From patchwork Mon Jun 26 21:59:08 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: 696503 Delivered-To: patch@linaro.org Received: by 2002:adf:e885:0:0:0:0:0 with SMTP id d5csp3448074wrm; Mon, 26 Jun 2023 15:03:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ61W5+cdJ7mGbUDIecr2cDCYnGL/0zPLdt7dAXRLsLHWDp+swZFaGQw5TbnT3dgiRHhIFc5 X-Received: by 2002:a05:6214:c88:b0:626:272b:28e9 with SMTP id r8-20020a0562140c8800b00626272b28e9mr33612860qvr.24.1687817006718; Mon, 26 Jun 2023 15:03:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687817006; cv=none; d=google.com; s=arc-20160816; b=hPLfBiQ9W310dIS5MOv7qZbW1NwsJb5mxmGlkyJLpUc2uB0HM9nsh9OLxq54N9EElq +QteFuaDAhuH49mhDsPkO/vGbVKjOKzCIpEC7s+ZIvjSEtHqOX3Nc32FADUux4PeBiH4 RMG34Grb2PP08Z6SknZ0BOYTfUUEb40A33QkVa9JYT3CWSdhkbOND+Q1VlTrnVoF9wdb EVUxFaz67WQftGSz7+lGsYE7wTibU5wYWY6quxv4qkjXrRJtSv7NvXP+sVdHvVMaGzLg z4HywXZ/n65MWrd9KDX9/fukV7bc0elVfjRNryfoHuhTSb5OdXMm0iE8Cg4/gyJBstow 81Pg== 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=; fh=sQEya64SXtq2IEsk3H77u01QQAMvGjGQGvqUW/mcVd0=; b=aT4MYrpvDvGzNR6LW0vOvoZ0aSux6JArjQbjNWL6IhIT1dGYy6Nj17aWnd5TFcazms pEn6wY6rN80FY+zsHVm8UP9PqMgy1H3HyPV8TGlI4cIRrsqoyk0BbD1eGfTZ22FeRgBz zukDSRpwdjHRO+4vI1M1RmeFiZNqmDz0xUs2ITJHlCywrwH0mhvloA+hfU3wcROoawtp +rJAtPksJjXO7Dg6j8Amd0pfr4vg+W9jIPA3BujZbQPp+WBXZ5FXjYm4N5Xie0JvKP/j 5IN6u397w2tH15RnljYKpz6pDqYrkweQSo9ClmufUcooj3Ux0NkuORFcGv1+PM8x2Pt/ KG5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y4cWEPo7; 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 jr11-20020a0562142a8b00b0061ac2bf9f0dsi2440193qvb.435.2023.06.26.15.03.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 26 Jun 2023 15:03:26 -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=y4cWEPo7; 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 1qDuFI-0002dp-No; Mon, 26 Jun 2023 17:59:40 -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 1qDuFE-0002aa-Uy for qemu-devel@nongnu.org; Mon, 26 Jun 2023 17:59:36 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qDuFA-0004s9-Fs for qemu-devel@nongnu.org; Mon, 26 Jun 2023 17:59:36 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-3fa99742af9so13350205e9.2 for ; Mon, 26 Jun 2023 14:59:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1687816771; x=1690408771; 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=y4cWEPo7e4u0mgr0SUohceoPO7QQiLIHO5sWxD8mrpnSuo98WJjvCJ0ZbIlSPjk14s L3rFJNirp+f0GaoMaJOU9OJdo1k20U77/V5xJw2LJRJ/uRr+pVLh6xoZwMAnE0ND6yWt l+aVsPIjFRikBRE0jM6GPH5nhnKreYZHUDZIspWNzCMVWipYdKH+H3R3wJdSq2UpbxqJ JYZcklhmSQ5G+wLy9FoStOvIjWr+CCe/kBRQvXtfQ2JxThj4L3QSdv8cFDDHD6JFPDcD tpde7PJRL1pqp/ZU1UXQFIz0GCQlhRLJTs8X7byCrFCGEh2ObcLf6fPIQZ6IPe/Fs5lM 6pgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687816771; x=1690408771; 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=b66xnS9VewmpiOyxSojPD86lw5IVp3YfJ1WnukqJErZXpThnJ2M8UEZD3uzdx0bziZ qk4GHqiSEdH8fEU+z89fkiXGRVIeFKLx5vDFlHeI7PrCo/0QfDB9EFAULpbLz6nrj7hE y3aDdZwOgbB+t99oJlZCVuuYa6bj/82+YN2V/17DC3lyVzC7nBm5WklMqM0u+0Fk7/oz zHnvp3JWMKzXhtm8kC/N6BPIC/vU+Dkw8PVoSD6xTCwvx9eyEzIc08nugMmDkvfOqPUX MJz/90v1l6Tb8ALn444faKLt3TlQfAsVYi2j9F/ne20HkVama9TO7sbpAWk2NhYNSLiq NtDw== X-Gm-Message-State: AC+VfDzqW1LJJNpGna35cKCbOZst1+2n4TCEeAoLkpaBQsWPe2D+3UmX 2V/L3n63Fzgkns7InO8p5sct/w== X-Received: by 2002:a7b:c399:0:b0:3fa:9590:a365 with SMTP id s25-20020a7bc399000000b003fa9590a365mr2927101wmj.17.1687816771132; Mon, 26 Jun 2023 14:59:31 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id k26-20020a7bc41a000000b003f080b2f9f4sm11751894wmi.27.2023.06.26.14.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 14:59:29 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id B91EB1FFC3; Mon, 26 Jun 2023 22:59:27 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: Alexander Bulekov , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Juan Quintela , Alexandre Iooss , Thomas Huth , Marcel Apfelbaum , Leif Lindholm , Riku Voipio , Peter Maydell , Paolo Bonzini , Bandan Das , Leonardo Bras , Cleber Rosa , Richard Henderson , Beraldo Leal , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Xu , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Mahmoud Mandour , Stefan Hajnoczi , Yanan Wang , Eduardo Habkost , Bin Meng , qemu-arm@nongnu.org, Wainer dos Santos Moschetta , Darren Kenny , Radoslaw Biernacki , Marcin Juszkiewicz , Qiuhao Li , Laurent Vivier Subject: [PATCH v2 08/26] tests/qtests: clean-up and fix leak in generic_fuzz Date: Mon, 26 Jun 2023 22:59:08 +0100 Message-Id: <20230626215926.2522656-9-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230626215926.2522656-1-alex.bennee@linaro.org> References: <20230626215926.2522656-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x334.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 with g_autoptr and use ARRAY_SIZE while we are at it. Signed-off-by: Alex Bennée Reviewed-by: Juan Quintela Reviewed-by: Alexander Bulekov --- 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,