qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
To: Wainer dos Santos Moschetta <wainersm@redhat.com>
Cc: qemu-devel@nongnu.org, quintela@redhat.com
Subject: Re: [PATCH] migration/qemu-file: Fix maybe uninitialized on qemu_get_buffer_in_place()
Date: Thu, 28 Jan 2021 17:16:19 +0000	[thread overview]
Message-ID: <20210128171619.GF2951@work-vm> (raw)
In-Reply-To: <20210128130625.569900-1-wainersm@redhat.com>

* Wainer dos Santos Moschetta (wainersm@redhat.com) wrote:
> Fixed error when compiling migration/qemu-file.c with -Werror=maybe-uninitialized
> as shown here:
> 
> ../migration/qemu-file.c: In function 'qemu_get_buffer_in_place':
> ../migration/qemu-file.c:604:18: error: 'src' may be used uninitialized in this function [-Werror=maybe-uninitialized]
>   604 |             *buf = src;
>       |             ~~~~~^~~~~
> cc1: all warnings being treated as errors
> 
> Signed-off-by: Wainer dos Santos Moschetta <wainersm@redhat.com>

Yes, I think I had a discussion with someone about this recently but
can't find it; the compiler is technically correct, but the only time
it's unitialised is the case where it's result doesn't matter.

Still, to shut the compiler up:


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
> Passed on CI: https://gitlab.com/wainersm/qemu/-/pipelines/247801576
> 
>  migration/qemu-file.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/migration/qemu-file.c b/migration/qemu-file.c
> index be21518c57..d6e03dbc0e 100644
> --- a/migration/qemu-file.c
> +++ b/migration/qemu-file.c
> @@ -595,7 +595,7 @@ size_t qemu_get_buffer_in_place(QEMUFile *f, uint8_t **buf, size_t size)
>  {
>      if (size < IO_BUF_SIZE) {
>          size_t res;
> -        uint8_t *src;
> +        uint8_t *src = NULL;
>  
>          res = qemu_peek_buffer(f, &src, size, 0);
>  
> -- 
> 2.28.0
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



  reply	other threads:[~2021-01-28 17:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-28 13:06 [PATCH] migration/qemu-file: Fix maybe uninitialized on qemu_get_buffer_in_place() Wainer dos Santos Moschetta
2021-01-28 17:16 ` Dr. David Alan Gilbert [this message]
2021-01-28 18:07   ` Philippe Mathieu-Daudé
2021-01-28 18:18     ` Wainer dos Santos Moschetta
2021-01-28 18:36     ` Dr. David Alan Gilbert
2021-02-04 14:33   ` Dr. David Alan Gilbert

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=20210128171619.GF2951@work-vm \
    --to=dgilbert@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=wainersm@redhat.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).