[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 19/20] target-i386: Avoid goto in hw_breakpoint_inse
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH 19/20] target-i386: Avoid goto in hw_breakpoint_insert() |
Date: |
Tue, 15 Jan 2013 10:27:37 +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
- [Qemu-devel] [PATCH 09/20] target-i386: Disable kvm_mmu by default, (continued)
- [Qemu-devel] [PATCH 09/20] target-i386: Disable kvm_mmu by default, Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH 04/20] cpu: Move cpu_index field to CPUState, Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH 10/20] target-i386/cpu: Introduce FeatureWord typedefs, Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH 12/20] target-i386/cpu.c: Add feature name array for ext4_features, Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH 14/20] target-i386: Move setting defaults out of cpu_x86_parse_featurestr(), Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH 18/20] target-i386: Introduce hw_{local, global}_breakpoint_enabled(), Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH 17/20] target-i386: Define DR7 bit field constants, Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH 16/20] target-i386: Move kvm_check_features_against_host() check to realize time, Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH 15/20] target-i386: cpu_x86_register() consolidate freeing resources, Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH 20/20] target-i386: Use switch in check_hw_breakpoints(), Andreas Färber, 2013/01/15
- [Qemu-devel] [PATCH 19/20] target-i386: Avoid goto in hw_breakpoint_insert(),
Andreas Färber <=
- Re: [Qemu-devel] [PULL] QOM CPUState patch queue 2013-01-15, Anthony Liguori, 2013/01/15