From patchwork Tue Jun 27 16:06:32 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: 696864 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3865053wrm; Tue, 27 Jun 2023 09:12:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5xOPvGX0sTSywUYtS9dscu3WektMZELAYUFQNcjowXTL1u0JcUVQkiB6nSU4pF34FKN6T3 X-Received: by 2002:ac8:58d6:0:b0:3f5:1321:26f7 with SMTP id u22-20020ac858d6000000b003f5132126f7mr35872390qta.36.1687882333617; Tue, 27 Jun 2023 09:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687882333; cv=none; d=google.com; s=arc-20160816; b=0yR7hSLjVOQ5BjSYexrg80jJm8+B+QIM5ijDFhbNPis5QRnxLWBJD/fonsFxdiSGCh my+CFs/hrgHFK6FCYMeqfU8dVD2lNHrut+b1RR2OnCmBZIOvwZXzYonPtAOAfXQMFcQk OWti6+H0EnGSAlUKVqv0hVuS4DRXZm1BpHxh2hiwic8MLmg+plr6nZ30vzhOgqYTp1kx 6V39hZ/A7nzDOgjEnAx2wBfGIpopCSwp4gnx7BXiOu27nqDgs2DvWGMN+Jk6IenKzSgz u8lka6YHonFrLuE1UCHAUGhTQ/ih5jNPFRL6ym4dl3GVd+rUrEdp8AkHBh2cc4eZA0wZ YgpQ== 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=o65EU6QKm/ZKlwjUjomTQSbG60nANx/Rf8AOn4I397k=; fh=UYmazdnd7dWeaUl9zzIqQyuUvQUcVQKeyrKAe+85WNA=; b=oZ0EBV8lRTlXq1QFUXbSgtGkOeuMY6s8P/J6ogxtArngISjtQg1yRDtxI+Q2oxLpGA gVIt8kWr/4VQGOQ+zdne+aiB0VAECUO135MvTGGIfBtliv228ZPhoAmm0i/39kt5MQW5 WSZ+RWCcSfJXraw3GYyJQdxecPF/dGmbKnzr6Is5aqGVKFHjI1SbWGHkvO2N9ZFk3lSE t0G/rhTq4sw98MtIXHP0PhcM3y2Z0XDLyGaT9hxO6fIVvnyYhGrAdkuRhtj4lBb50tZj B7KLOi7JTUjnRrWi4wX2q8Nb8TyzJrAWJcnVgEHqSUoLV70pDK6S3IIZzxIQicgXYcOM 9kmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CbHtyoZ7; 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 o3-20020ac87c43000000b003f6c46a79c5si3271183qtv.454.2023.06.27.09.12.13 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 27 Jun 2023 09:12:13 -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=CbHtyoZ7; 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 1qEBE5-0000Lt-EX; Tue, 27 Jun 2023 12:07:33 -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 1qEBDk-0000Bx-Tp for qemu-devel@nongnu.org; Tue, 27 Jun 2023 12:07:12 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qEBDe-00058Z-OI for qemu-devel@nongnu.org; Tue, 27 Jun 2023 12:07:12 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-3fba8e2a9ecso6761415e9.3 for ; Tue, 27 Jun 2023 09:07:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687882025; x=1690474025; 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=o65EU6QKm/ZKlwjUjomTQSbG60nANx/Rf8AOn4I397k=; b=CbHtyoZ7l3CHg14wHQLLaJZkrslTC02xBDp/hppUHY8ORu4Gja0LUY7GpaSsrL0hAn 29JQ0SOPm84Vfrw93rkQ1aj7JBYMf9zAOFYg08LPgHdwR8NzsDTVXXiJlR1YXIuwlVvd b8zUZipq6wP7T9/iSAkbOUe3oc/raZ9SZ9xnDcw/w75oDb0m+NpF4mC/+uRpn5aXHduO rt9i1tbMP7sdAA0tf/UZvEsoL0w2/CjkgAoaxfVPAT067p9tWPVt2UvumBM6/0CYpvlw ux6U9yaQA6uQxbZZevMSuMcBddtH5vC/S2r24xhfrPi0Rm+p1PMk8KYuxhrZfQpE7p5N kWFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687882025; x=1690474025; 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=o65EU6QKm/ZKlwjUjomTQSbG60nANx/Rf8AOn4I397k=; b=jFTBMYplCjpUe978U/SNtaoQahMuIgOR+7GqqoB6IYAzxdivd9EMxbFf5DitYcLleg iOX56jivxzmGPL1S5snlfy/JLgYEC7HcRNK0tOQE8Dc6jsXNK/keIXWYvC6s2A63T4aQ 5SqQcKCk/AXH2cUuNbhCENH3hTaaTrPkzTBEvShw86rgyiCLUcEY9F8dlCfNEgnlCmGi K8PjA99mnkaVjKBG0him0MuSiTADi3zPgDCCCNsbNW/r9T/3Buoelp45jf6PojJOlWoN bVl5+GGFjANc17khziS8esksUW4lO5OtA++WLG/d55Zg3JLVc5B1p6xlEcNj6VXNmmFf rReg== X-Gm-Message-State: AC+VfDwPvvVSyqL9d7ab0Y9q2cJGszzwI14p7juQP8jPDREfSlTt3dWQ MCiDwfuNtYHVkhR0Zn1yBH+2KQ== X-Received: by 2002:a7b:c414:0:b0:3fa:7cb1:ff7a with SMTP id k20-20020a7bc414000000b003fa7cb1ff7amr9887231wmi.13.1687882024928; Tue, 27 Jun 2023 09:07:04 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id a10-20020a05600c224a00b003faef96ee78sm5045149wmm.33.2023.06.27.09.07.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 09:07:03 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id A265F1FFC3; Tue, 27 Jun 2023 17:07:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Riku Voipio , Leonardo Bras , Wainer dos Santos Moschetta , Leif Lindholm , Yanan Wang , Marcin Juszkiewicz , Bandan Das , Beraldo Leal , Laurent Vivier , Marcel Apfelbaum , Bin Meng , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , =?utf-8?q?Alex?= =?utf-8?q?_Benn=C3=A9e?= , Stefan Hajnoczi , Richard Henderson , Peter Maydell , Thomas Huth , Cleber Rosa , Alexandre Iooss , Juan Quintela , Eduardo Habkost , Paolo Bonzini , Qiuhao Li , Mahmoud Mandour , Peter Xu , Radoslaw Biernacki , Darren Kenny , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Alexander Bulekov Subject: [PATCH v3 08/36] tests/qtests: clean-up and fix leak in generic_fuzz Date: Tue, 27 Jun 2023 17:06:32 +0100 Message-Id: <20230627160700.2955547-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230627160700.2955547-1-alex.bennee@linaro.org> References: <20230627160700.2955547-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x32c.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=unavailable 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 --- tests/qtest/fuzz/generic_fuzz.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index c525d22951..d0a59f7475 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++) { + for (int i = 0; i < ARRAY_SIZE(predefined_configs); i++) { config = predefined_configs + i; - name = g_string_new("generic-fuzz"); - g_string_append_printf(name, "-%s", config->name); 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,