qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH qom-cpu v6 3/4] target-i386: Avoid goto in hw_breakp


From: Andreas Färber
Subject: [Qemu-devel] [PATCH qom-cpu v6 3/4] target-i386: Avoid goto in hw_breakpoint_insert()
Date: Tue, 15 Jan 2013 09:29:57 +0100

From: liguang <address@hidden>

  "Go To Statement Considered Harmful" -- E. Dijkstra

To avoid an unnecessary goto within the switch statement, move
watchpoint insertion out of the switch statement. Improves readability.

While at it, fix Coding Style issues (missing braces, indentation).

Signed-off-by: liguang <address@hidden>
Signed-off-by: Andreas Färber <address@hidden>
---
 target-i386/helper.c |   16 ++++++++++------
 1 Datei geändert, 10 Zeilen hinzugefügt(+), 6 Zeilen entfernt(-)

diff --git a/target-i386/helper.c b/target-i386/helper.c
index ebdd6a5..a10b562 100644
--- a/target-i386/helper.c
+++ b/target-i386/helper.c
@@ -966,7 +966,7 @@ hwaddr cpu_get_phys_page_debug(CPUX86State *env, 
target_ulong addr)
 
 void hw_breakpoint_insert(CPUX86State *env, int index)
 {
-    int type, err = 0;
+    int type = 0, err = 0;
 
     switch (hw_breakpoint_type(env->dr[7], index)) {
     case DR7_TYPE_BP_INST:
@@ -977,20 +977,24 @@ void hw_breakpoint_insert(CPUX86State *env, int index)
         break;
     case DR7_TYPE_DATA_WR:
         type = BP_CPU | BP_MEM_WRITE;
-        goto insert_wp;
+        break;
     case DR7_TYPE_IO_RW:
-         /* No support for I/O watchpoints yet */
+        /* No support for I/O watchpoints yet */
         break;
     case DR7_TYPE_DATA_RW:
         type = BP_CPU | BP_MEM_ACCESS;
-    insert_wp:
+        break;
+    }
+
+    if (type != 0) {
         err = cpu_watchpoint_insert(env, env->dr[index],
                                     hw_breakpoint_len(env->dr[7], index),
                                     type, &env->cpu_watchpoint[index]);
-        break;
     }
-    if (err)
+
+    if (err) {
         env->cpu_breakpoint[index] = NULL;
+    }
 }
 
 void hw_breakpoint_remove(CPUX86State *env, int index)
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]