From nobody Fri Dec 19 06:17:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1620249163; cv=none; d=zohomail.com; s=zohoarc; b=XsA5rm8ZjaM2Si0MY3y++RKrIK90BR1WKG0E4by8rvIiXYtbbEv1boOWAoKLALoFx4/U0jWNt3y/wnyjyG/enZhM+8NEc4ioJNVv02SYLQuqQphpIP0bD/bN3lIVZKA0DWM8u6jnWVLLuSQQukosnkygyX5/tlVjmKqS9Zb5OPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620249163; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=FUeFPg/DBT6PTTnQUMbBIc/iv0DSckK3YeVFNuGPU00=; b=HAPSK2uL4zv6RP9hzWeWXWqGOZAbvbzyNlgF3ew/zBWkJj+1U+nyLMx6ftJoLTGA4GrhwrHEKq0HqDZGz6y9X8g0ifls99/VI8w/1fBJ/P2COLBwSwbOeNlOE1XUShiTNnS1zJyJpth38OzDyAzOxz2soFy3tvJh8LDJwNi7CWQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1620249163756508.32215578394414; Wed, 5 May 2021 14:12:43 -0700 (PDT) Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-236-XMbvzIM-MpC-QpH6kGIbfg-1; Wed, 05 May 2021 17:12:41 -0400 Received: by mail-wm1-f72.google.com with SMTP id v2-20020a7bcb420000b0290146b609814dso730246wmj.0 for ; Wed, 05 May 2021 14:12:41 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.redhat.com (astrasbourg-653-1-188-220.w90-13.abo.wanadoo.fr. [90.13.127.220]) by smtp.gmail.com with ESMTPSA id e18sm725918wrc.85.2021.05.05.14.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 May 2021 14:12:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620249162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FUeFPg/DBT6PTTnQUMbBIc/iv0DSckK3YeVFNuGPU00=; b=G7c+mrOgcT+LU+q+LPMHWaJFYJME2DzO66SaAYdDLXklBbttj+yzlwGiMdzYtxwO9DQDvM ShAkp4L194JJUvFkwLZiUsJzpDF+6QVF3fJYbKtBDKkG1E36OmU+YM0GB0GroKA6UJVyag +j5jm/0XE36EuLi6Zz71YIjkbM+P3dU= X-MC-Unique: XMbvzIM-MpC-QpH6kGIbfg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FUeFPg/DBT6PTTnQUMbBIc/iv0DSckK3YeVFNuGPU00=; b=M0a/naYFNovY2uErQoxGpz/IU80Ovn4heauczlSgkviMZjYjDEYqAH79PAyJV0VxZE MvOi/CbsLfvAuGrWW216+9vEaNd8hHUwvPLiBeOV9y5qfJZVKFGQHot+89+Sptlbhj6C IcmlTjTRBFTnbD5BV4BjhtYpnUWvTu4LbPeZTncFOg+Bz26/fyNJ2LXO9BmSlX+BdDGB rdS62H1d4qUe+g0bSUrmW0g7dJPO/8+72vmVOETBx2a4MRbJHXCmFbaFMWdzNXwQwPQP 3bqEiY8naR9IY3g68uTA33N9PbfCr3+rAAa16D+458/uPGlcQUSL9b2niWUyZWBZEyOp 1Zfg== X-Gm-Message-State: AOAM533wfsV3MZvYISYytUzzAFC/tD8EZdbPkXcdNB/tLwnfRw+m7lyB ePeaPWf0Js3mQDxbkqqC5Tg8px1fwEH7chBSMaYrgkepr25PNfiHoRSyRR3FV9NFy7JrtmIE6Co na6u54gt3Q/pp8g== X-Received: by 2002:a05:600c:4b88:: with SMTP id e8mr669494wmp.74.1620249160168; Wed, 05 May 2021 14:12:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyM4vkT9fyrsRuOzWqlqhNnPCxLKxFJ+/jKPVgfZG1Gaf+tSButEFgSsc6olHkT1yfZy+fPmA== X-Received: by 2002:a05:600c:4b88:: with SMTP id e8mr669481wmp.74.1620249160047; Wed, 05 May 2021 14:12:40 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , qemu-ppc@nongnu.org, Gerd Hoffmann , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH 22/23] tests/unit/test-vmstate: Avoid dynamic stack allocation Date: Wed, 5 May 2021 23:10:46 +0200 Message-Id: <20210505211047.1496765-23-philmd@redhat.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210505211047.1496765-1-philmd@redhat.com> References: <20210505211047.1496765-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Use autofree heap allocation instead of variable-length array on the stack. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- 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 a001879585e..2d7ef42d73f 100644 --- a/tests/unit/test-vmstate.c +++ b/tests/unit/test-vmstate.c @@ -86,17 +86,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 =3D open_test_file(false); - uint8_t result[size]; + g_autofree uint8_t *result =3D g_malloc(size); =20 /* read back as binary */ =20 - g_assert_cmpint(qemu_get_buffer(f, result, sizeof(result)), =3D=3D, - sizeof(result)); + g_assert_cmpint(qemu_get_buffer(f, result, size), =3D=3D, size); g_assert(!qemu_file_get_error(f)); =20 /* 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)); =20 /* Must reach EOF */ qemu_get_byte(f); --=20 2.26.3