Received: from eggs.gnu.org ([208.118.235.92]:43754) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv1uW-00034n-Ne for qemu-devel@nongnu.org; Tue, 15 Jan 2013 03:30:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tv1uT-00016d-5s for qemu-devel@nongnu.org; Tue, 15 Jan 2013 03:30:20 -0500 Received: from cantor2.suse.de ([195.135.220.15]:38334 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tv1uS-00016Q-TA for qemu-devel@nongnu.org; Tue, 15 Jan 2013 03:30:17 -0500 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= Date: Tue, 15 Jan 2013 09:29:57 +0100 Message-Id: <1358238598-31451-4-git-send-email-afaerber@suse.de> In-Reply-To: <1358238598-31451-1-git-send-email-afaerber@suse.de> References: <1358238598-31451-1-git-send-email-afaerber@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH qom-cpu v6 3/4] target-i386: Avoid goto in hw_breakpoint_insert() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , lig.fnst@cn.fujitsu.com From: liguang "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 Signed-off-by: Andreas F=C3=A4rber --- target-i386/helper.c | 16 ++++++++++------ 1 Datei ge=C3=A4ndert, 10 Zeilen hinzugef=C3=BCgt(+), 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, targ= et_ulong addr) =20 void hw_breakpoint_insert(CPUX86State *env, int index) { - int type, err =3D 0; + int type =3D 0, err =3D 0; =20 switch (hw_breakpoint_type(env->dr[7], index)) { case DR7_TYPE_BP_INST: @@ -977,20 +977,24 @@ void hw_breakpoint_insert(CPUX86State *env, int ind= ex) break; case DR7_TYPE_DATA_WR: type =3D 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 =3D BP_CPU | BP_MEM_ACCESS; - insert_wp: + break; + } + + if (type !=3D 0) { err =3D 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] =3D NULL; + } } =20 void hw_breakpoint_remove(CPUX86State *env, int index) --=20 1.7.10.4