From patchwork Mon Oct 7 15:19:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 11177841 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14BAE139A for ; Mon, 7 Oct 2019 15:24:54 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E95132053B for ; Mon, 7 Oct 2019 15:24:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E95132053B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Received: from localhost ([::1]:46022 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUsW-0007eh-C1 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 07 Oct 2019 11:24:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47410) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iHUno-0002ts-5E for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iHUnm-0008Ly-SB for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:20:00 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41681) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iHUnk-0008Iy-8X for qemu-devel@nongnu.org; Mon, 07 Oct 2019 11:19:56 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4789E8A1CAE; Mon, 7 Oct 2019 15:19:55 +0000 (UTC) Received: from x1w.redhat.com (unknown [10.40.206.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF16519C5B; Mon, 7 Oct 2019 15:19:52 +0000 (UTC) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 3/7] tests/libqos/fw_cfg: Document pc_fw_cfg_init to drop pc_fw_cfg_uninit Date: Mon, 7 Oct 2019 17:19:01 +0200 Message-Id: <20191007151905.32766-4-philmd@redhat.com> In-Reply-To: <20191007151905.32766-1-philmd@redhat.com> References: <20191007151905.32766-1-philmd@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Mon, 07 Oct 2019 15:19:55 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Thomas Huth , Laszlo Ersek , Li Qiang , Gerd Hoffmann , Stefan Hajnoczi , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" Document pc_fw_cfg_init() return value must be released with g_free(). Directly calling g_free() we don't really need pc_fw_cfg_uninit(): remove it. This reverts commit 65461d124363: "tests/libqos: Add pc_fw_cfg_uninit() and use it" Reviewed-by: Laszlo Ersek Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Li Qiang --- tests/fw_cfg-test.c | 22 +++++++++++----------- tests/libqos/fw_cfg.h | 14 +++++++++----- tests/libqos/malloc-pc.c | 2 +- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/tests/fw_cfg-test.c b/tests/fw_cfg-test.c index 1d3147f821..53ae82f7c8 100644 --- a/tests/fw_cfg-test.c +++ b/tests/fw_cfg-test.c @@ -36,7 +36,7 @@ static void test_fw_cfg_signature(void) buf[4] = 0; g_assert_cmpstr(buf, ==, "QEMU"); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } @@ -52,7 +52,7 @@ static void test_fw_cfg_id(void) id = qfw_cfg_get_u32(fw_cfg, FW_CFG_ID); g_assert((id == 1) || (id == 3)); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } @@ -73,7 +73,7 @@ static void test_fw_cfg_uuid(void) qfw_cfg_get(fw_cfg, FW_CFG_UUID, buf, 16); g_assert(memcmp(buf, uuid, sizeof(buf)) == 0); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } @@ -88,7 +88,7 @@ static void test_fw_cfg_ram_size(void) g_assert_cmpint(qfw_cfg_get_u64(fw_cfg, FW_CFG_RAM_SIZE), ==, ram_size); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } @@ -102,7 +102,7 @@ static void test_fw_cfg_nographic(void) g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NOGRAPHIC), ==, 0); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } @@ -116,7 +116,7 @@ static void test_fw_cfg_nb_cpus(void) g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_NB_CPUS), ==, nb_cpus); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } @@ -129,7 +129,7 @@ static void test_fw_cfg_max_cpus(void) fw_cfg = pc_fw_cfg_init(s); g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_MAX_CPUS), ==, max_cpus); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } @@ -158,7 +158,7 @@ static void test_fw_cfg_numa(void) g_free(node_mask); g_free(cpu_mask); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } @@ -171,7 +171,7 @@ static void test_fw_cfg_boot_menu(void) fw_cfg = pc_fw_cfg_init(s); g_assert_cmpint(qfw_cfg_get_u16(fw_cfg, FW_CFG_BOOT_MENU), ==, boot_menu); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } @@ -190,7 +190,7 @@ static void test_fw_cfg_reboot_timeout(void) g_assert_cmpint(filesize, ==, sizeof(reboot_timeout)); reboot_timeout = le32_to_cpu(reboot_timeout); g_assert_cmpint(reboot_timeout, ==, 15); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } @@ -209,7 +209,7 @@ static void test_fw_cfg_splash_time(void) g_assert_cmpint(filesize, ==, sizeof(splash_time)); splash_time = le16_to_cpu(splash_time); g_assert_cmpint(splash_time, ==, 12); - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); qtest_quit(s); } diff --git a/tests/libqos/fw_cfg.h b/tests/libqos/fw_cfg.h index 3247fd4000..6316f4c354 100644 --- a/tests/libqos/fw_cfg.h +++ b/tests/libqos/fw_cfg.h @@ -54,14 +54,18 @@ QFWCFG *mm_fw_cfg_init(QTestState *qts, uint64_t base); */ QFWCFG *io_fw_cfg_init(QTestState *qts, uint16_t base); +/** + * pc_fw_cfg_init(): + * @qts: The #QTestState that will be referred to by the QFWCFG object. + * + * This function is specific to the PC machine (X86). + * + * Returns a newly allocated QFWCFG object which must be released + * with a call to g_free() when no longer required. + */ static inline QFWCFG *pc_fw_cfg_init(QTestState *qts) { return io_fw_cfg_init(qts, 0x510); } -static inline void pc_fw_cfg_uninit(QFWCFG *fw_cfg) -{ - g_free(fw_cfg); -} - #endif diff --git a/tests/libqos/malloc-pc.c b/tests/libqos/malloc-pc.c index 6f92ce4135..949a99361d 100644 --- a/tests/libqos/malloc-pc.c +++ b/tests/libqos/malloc-pc.c @@ -29,5 +29,5 @@ void pc_alloc_init(QGuestAllocator *s, QTestState *qts, QAllocOpts flags) alloc_init(s, flags, 1 << 20, MIN(ram_size, 0xE0000000), PAGE_SIZE); /* clean-up */ - pc_fw_cfg_uninit(fw_cfg); + g_free(fw_cfg); }