qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Andreas Färber" <afaerber@suse.de>, lig.fnst@cn.fujitsu.com
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	[thread overview]
Message-ID: <1358238598-31451-4-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1358238598-31451-1-git-send-email-afaerber@suse.de>

From: liguang <lig.fnst@cn.fujitsu.com>

  "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 <lig.fnst@cn.fujitsu.com>
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
 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

  parent reply	other threads:[~2013-01-15  8:30 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-15  8:29 [Qemu-devel] [PATCH qom-cpu v6 0/4] target-i386: Clean up DR7 breakpoint handling Andreas Färber
2013-01-15  8:29 ` [Qemu-devel] [PATCH qom-cpu v6 1/4] target-i386: Define DR7 bit field constants Andreas Färber
2013-01-15  8:29 ` [Qemu-devel] [PATCH qom-cpu v6 2/4] target-i386: Introduce hw_{local, global}_breakpoint_enabled() Andreas Färber
2013-01-15  8:29 ` Andreas Färber [this message]
2013-01-15  8:29 ` [Qemu-devel] [PATCH qom-cpu v6 4/4] target-i386: Use switch in check_hw_breakpoints() Andreas Färber
2013-01-15  8:49 ` [Qemu-devel] [PATCH qom-cpu v6 0/4] target-i386: Clean up DR7 breakpoint handling li guang
2013-01-15  9:18   ` Andreas Färber

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1358238598-31451-4-git-send-email-afaerber@suse.de \
    --to=afaerber@suse.de \
    --cc=lig.fnst@cn.fujitsu.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).