xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] tools/livepatch: cleanup unnecessary "j = ARRAY_SIZE(action_options); "
@ 2016-06-09 16:02 Dongli Zhang
  2016-06-09 16:29 ` Wei Liu
  2016-06-14 19:22 ` Olaf Hering
  0 siblings, 2 replies; 4+ messages in thread
From: Dongli Zhang @ 2016-06-09 16:02 UTC (permalink / raw)
  To: xen-devel, konrad.wilk, ross.lagerwall, ian.jackson, wei.liu2

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.

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 tools/misc/xen-livepatch.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/misc/xen-livepatch.c b/tools/misc/xen-livepatch.c
index 28f339a..3162489 100644
--- a/tools/misc/xen-livepatch.c
+++ b/tools/misc/xen-livepatch.c
@@ -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 )
-- 
1.9.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] tools/livepatch: cleanup unnecessary "j = ARRAY_SIZE(action_options); "
  2016-06-09 16:02 [PATCH 1/1] tools/livepatch: cleanup unnecessary "j = ARRAY_SIZE(action_options); " Dongli Zhang
@ 2016-06-09 16:29 ` Wei Liu
  2016-06-14 19:22 ` Olaf Hering
  1 sibling, 0 replies; 4+ messages in thread
From: Wei Liu @ 2016-06-09 16:29 UTC (permalink / raw)
  To: Dongli Zhang; +Cc: ross.lagerwall, ian.jackson, wei.liu2, xen-devel

On Fri, Jun 10, 2016 at 12:02:52AM +0800, Dongli Zhang wrote:
> 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.
> 
> Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>

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

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] tools/livepatch: cleanup unnecessary "j = ARRAY_SIZE(action_options); "
  2016-06-09 16:02 [PATCH 1/1] tools/livepatch: cleanup unnecessary "j = ARRAY_SIZE(action_options); " Dongli Zhang
  2016-06-09 16:29 ` Wei Liu
@ 2016-06-14 19:22 ` Olaf Hering
  2016-06-14 20:07   ` Konrad Rzeszutek Wilk
  1 sibling, 1 reply; 4+ messages in thread
From: Olaf Hering @ 2016-06-14 19:22 UTC (permalink / raw)
  To: Dongli Zhang; +Cc: ross.lagerwall, ian.jackson, wei.liu2, xen-devel

On Fri, Jun 10, Dongli Zhang wrote:

> 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
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] tools/livepatch: cleanup unnecessary "j = ARRAY_SIZE(action_options); "
  2016-06-14 19:22 ` Olaf Hering
@ 2016-06-14 20:07   ` Konrad Rzeszutek Wilk
  0 siblings, 0 replies; 4+ messages in thread
From: Konrad Rzeszutek Wilk @ 2016-06-14 20:07 UTC (permalink / raw)
  To: Olaf Hering
  Cc: Dongli Zhang, ross.lagerwall, ian.jackson, wei.liu2, xen-devel

On Tue, Jun 14, 2016 at 09:22:45PM +0200, Olaf Hering wrote:
> On Fri, Jun 10, Dongli Zhang wrote:
> 
> > 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

?

diff --git a/tools/misc/xen-livepatch.c b/tools/misc/xen-livepatch.c
index 3162489..62c072e 100644
--- a/tools/misc/xen-livepatch.c
+++ b/tools/misc/xen-livepatch.c
@@ -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
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-14 20:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-09 16:02 [PATCH 1/1] tools/livepatch: cleanup unnecessary "j = ARRAY_SIZE(action_options); " Dongli Zhang
2016-06-09 16:29 ` Wei Liu
2016-06-14 19:22 ` Olaf Hering
2016-06-14 20:07   ` Konrad Rzeszutek Wilk

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