Patchwork [3/7] balloon: Simplify code flow

login
register
mail settings
Submitter Amit Shah
Date July 26, 2011, 9:08 a.m.
Message ID <f1ee0a0ebda763f39f8b8aa289fd771133c9971b.1311671109.git.amit.shah@redhat.com>
Download mbox | patch
Permalink /patch/106808/
State New
Headers show

Comments

Amit Shah - July 26, 2011, 9:08 a.m.
Replace:
  if (foo) {
    ...
  } else {
    return 0;
  }

by

  if (!foo) {
    return 0;
  }
  ...

Signed-off-by: Amit Shah <amit.shah@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
 balloon.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

Patch

diff --git a/balloon.c b/balloon.c
index 86f629e..d40be39 100644
--- a/balloon.c
+++ b/balloon.c
@@ -42,23 +42,21 @@  void qemu_add_balloon_handler(QEMUBalloonEvent *func, void *opaque)
 
 static int qemu_balloon(ram_addr_t target, MonitorCompletion cb, void *opaque)
 {
-    if (balloon_event_fn) {
-        trace_balloon_event(balloon_opaque, target);
-        balloon_event_fn(balloon_opaque, target, cb, opaque);
-        return 1;
-    } else {
+    if (!balloon_event_fn) {
         return 0;
     }
+    trace_balloon_event(balloon_opaque, target);
+    balloon_event_fn(balloon_opaque, target, cb, opaque);
+    return 1;
 }
 
 static int qemu_balloon_status(MonitorCompletion cb, void *opaque)
 {
-    if (balloon_event_fn) {
-        balloon_event_fn(balloon_opaque, 0, cb, opaque);
-        return 1;
-    } else {
+    if (!balloon_event_fn) {
         return 0;
     }
+    balloon_event_fn(balloon_opaque, 0, cb, opaque);
+    return 1;
 }
 
 static void print_balloon_stat(const char *key, QObject *obj, void *opaque)