From patchwork Fri Jun 30 18:03:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 697961 Delivered-To: patch@linaro.org Received: by 2002:adf:fcc5:0:0:0:0:0 with SMTP id f5csp593889wrs; Fri, 30 Jun 2023 11:08:15 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5cHKnvYynjVn8lIDz2JJaHTVmzTAYOHn5Tz07DstoHqpNdg/Qzbizc68bwE3sH8eGe42dM X-Received: by 2002:a05:6808:aaa:b0:3a3:6331:fd69 with SMTP id r10-20020a0568080aaa00b003a36331fd69mr3376156oij.8.1688148495367; Fri, 30 Jun 2023 11:08:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688148495; cv=none; d=google.com; s=arc-20160816; b=BpNL7F6MMCAFuMjN+9dqIIS5RHu7aSyyXbcWtjs2S/pnxISJ93dRTI4Y9F2Hf1zDGH zvjb9KNnn0+Di92Hs1fLDiqZnfYPGrQMwhkHp0xBlTZ+HwhhHoc8oU82NCqr29b3tKoM yAahHXplIEwhkoPLYBY8pw1DCq/toufSP1MfhkX3u+ct2Yoa5F9nBaAjlNQxOsNyb2kX 05FjhI2Tz+BUojSDFgnBE92mZY1iunDG1jn5pSGmPrmB0byFp81JolrAvfsekzq93BxB o/n4mK8uBAcyvr93R14lI990nV7oeWlYoT64e++rPaBHunSXzbUyHorEIBcnXHXuFPVj mnOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=SSu5pHfoFzXcN2jMDhRn3eR0vnuKsKx/O0/7tf0yFTM=; fh=OltHerz+Vf7zZkebZbScoRT4WgVwJDskRS7DoEjx2Hw=; b=hsjz23LGWLnII+jgAaPBi+HImOQ+7dsSYUbchUMBdnqle3O5iia96kRFWgft+t1U1r q5WwKOfgn+Fqe+Zjgu7hL3dgFHyKPRnKi2c+8/1qys4CjsGbjjGUFIBin6r7JrdDCSOQ 27IQEw5rVwS9exK1e/neRaEoUMIjIECFyLJPVzhhP9z+7+H+1lCfjFfvGQOg7fE3RuLz bFRcJS/3DQgrVoGC9vbWo6ZIkUnWjDbKS9TE5/L0m+AfLUAuYAdn7/Pv0hVjQYnxKUC5 3+y1EHQf520PYbj0ZzyGUWaSyGZLlUcyYjuNdfZxQ22ftyBHpGuC7iWHccMQiMtnOYzq aNDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gmI1tCM/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id tc1-20020a05620a2cc100b007671ac49befsi4718259qkn.682.2023.06.30.11.08.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Jun 2023 11:08:15 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gmI1tCM/"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qFIU3-0008Lu-0e; Fri, 30 Jun 2023 14:04:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qFITx-0008IL-RZ for qemu-devel@nongnu.org; Fri, 30 Jun 2023 14:04:35 -0400 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qFITt-0006yz-Py for qemu-devel@nongnu.org; Fri, 30 Jun 2023 14:04:32 -0400 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-314172bb818so2391820f8f.1 for ; Fri, 30 Jun 2023 11:04:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1688148268; x=1690740268; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SSu5pHfoFzXcN2jMDhRn3eR0vnuKsKx/O0/7tf0yFTM=; b=gmI1tCM/SzFKZXXDBrrViPmwB5IpkzBVuzKvF58c4h2JL+/MLQgDzcg6aOke7RgKBp d3uq1KhwOEQOqI7POh0IkwWoMgYE3/B6W6d8aeR24Te3Cv27dZInOiYLRv6gEvs4ebHP K5dYahrofUra5LlAuxQnVRwUKu5kXvfAm1l6ESW5kZkg67vedbnOl8wx4ne3sF7jvjma LsITkM1Zu4R3kU5NtaTYtn0L/6b3pNGvCBucGs/BPTztscdwkVOjyl5zV2BcGOt5ZChq DwPEQxndmKBxSj+9UWfybCEwGa/A/Kgs/plQpoj0vIp0A9D6IbPGdnP97fB1eELVE+F0 /keQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688148268; x=1690740268; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SSu5pHfoFzXcN2jMDhRn3eR0vnuKsKx/O0/7tf0yFTM=; b=gepRnD6GR0ZTJh+NFTPlJesS5WHfSTVtJz4sdJoghzr1Zk3w7cZcEMX3R2U9QPJCx0 u/wemRrCtHuGecOmvIwbLfdhbY5/NMtttJyKTRQvN8fsZTa9djALb6fWWTTB7yCo/Cza H4gGNWCkVCO6YpS82cFNSlGqXSIaG/U3xXQKLbFdvSUdUbSAuVSoH6x6PxVkijyNSiK4 LngxHd0BAZ1TkrVyMkwUFcAIobTpVyL3xBqtROjTFigfJMfx5RMxkiP88/QGZ+iQDPbh ZS9KCL2Ic7ZvFt6swUBariXiwRm/CsXJU+JFn6ONES3VyXugybzIBJzEtJfcR8QktJmA Fz0A== X-Gm-Message-State: ABy/qLZGW96PqPrgGn1OeGobOBOcIjNJDbXT+a9e6kNUT/q1ov5Pp4Om bqJtCMUcinaKjRBnOvjvwN9t8Q== X-Received: by 2002:a5d:61d2:0:b0:313:e8bf:a6e with SMTP id q18-20020a5d61d2000000b00313e8bf0a6emr2851150wrv.21.1688148267856; Fri, 30 Jun 2023 11:04:27 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id b7-20020a5d45c7000000b003141a3c4353sm4227394wrs.30.2023.06.30.11.04.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jun 2023 11:04:26 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id BD5481FFBB; Fri, 30 Jun 2023 19:04:24 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Paolo Bonzini , Stefan Hajnoczi , Leonardo Bras , Laurent Vivier , Peter Xu , Juan Quintela , Beraldo Leal , Radoslaw Biernacki , Qiuhao Li , Peter Maydell , Yanan Wang , Riku Voipio , Wainer dos Santos Moschetta , Mahmoud Mandour , Alexandre Iooss , =?utf-8?q?Alex_Benn=C3=A9e?= , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , Eduardo Habkost , Thomas Huth , Laurent Vivier , Bin Meng , Marcel Apfelbaum , Bandan Das , Cleber Rosa , Richard Henderson , Leif Lindholm , Marcin Juszkiewicz , qemu-arm@nongnu.org, Darren Kenny , Alexander Bulekov Subject: [PATCH v4 08/38] tests/qtests: clean-up and fix leak in generic_fuzz Date: Fri, 30 Jun 2023 19:03:53 +0100 Message-Id: <20230630180423.558337-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230630180423.558337-1-alex.bennee@linaro.org> References: <20230630180423.558337-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::433; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x433.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org An update to the clang tooling detects more issues with the code including a memory leak from the g_string_new() allocation. Clean up the code to avoid the allocation and use ARRAY_SIZE while we are at it. Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson --- v3 - use g_strconcat instead --- tests/qtest/fuzz/generic_fuzz.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index c525d22951..11256abf6c 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -954,17 +954,10 @@ static void register_generic_fuzz_targets(void) .crossover = generic_fuzz_crossover }); - GString *name; - const generic_fuzz_config *config; - - for (int i = 0; - i < sizeof(predefined_configs) / sizeof(generic_fuzz_config); - i++) { - config = predefined_configs + i; - name = g_string_new("generic-fuzz"); - g_string_append_printf(name, "-%s", config->name); + for (int i = 0; i < ARRAY_SIZE(predefined_configs); i++) { + const generic_fuzz_config *config = predefined_configs + i; fuzz_add_target(&(FuzzTarget){ - .name = name->str, + .name = g_strconcat("generic-fuzz-", config->name, NULL), .description = "Predefined generic-fuzz config.", .get_init_cmdline = generic_fuzz_predefined_config_cmdline, .pre_fuzz = generic_pre_fuzz,