From patchwork Fri Jun 23 12:20:43 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: 695238 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp1920348wrm; Fri, 23 Jun 2023 05:23:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5JGLsw+3aPQYpetuihtwuDuCCvX0ZIW3mtDFCaEGTwOJz3C5ge+YV9HtbS3L8Xuvg1srEa X-Received: by 2002:a05:620a:9449:b0:75b:23a0:d9e6 with SMTP id sm9-20020a05620a944900b0075b23a0d9e6mr20003059qkn.60.1687523001065; Fri, 23 Jun 2023 05:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687523001; cv=none; d=google.com; s=arc-20160816; b=eZlsR68QFEximN3VWjNDrlRbzvWQEU+0pLlT9O590yKXRMbMakJypbelb3XXwn4VQQ e6hJ85Qpert+VrRsGMnW1bkvnUAmJ0Bu1YLxogIldty3LIQYyPLS/lCfGM0O3FTMDP/i 5CzlrZ1AxtSB/EGIUbbsZoIJwH/ICg0gNAvLJFLteqWldBp+b8mRTA9HQ21vKhA+Q4YB fS0Nz5MhklvgetAqyqa12noMuMMJARf9uggknDLQgZVz54m4GadkDU+zO1beAHA8VoG5 knO5zZUPiyBazzut1/Ddm+bjvG3WugA8/VO33QfhyDmxIq1XSzxpQVXXmFfn/NO4ekhg O4KA== 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=cCVrBcA62K9RLf5e56Guknvwd44ZoDW7Y93GujqWZjQ=; b=imR+iSux7pd/P6kKdllzdQhB+1FxHtCyhXuKGmZ7dB4NEfMsTCZtmfpYljgxMf6G5E PueqeNjkgpZDeTQ+5/4Olkcxxx1m/2v1WFHJ9zMdOHCqb6CEyPU7ZU8gSiSogB9KR5fX 7Nv+fQoGRWOT1pFe6QdJmaA5dvsEopIUMLgi4/hL+qTkl+Ql715S+QnMr7f4xMYreMd9 3iGIXsJneKyNZVczmcPcVigujIfpQsQd2dPl4KBNWuVSv9VDwd7ZUA9Ib65s5pCPM/3g kRUnXgFjdb792YqtJpZpWnCs5TTW7CjOrmZpfDuodHg2yzp2s9RlGz8dg9zC5ENUlNtc +7zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KTpc5rQI; 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 qw23-20020a05620a8b1700b0076554a836e6si78314qkn.580.2023.06.23.05.23.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 23 Jun 2023 05:23:21 -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=KTpc5rQI; 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 1qCfo1-0004mU-MV; Fri, 23 Jun 2023 08:22:25 -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 1qCfmu-0003o5-My for qemu-devel@nongnu.org; Fri, 23 Jun 2023 08:21:18 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qCfmo-0003hz-AA for qemu-devel@nongnu.org; Fri, 23 Jun 2023 08:21:13 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-3f9c0abc8b1so7225165e9.1 for ; Fri, 23 Jun 2023 05:21:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687522865; x=1690114865; 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=cCVrBcA62K9RLf5e56Guknvwd44ZoDW7Y93GujqWZjQ=; b=KTpc5rQI22c/y3NRcMlIiXKjNRvshvRgkP98Q9XeXBcJHV6bMrlnYYr01sqnTptoTQ uk0cCTx19AZNsn6u8GuEX+Rs1BrJdpenN6md2sq2TxV8vH28uiG6KEbbztbITEeu5F+b Yg6Cor0xOvVCbqcZrlKECvgnDRgjDVX9iy/pgpwYuj5eAqlPYluAJDRVA7SeLO2fUfpD ZT9sUaXqfOC04wK/Z1AvYzoMcevifTe9/tRpGKPVZ4ciNH0uBoJY7ptPymYhv44ua7rW WhnFLSC/Z6cDqC+FATKO8uV5JAPwgwVUBLAIBNtZqDLFuoqpUI5X+Qtr2wTIoEHBz079 gXBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687522865; x=1690114865; 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=cCVrBcA62K9RLf5e56Guknvwd44ZoDW7Y93GujqWZjQ=; b=eFHL0ZP9u7z64Ik3aVPXA8BM7X6fVKgaM3fpIL+9T8TGsStCevUG6ulTVhYCIQv4FU IJOEsM0EhWJgKTl8N4tI6uiMTGQkjdwDIuuYN1+ZYtjZpQT/ASrljS6TxJa7rf0kO3T5 0IYUnnNaN1FZsU57tiUtWeSOLfTxiPwrXHOmYJVjhUxiPCSo+y3xT54XOz6OKFTKlH7m KT/UmdyxSfNDjT+ztscYpATggwlwtc97k4t1jKAsCPP8ffaYciLeJyFzP70itZLFCVBM x2wk50Tq+kWaF/mI9igR+91Rn8EmmR3XVVisFv+snmEpj1Wp6JlT9QFYnjGVKocEinjS mJxA== X-Gm-Message-State: AC+VfDwo4+0vLIo3hVvAc50Dhw5GkohnKp6z852p62n3qPFCBbdXcq81 06n9A+f7tOLtjOTU0SQTfAqGYw== X-Received: by 2002:a7b:c7cb:0:b0:3f9:b1e7:8a41 with SMTP id z11-20020a7bc7cb000000b003f9b1e78a41mr12023755wmk.35.1687522865709; Fri, 23 Jun 2023 05:21:05 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id c25-20020a7bc019000000b003f819faff24sm2195346wmb.40.2023.06.23.05.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 05:21:02 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7B3A71FFBB; Fri, 23 Jun 2023 13:21:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Richard Henderson , Juan Quintela , Peter Maydell , Cleber Rosa , Darren Kenny , Alexandre Iooss , Peter Xu , qemu-arm@nongnu.org, Eduardo Habkost , Riku Voipio , Mahmoud Mandour , =?utf-8?q?Daniel_P=2E_Berrang?= =?utf-8?q?=C3=A9?= , Paolo Bonzini , Bandan Das , Marcin Juszkiewicz , Radoslaw Biernacki , Alexander Bulekov , Leif Lindholm , Qiuhao Li , Wainer dos Santos Moschetta , Marcel Apfelbaum , Leonardo Bras , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Bin Meng , Thomas Huth , Beraldo Leal , Laurent Vivier , Yanan Wang , =?utf-8?q?Alex_Benn=C3=A9e?= Subject: [PATCH 09/26] tests/qtests: clean-up and fix leak in generic_fuzz Date: Fri, 23 Jun 2023 13:20:43 +0100 Message-Id: <20230623122100.1640995-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230623122100.1640995-1-alex.bennee@linaro.org> References: <20230623122100.1640995-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x332.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 with g_autoptr 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, 4 insertions(+), 7 deletions(-) diff --git a/tests/qtest/fuzz/generic_fuzz.c b/tests/qtest/fuzz/generic_fuzz.c index c525d22951..a4841181cc 100644 --- a/tests/qtest/fuzz/generic_fuzz.c +++ b/tests/qtest/fuzz/generic_fuzz.c @@ -954,17 +954,14 @@ static void register_generic_fuzz_targets(void) .crossover = generic_fuzz_crossover }); - GString *name; + g_autoptr(GString) name = g_string_new(""); 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); + g_string_printf(name, "generic-fuzz-%s", config->name); fuzz_add_target(&(FuzzTarget){ - .name = name->str, + .name = g_strdup(name->str), .description = "Predefined generic-fuzz config.", .get_init_cmdline = generic_fuzz_predefined_config_cmdline, .pre_fuzz = generic_pre_fuzz,