qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Max Reitz <mreitz@redhat.com>
To: Chen Qun <kuhn.chenqun@huawei.com>,
	qemu-devel@nongnu.org, qemu-trivial@nongnu.org
Cc: fam@euphon.net, ganqixin@huawei.com, vsementsov@virtuozzo.com,
	zhang.zhanghailiang@huawei.com, qemu-block@nongnu.org,
	quintela@redhat.com, Li Qiang <liq3ea@gmail.com>,
	dgilbert@redhat.com, Laurent Vivier <laurent@vivier.eu>,
	stefanha@redhat.com, Euler Robot <euler.robot@huawei.com>,
	jsnow@redhat.com
Subject: Re: [PATCH v2] migration/block-dirty-bitmap: fix uninitialized variable warning
Date: Tue, 13 Oct 2020 16:47:15 +0200	[thread overview]
Message-ID: <561a0092-3723-a95a-0208-d53cb475a532@redhat.com> (raw)
In-Reply-To: <20201013123340.1850548-1-kuhn.chenqun@huawei.com>


[-- Attachment #1.1: Type: text/plain, Size: 2514 bytes --]

On 13.10.20 14:33, Chen Qun wrote:
> A default value is provided for the variable 'bitmap_name' to avoid compiler warning.
> 
> The compiler show warning:
> migration/block-dirty-bitmap.c:1090:13: warning: ‘bitmap_name’
> may be used uninitialized in this function [-Wmaybe-uninitialized]
>        g_strlcpy(s->bitmap_name, bitmap_name, sizeof(s->bitmap_name));
>        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
> Cc: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> Cc: Laurent Vivier <laurent@vivier.eu>
> Cc: Li Qiang <liq3ea@gmail.com>
> ---
>  migration/block-dirty-bitmap.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)

No objections, semantically, but...

> diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c
> index 5bef793ac0..bcb79c04ce 100644
> --- a/migration/block-dirty-bitmap.c
> +++ b/migration/block-dirty-bitmap.c
> @@ -1064,15 +1064,13 @@ static int dirty_bitmap_load_header(QEMUFile *f, DBMLoadState *s,
>      assert(nothing || s->cancelled || !!alias_map == !!bitmap_alias_map);
>  
>      if (s->flags & DIRTY_BITMAP_MIG_FLAG_BITMAP_NAME) {
> -        const char *bitmap_name;
> -
>          if (!qemu_get_counted_string(f, s->bitmap_alias)) {
>              error_report("Unable to read bitmap alias string");
>              return -EINVAL;
>          }
>  
> -        if (!s->cancelled) {
> -            if (bitmap_alias_map) {
> +        const char *bitmap_name = s->bitmap_alias;

qemu’s coding style mandates declarations to be placed at the beginning
of their block, so the declaration has to stay where it is.  (Putting
the assignment here looks reasonable.)

> +        if (!s->cancelled && bitmap_alias_map) {
>                  bitmap_name = g_hash_table_lookup(bitmap_alias_map,
>                                                    s->bitmap_alias);

This block of course needs to be re-indented.

Max

>                  if (!bitmap_name) {
> @@ -1081,9 +1079,6 @@ static int dirty_bitmap_load_header(QEMUFile *f, DBMLoadState *s,
>                                   s->bs->node_name, s->node_alias);
>                      cancel_incoming_locked(s);
>                  }
> -            } else {
> -                bitmap_name = s->bitmap_alias;
> -            }
>          }
>  
>          if (!s->cancelled) {
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2020-10-13 14:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-13 12:33 [PATCH v2] migration/block-dirty-bitmap: fix uninitialized variable warning Chen Qun
2020-10-13 14:47 ` Max Reitz [this message]
2020-10-14  1:03   ` Chenqun (kuhn)
2020-10-14  9:35     ` Max Reitz
2020-10-14 11:21       ` Chenqun (kuhn)

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=561a0092-3723-a95a-0208-d53cb475a532@redhat.com \
    --to=mreitz@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=euler.robot@huawei.com \
    --cc=fam@euphon.net \
    --cc=ganqixin@huawei.com \
    --cc=jsnow@redhat.com \
    --cc=kuhn.chenqun@huawei.com \
    --cc=laurent@vivier.eu \
    --cc=liq3ea@gmail.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=quintela@redhat.com \
    --cc=stefanha@redhat.com \
    --cc=vsementsov@virtuozzo.com \
    --cc=zhang.zhanghailiang@huawei.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).