From: Paolo Bonzini <pbonzini@redhat.com>
To: Emanuele Giuseppe Esposito <eesposit@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Alberto Garcia <berto@igalia.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
Max Reitz <mreitz@redhat.com>
Subject: Re: [PATCH] tests/unit/test-block-iothread: fix maybe-uninitialized error on GCC 11
Date: Fri, 19 Mar 2021 12:28:26 +0100 [thread overview]
Message-ID: <43389c06-36d8-b754-8265-d776aaae749b@redhat.com> (raw)
In-Reply-To: <20210319112218.49609-1-eesposit@redhat.com>
On 19/03/21 12:22, Emanuele Giuseppe Esposito wrote:
> When building qemu with GCC 11, test-block-iothread produces the following
> warning:
>
> ../tests/unit/test-block-iothread.c:148:11: error: ‘buf’ may be used
> uninitialized [-Werror=maybe-uninitialized]
>
> This is caused by buf[512] left uninitialized and passed to
> bdrv_save_vmstate() that expects a const uint8_t *, so the compiler
> assumes it will be read and expects the parameter to be initialized.
>
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
> tests/unit/test-block-iothread.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c
> index 3f866a35c6..8cf172cb7a 100644
> --- a/tests/unit/test-block-iothread.c
> +++ b/tests/unit/test-block-iothread.c
> @@ -89,7 +89,7 @@ static void test_sync_op_pread(BdrvChild *c)
>
> static void test_sync_op_pwrite(BdrvChild *c)
> {
> - uint8_t buf[512];
> + uint8_t buf[512] = { 0 };
> int ret;
>
> /* Success */
> @@ -117,7 +117,7 @@ static void test_sync_op_blk_pread(BlockBackend *blk)
>
> static void test_sync_op_blk_pwrite(BlockBackend *blk)
> {
> - uint8_t buf[512];
> + uint8_t buf[512] = { 0 };
> int ret;
>
> /* Success */
> @@ -141,7 +141,7 @@ static void test_sync_op_load_vmstate(BdrvChild *c)
>
> static void test_sync_op_save_vmstate(BdrvChild *c)
> {
> - uint8_t buf[512];
> + uint8_t buf[512] = { 0 };
> int ret;
>
> /* Error: Driver does not support snapshots */
>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
next prev parent reply other threads:[~2021-03-19 11:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-19 11:22 [PATCH] tests/unit/test-block-iothread: fix maybe-uninitialized error on GCC 11 Emanuele Giuseppe Esposito
2021-03-19 11:28 ` Paolo Bonzini [this message]
2021-03-21 12:53 ` Alberto Garcia
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=43389c06-36d8-b754-8265-d776aaae749b@redhat.com \
--to=pbonzini@redhat.com \
--cc=berto@igalia.com \
--cc=eesposit@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).