qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] monitor: Fix warning from clang
@ 2012-08-17 13:34 Stefan Weil
  2012-08-17 13:58 ` Luiz Capitulino
  2012-08-17 14:10 ` Markus Armbruster
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Weil @ 2012-08-17 13:34 UTC (permalink / raw)
  To: qemu-trivial; +Cc: qemu-devel, Stefan Weil, Markus Armbruster, Luiz Capitulino

ccc-analyzer reports these warnings:

monitor.c:3532:21: warning: Division by zero
                val %= val2;
                    ^
monitor.c:3530:21: warning: Division by zero
                val /= val2;
                    ^

Rewriting the code fixes this (and also a style issue).

Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
 monitor.c |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/monitor.c b/monitor.c
index 0c34934..0ea2c14 100644
--- a/monitor.c
+++ b/monitor.c
@@ -3524,12 +3524,13 @@ static int64_t expr_prod(Monitor *mon)
             break;
         case '/':
         case '%':
-            if (val2 == 0)
+            if (val2 == 0) {
                 expr_error(mon, "division by zero");
-            if (op == '/')
+            } else if (op == '/') {
                 val /= val2;
-            else
+            } else {
                 val %= val2;
+            }
             break;
         }
     }
-- 
1.7.10

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

end of thread, other threads:[~2012-08-24 10:31 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-17 13:34 [Qemu-devel] [PATCH] monitor: Fix warning from clang Stefan Weil
2012-08-17 13:58 ` Luiz Capitulino
2012-08-17 14:10 ` Markus Armbruster
2012-08-17 14:21   ` Luiz Capitulino
2012-08-17 14:41     ` Markus Armbruster
2012-08-17 15:02       ` Luiz Capitulino
2012-08-18 11:49         ` Stefan Weil
2012-08-20  7:17           ` Markus Armbruster
2012-08-24 10:31             ` Stefan Hajnoczi

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