Skip to contentSkip to conversation

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

PATCH In review Dongli Zhang 3 participants 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH v2 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 | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/misc/xen-livepatch.c +2 -3
index 28f339a..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 )
     {
@@ -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 5 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.

Your original patch has been committed. That's why Olaf is seeing compilation error. It is currently in staging branch. Osstest (the CI system) will test it (well, in fact there is not yet a test case). If the test succeeds, all the patches tested will be pushed to master branch.

To fix the breakage, please check out staging branch and write a patch to fix it. And maybe the commit message should say something like "initialise j to 0 to make some versions of gcc happy".

If you have further question, feel free to ask. :-)

Wei.

Quoted 30 lines
---
 tools/misc/xen-livepatch.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/misc/xen-livepatch.c +2 -3
index 28f339a..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 )
     {
@@ -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 · 1 line
1.9.1

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

#2 lore raw
Quoted 3 lines · Wei Liu

To fix the breakage, please check out staging branch and write a patch to fix it. And maybe the commit message should say something like "initialise j to 0 to make some versions of gcc happy".

Not "some", but rather "at least gcc4.5/4.3" or similar. There are already enough "some"s out there, where in the end noone knows what the given workaround is all about.

Olaf

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

#3 lore raw
Quoted 10 lines · Olaf Hering
Quoted 3 lines · Wei Liu

To fix the breakage, please check out staging branch and write a patch to fix it. And maybe the commit message should say something like "initialise j to 0 to make some versions of gcc happy".

Not "some", but rather "at least gcc4.5/4.3" or similar. There are already enough "some"s out there, where in the end noone knows what the given workaround is all about.

Fine by me of course. I didn't have a list of known offenders so I couldn't suggest concrete version numbers.

Wei.

Quoted 1 line

Olaf

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