diff mbox

[v2,1/3] use consistent exit mechanism

Message ID 577A6ABC02000078000FAD04@prv-mh.provo.novell.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Beulich July 4, 2016, 11:55 a.m. UTC
Similar code should use similar exit mechanisms (return vs goto).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: Use "goto" instead of "return", making things consistent right away
    instead of only after a (series of) future patch(es) converting
    more code to "return".
x86emul: use consistent exit mechanism

Similar code should use similar exit mechanisms (return vs goto).

Signed-off-by: Jan Beulich <jbeulich@suse.com>
---
v2: Use "goto" instead of "return", making things consistent right away
    instead of only after a (series of) future patch(es) converting
    more code to "return".

--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -2106,7 +2106,7 @@ x86_emulate(
         generate_exception_if(mode_64bit() && !ext, EXC_UD, -1);
         fail_if(ops->read_segment == NULL);
         if ( (rc = ops->read_segment(src.val, &reg, ctxt)) != 0 )
-            return rc;
+            goto done;
         /* 64-bit mode: PUSH defaults to a 64-bit operand. */
         if ( mode_64bit() && (op_bytes == 4) )
             op_bytes = 8;
@@ -2125,10 +2125,9 @@ x86_emulate(
         if ( mode_64bit() && (op_bytes == 4) )
             op_bytes = 8;
         if ( (rc = read_ulong(x86_seg_ss, sp_post_inc(op_bytes),
-                              &dst.val, op_bytes, ctxt, ops)) != 0 )
+                              &dst.val, op_bytes, ctxt, ops)) != 0 ||
+             (rc = load_seg(src.val, dst.val, 0, NULL, ctxt, ops)) != 0 )
             goto done;
-        if ( (rc = load_seg(src.val, dst.val, 0, NULL, ctxt, ops)) != 0 )
-            return rc;
         break;
 
     case 0x0e: /* push %%cs */

Comments

Andrew Cooper July 4, 2016, 12:54 p.m. UTC | #1
On 04/07/16 12:55, Jan Beulich wrote:
> Similar code should use similar exit mechanisms (return vs goto).
>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
diff mbox

Patch

--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -2106,7 +2106,7 @@  x86_emulate(
         generate_exception_if(mode_64bit() && !ext, EXC_UD, -1);
         fail_if(ops->read_segment == NULL);
         if ( (rc = ops->read_segment(src.val, &reg, ctxt)) != 0 )
-            return rc;
+            goto done;
         /* 64-bit mode: PUSH defaults to a 64-bit operand. */
         if ( mode_64bit() && (op_bytes == 4) )
             op_bytes = 8;
@@ -2125,10 +2125,9 @@  x86_emulate(
         if ( mode_64bit() && (op_bytes == 4) )
             op_bytes = 8;
         if ( (rc = read_ulong(x86_seg_ss, sp_post_inc(op_bytes),
-                              &dst.val, op_bytes, ctxt, ops)) != 0 )
+                              &dst.val, op_bytes, ctxt, ops)) != 0 ||
+             (rc = load_seg(src.val, dst.val, 0, NULL, ctxt, ops)) != 0 )
             goto done;
-        if ( (rc = load_seg(src.val, dst.val, 0, NULL, ctxt, ops)) != 0 )
-            return rc;
         break;
 
     case 0x0e: /* push %%cs */