From patchwork Thu Sep 22 16:35:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 608260 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp513118pvb; Thu, 22 Sep 2022 11:53:53 -0700 (PDT) X-Google-Smtp-Source: AMsMyM775NmGbXrbG0r6fgn5UH07Mii7xB2MPYdFY9g4gqhYJz7wzu9OzKXYu+QWVe82L/OZ8LYG X-Received: by 2002:ac8:7d90:0:b0:35b:afd3:20aa with SMTP id c16-20020ac87d90000000b0035bafd320aamr4045671qtd.252.1663872833135; Thu, 22 Sep 2022 11:53:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663872833; cv=none; d=google.com; s=arc-20160816; b=dCekhfPeNicn7yUWKU92B5XaydYopaWo2XnQDprVhLxeasYA/9GT2cTQ36rl+uvm6O taPnTj1A9JYwA1OsS8CDig0tWS7Rm2JBVWTkesIEMi3VRKQTVfXD7Ms2W2WKI1Asl01O kMMzav1x5azeESmFrI7mVQzqbqzLoJz6h/Fkc+JptJPmR1owMvUvoEnA0Ej9/zAmEdCR kxW6ODV29GDZgh18sSAG3YbJz6dMzXw+VxUBd2SfdRO3XHgmGHZ/ZKyVO61OgpvUFiL7 4ei568RAyqwhzUGoP/UKVj8jR3pP8fyOL9lsVaDAj4vGG8JuiDq8+EFswQCwzJITLpeG HNLg== 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:to:from :dkim-signature; bh=bhukZinHP19tc2MABOlYOy3TPhufYb3LdwBHDFcAuKE=; b=dBpuvYtPScddOqnz3P6BXS2DE4qKr0etHsiRyj8pg6srYyoYSs3maJyhjU33xzjD4G I50NrIb8fglSG+KK9A9JIl09ScHM/vNMsAXLgkm9p9SV9EMG0RhkJS2eNpIrvbiiAlkE t4g70zsROoLmHtwMuhTK2MD1BXeYo0HJeEx03NlVZUsgj32cM2GeVpQc3YYEBUhJf8fv fheP0ZGNZWjE4mtkf/tpXSue0zLgnQgL61c70EasFS4clVQX7xDWBmItaXuMHzX2odB5 JNFGAe2/giNxK6X+PEbnb1x29Rkc7vhJAwhQRMgRxnNF+OwYfhpj3CUxSKpTP4e40LDF 6m3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CS47AR3K; 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 s22-20020ac87596000000b0035a89595940si3443198qtq.19.2022.09.22.11.53.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 22 Sep 2022 11:53:53 -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=CS47AR3K; 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]:57740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obRKa-0008In-Ij for patch@linaro.org; Thu, 22 Sep 2022 14:53:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41208) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obPBG-0002De-Iu for qemu-devel@nongnu.org; Thu, 22 Sep 2022 12:36:10 -0400 Received: from mail-wr1-x432.google.com ([2a00:1450:4864:20::432]:38707) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1obPB9-0005Qb-O7 for qemu-devel@nongnu.org; Thu, 22 Sep 2022 12:36:02 -0400 Received: by mail-wr1-x432.google.com with SMTP id n15so9519025wrq.5 for ; Thu, 22 Sep 2022 09:35:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=bhukZinHP19tc2MABOlYOy3TPhufYb3LdwBHDFcAuKE=; b=CS47AR3KgcJoOEJE6MR308REqH9N0PmQ0EFuZ20HS0YuCl0OEP88H2Xh7wVro4rlXa 5Rd8swQfM4ZpfvOHR7apLQbLfG5DUJfIxAI8v72hdKRYRGKlypbDLhrYUFiWGasovsj1 rIDxvKk6Kk4JgNgVOqArftEoMtfukPjtj2DqkvydxUmFbI4byXZOCOT/xBdHf0xpAdkN y0/75mx76U/N3ekLVDxInvUztsmilQ7exsNmqjEIWt8Qo/rKOYzwP2RSzIevPjfrwVsn giEGIHQr+cVLauD8mua4iwGvVsRYU8yS4E0gtMwJGRG6yIoLBQkLUdAyX6V6LKnwV98v HYKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=bhukZinHP19tc2MABOlYOy3TPhufYb3LdwBHDFcAuKE=; b=hPwicJkM4nSlCNohOHQN098vvyvaFSMii+i2Vx/rwdEesSoXMT1dc0vbNJCeWWkG/B e+q7Ql/frZGkTxeDKIP1WuAOPPx6KCiS3qANvRzGOUg05dGo0ssol7LH4AwWpgVnqYpB Co7zpkry0EGzN4qKkTi0FThfyAjD9bJmyknu1eBIYugrU0rlJ5PQsdul3eswmC+BB13i FtN+3rjvR7oPfnS6l/7N5sbmyI4dSpkRWf5O7tf0r+FlkgOuvq6amkEBsrGM/xIck985 5Mx+OIiM2VU3E7ODVLYWML5FIA/MaGZmwsHziHqkWwV63zi9tqD8ruoYmd2nSPgvNv0p vNqQ== X-Gm-Message-State: ACrzQf2BriZi6Se0kaXj7k2rIemj9Pw3pTS01ujPnf6K/PlKo+MLnFUO 71HSTKENBhz9B5aXVR/hBHEF06hRrQXE9g== X-Received: by 2002:a05:6000:1241:b0:226:d999:a2df with SMTP id j1-20020a056000124100b00226d999a2dfmr2585527wrx.19.1663864558936; Thu, 22 Sep 2022 09:35:58 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id iw1-20020a05600c54c100b003b3401f1e24sm6452599wmb.28.2022.09.22.09.35.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 09:35:58 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 32/39] tests/unit/test-vmstate: Avoid dynamic stack allocation Date: Thu, 22 Sep 2022 17:35:29 +0100 Message-Id: <20220922163536.1096175-33-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220922163536.1096175-1-peter.maydell@linaro.org> References: <20220922163536.1096175-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::432; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x432.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 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" From: Philippe Mathieu-Daudé Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson Signed-off-by: Peter Maydell Message-id: 20220819153931.3147384-12-peter.maydell@linaro.org --- tests/unit/test-vmstate.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/unit/test-vmstate.c b/tests/unit/test-vmstate.c index 72077b57800..541bb4f63e3 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -87,17 +87,16 @@ static void save_buffer(const uint8_t *buf, size_t buf_size) static void compare_vmstate(const uint8_t *wire, size_t size) { QEMUFile *f = open_test_file(false); - uint8_t result[size]; + g_autofree uint8_t *result = g_malloc(size); /* read back as binary */ - g_assert_cmpint(qemu_get_buffer(f, result, sizeof(result)), ==, - sizeof(result)); + g_assert_cmpint(qemu_get_buffer(f, result, size), ==, size); g_assert(!qemu_file_get_error(f)); /* Compare that what is on the file is the same that what we expected to be there */ - SUCCESS(memcmp(result, wire, sizeof(result))); + SUCCESS(memcmp(result, wire, size)); /* Must reach EOF */ qemu_get_byte(f);