Skip to contentSkip to conversation

migration/block-dirty-bitmap: fix uninitialized variable warning

PATCH In review Chen Qun 4 participants 6 messages Oct 14, 2020 – Oct 20, 2020

lore
Share & tools
lore

Chen Qun

author
#0 lore raw

PATCH v3 1/1 migration/block-dirty-bitmap: fix uninitialized variable warning

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));
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

---
v2->v3: Placing the declaration at the beginning of the block(Base on Max's suggestion).

Cc Max Reitz <[email protected]>
Cc Vladimir Sementsov-Ogievskiy <[email protected]>
Cc Laurent Vivier <[email protected]>
Cc Li Qiang <[email protected]>
---
 migration/block-dirty-bitmap.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)
migration/block-dirty-bitmap.c +9 -12
index 5bef793ac0..114987961a 100644
@@ -1071,18 +1071,15 @@ static int dirty_bitmap_load_header(QEMUFile *f, DBMLoadState *s,
             return -EINVAL;
         }
 
-        if (!s->cancelled) {
-            if (bitmap_alias_map) {
-                bitmap_name = g_hash_table_lookup(bitmap_alias_map,
-                                                  s->bitmap_alias);
-                if (!bitmap_name) {
-                    error_report("Error: Unknown bitmap alias '%s' on node "
-                                 "'%s' (alias '%s')", s->bitmap_alias,
-                                 s->bs->node_name, s->node_alias);
-                    cancel_incoming_locked(s);
-                }
-            } else {
-                bitmap_name = s->bitmap_alias;
+        bitmap_name = s->bitmap_alias;
+        if (!s->cancelled && bitmap_alias_map) {
+            bitmap_name = g_hash_table_lookup(bitmap_alias_map,
+                                              s->bitmap_alias);
+            if (!bitmap_name) {
+                error_report("Error: Unknown bitmap alias '%s' on node "
+                             "'%s' (alias '%s')", s->bitmap_alias,
+                             s->bs->node_name, s->node_alias);
+                cancel_incoming_locked(s);
             }
         }
 
Signature · 1 line
2.23.0
Reviewed-by on v3 1/1
#1 lore raw
Quoted 10 lines · Chen Qun

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));
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signature · 2 lines
Best regards,
Vladimir
#2 lore raw

Ping!

Hello,

Maybe this patch, some people have any other suggestions? Or, maybe missed to queue?

Thanks,
Chen Qun

Quoted 34 lines

-----Original Message-----
From: Vladimir Sementsov-Ogievskiy [mailto:[email protected]]
Sent: Wednesday, October 14, 2020 11:56 PM
To: Chenqun (kuhn) <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; ganqixin <[email protected]>; [email protected]; Euler Robot <[email protected]>; Laurent Vivier <[email protected]>; Li Qiang <[email protected]>
Subject: Re: [PATCH v3] migration/block-dirty-bitmap: fix uninitialized variable warning

Quoted 1 line · Chen Qun

A default value is provided for the variable 'bitmap_name' to avoid compiler

warning.

Quoted 5 lines

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));

Quoted 1 line

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Quoted 3 lines

--
Best regards,
Vladimir

#3 lore raw

Le 20/10/2020 à 09:36, Chenqun (kuhn) a écrit :

Quoted 5 lines

Ping!

Hello,

Maybe this patch, some people have any other suggestions? Or, maybe missed to queue?

Hi,

As we've seen by reviewing previous versions, this change is not really trivial, so I will not take it via the trivial queue.

Perhaps via block I/O queue (Stefan?), Dirty Bitmaps (John?) or Migration (Juan?).

Thanks,
Laurent

Quoted 37 lines

Thanks,
Chen Qun

Quoted 34 lines

-----Original Message-----
From: Vladimir Sementsov-Ogievskiy [mailto:[email protected]]
Sent: Wednesday, October 14, 2020 11:56 PM
To: Chenqun (kuhn) <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; ganqixin <[email protected]>; [email protected]; Euler Robot <[email protected]>; Laurent Vivier <[email protected]>; Li Qiang <[email protected]>
Subject: Re: [PATCH v3] migration/block-dirty-bitmap: fix uninitialized variable warning

Quoted 1 line · Chen Qun

A default value is provided for the variable 'bitmap_name' to avoid compiler

warning.

Quoted 5 lines

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));

Quoted 1 line

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Quoted 3 lines

--
Best regards,
Vladimir

#4 lore raw
Quoted 7 lines · Laurent Vivier

Le 20/10/2020 à 09:36, Chenqun (kuhn) a écrit :

Quoted 5 lines

Ping!

Hello,

Maybe this patch, some people have any other suggestions? Or, maybe missed to queue?

Quoted 8 lines

Hi,

As we've seen by reviewing previous versions, this change is not really trivial, so I will not take it via the trivial queue.

Perhaps via block I/O queue (Stefan?), Dirty Bitmaps (John?) or Migration (Juan?).

Correct would be Eric's bitmaps tree.

Quoted 39 lines
Quoted 38 lines

Thanks,
Chen Qun

Quoted 34 lines

-----Original Message-----
From: Vladimir Sementsov-Ogievskiy [mailto:[email protected]]
Sent: Wednesday, October 14, 2020 11:56 PM
To: Chenqun (kuhn) <[email protected]>; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Zhanghailiang <[email protected]>; ganqixin <[email protected]>; [email protected]; Euler Robot <[email protected]>; Laurent Vivier <[email protected]>; Li Qiang <[email protected]>
Subject: Re: [PATCH v3] migration/block-dirty-bitmap: fix uninitialized variable warning

Quoted 1 line · Chen Qun

A default value is provided for the variable 'bitmap_name' to avoid compiler

warning.

Quoted 5 lines

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));

Quoted 1 line

^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Quoted 3 lines

--
Best regards,
Vladimir

Signature · 2 lines
Best regards,
Vladimir
#5 lore raw
Quoted 11 lines · Vladimir Sementsov-Ogievskiy
Quoted 10 lines · Laurent Vivier

Le 20/10/2020 à 09:36, Chenqun (kuhn) a écrit :

Quoted 6 lines

Ping!

Hello,

   Maybe this patch, some people have any other suggestions?   Or, maybe missed to queue?

Hi,

Quoted 8 lines
Quoted 6 lines

As we've seen by reviewing previous versions, this change is not really trivial, so I will not take it via the trivial queue.

Perhaps via block I/O queue (Stefan?), Dirty Bitmaps (John?) or Migration (Juan?).

Correct would be Eric's bitmaps tree.

Yes, I'm planning on queuing this.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org