summaryrefslogtreecommitdiffstats
path: root/target-i386/helper.c
diff options
context:
space:
mode:
authorliguang2013-01-15 08:24:02 +0100
committerAndreas Färber2013-01-15 09:23:25 +0100
commit1cc21a180b9ea9204e99ad5c58604cb458e572a9 (patch)
tree397a4db4eb4905de4d7379c71b29b34f6190a3f1 /target-i386/helper.c
parenttarget-i386: Introduce hw_{local,global}_breakpoint_enabled() (diff)
downloadqemu-1cc21a180b9ea9204e99ad5c58604cb458e572a9.tar.gz
qemu-1cc21a180b9ea9204e99ad5c58604cb458e572a9.tar.xz
qemu-1cc21a180b9ea9204e99ad5c58604cb458e572a9.zip
target-i386: Avoid goto in hw_breakpoint_insert()
"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>
Diffstat (limited to 'target-i386/helper.c')
-rw-r--r--target-i386/helper.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/target-i386/helper.c b/target-i386/helper.c
index ebdd6a563a..a10b562bc9 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)