Skip to contentSkip to conversation

tools/livepatch: cleanup unnecessary "j = ARRAY_SIZE(action_options); "

PATCH Superseded Dongli Zhang 4 participants 4 messages Jun 9, 2016 – Jun 14, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/livepatch: cleanup unnecessary "j = ARRAY_SIZE(action_options); "

Local variable "j" would be used only when "i == ARRAY_SIZE(main_options)" is true. Thus, it is not necessary to update "j" when "i == ARRAY_SIZE(main_options)" is false.

---
 tools/misc/xen-livepatch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
tools/misc/xen-livepatch.c +1 -2
index 28f339a..3162489 100644
@@ -435,8 +435,7 @@ int main(int argc, char *argv[])
                    "'xen-livepatch help'\n", argv[1]);
             return 1;
         }
-    } else
-        j = ARRAY_SIZE(action_options);
+    }
 
     xch = xc_interface_open(0,0,0);
     if ( !xch )
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw
Quoted 6 lines · Dongli Zhang

Local variable "j" would be used only when "i == ARRAY_SIZE(main_options)" is true. Thus, it is not necessary to update "j" when "i == ARRAY_SIZE(main_options)" is false.

Thanks, I've queued this up in my next batch.

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#2 lore raw
In reply to Dongli Zhang
Quoted 3 lines · Dongli Zhang

Local variable "j" would be used only when "i == ARRAY_SIZE(main_options)" is true. Thus, it is not necessary to update "j" when "i == ARRAY_SIZE(main_options)" is false.

This breaks the build with gcc45:

[  153s] cc1: warnings being treated as errors
[  153s] xen-livepatch.c: In function 'main':
[  153s] xen-livepatch.c:415:12: error: 'j' may be used uninitialized in this function
[  153s] make[3]: *** [xen-livepatch.o] Error 1

Olaf

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel

#3 lore raw
Quoted 6 lines · Olaf Hering
Quoted 3 lines · Dongli Zhang

Local variable "j" would be used only when "i == ARRAY_SIZE(main_options)" is true. Thus, it is not necessary to update "j" when "i == ARRAY_SIZE(main_options)" is false.

Quoted 8 lines

This breaks the build with gcc45:

[  153s] cc1: warnings being treated as errors
[  153s] xen-livepatch.c: In function 'main':
[  153s] xen-livepatch.c:415:12: error: 'j' may be used uninitialized in this function
[  153s] make[3]: *** [xen-livepatch.o] Error 1

Olaf

?

tools/misc/xen-livepatch.c +1 -1
index 3162489..62c072e 100644
@@ -412,7 +412,7 @@ struct {
 
 int main(int argc, char *argv[])
 {
-    int i, j, ret;
+    int i, j = 0, ret;
 
     if ( argc  <= 1 )
     {

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel