Patchwork [2/5] vl.c: consolidate qemu_xxx_requested() logic.

login
register
mail settings
Submitter Isaku Yamahata
Date Aug. 30, 2010, 7:49 a.m.
Message ID <dd764e79ff5e0be8d4eeacdab61df66e82e13b5a.1283152674.git.yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/63009/
State New
Headers show

Comments

Isaku Yamahata - Aug. 30, 2010, 7:49 a.m.
Don't repeat same logic in qemu_xxx_requested().

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 vl.c |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)

Patch

diff --git a/vl.c b/vl.c
index a77a171..aba3786 100644
--- a/vl.c
+++ b/vl.c
@@ -1129,39 +1129,36 @@  static int powerdown_requested;
 int debug_requested;
 int vmstop_requested;
 
-static int qemu_shutdown_requested(void)
+static int qemu_requested(int *requested)
 {
-    int r = shutdown_requested;
-    shutdown_requested = 0;
+    int r = *requested;
+    *requested = 0;
     return r;
 }
 
+static int qemu_shutdown_requested(void)
+{
+    return qemu_requested(&shutdown_requested);
+}
+
 static int qemu_reset_requested(void)
 {
-    int r = reset_requested;
-    reset_requested = 0;
-    return r;
+    return qemu_requested(&reset_requested);
 }
 
 static int qemu_powerdown_requested(void)
 {
-    int r = powerdown_requested;
-    powerdown_requested = 0;
-    return r;
+    return qemu_requested(&powerdown_requested);
 }
 
 static int qemu_debug_requested(void)
 {
-    int r = debug_requested;
-    debug_requested = 0;
-    return r;
+    return qemu_requested(&debug_requested);
 }
 
 static int qemu_vmstop_requested(void)
 {
-    int r = vmstop_requested;
-    vmstop_requested = 0;
-    return r;
+    return qemu_requested(&vmstop_requested);
 }
 
 void qemu_register_reset(QEMUResetHandler *func, void *opaque)