amd64: remove additional comparison for validity of a register number.
authorWalfred Tedeschi <walfred.tedeschi@intel.com>
Fri, 27 Jan 2017 14:19:12 +0000 (15:19 +0100)
committerWalfred Tedeschi <walfred.tedeschi@intel.com>
Fri, 27 Jan 2017 14:20:12 +0000 (15:20 +0100)
Second part of the && is already guaranteed in the "regnum < num_regs"
due to comparison above.

2017-01-27  Walfred Tedeschi  <walfred.tedeschi@intel.com>

* amd64-nat.c (amd64_native_gregset_reg_offset): Simplify logic
that checks validity of a register number.

gdb/ChangeLog
gdb/amd64-nat.c

index c146e0b38d2f5a1ac82412b46aa495332e125983..401372c763194f53d9bcebfbe71123d95c5350b0 100644 (file)
@@ -1,3 +1,8 @@
+2017-01-27  Walfred Tedeschi  <walfred.tedeschi@intel.com>
+
+       * amd64-nat.c (amd64_native_gregset_reg_offset): Simplify logic
+       that checks validity of a register number.
+
 2017-01-27  Kees Cook  <keescook@google.com>
 
        * gdb/arm-linux-nat.c (arm_linux_fetch_inferior_registers): Call
index 18c8a99ae0ce9470520499bf54f81a98799fd7f8..680105b47c8e39e084248d93c8038faf808014fb 100644 (file)
@@ -65,10 +65,10 @@ amd64_native_gregset_reg_offset (struct gdbarch *gdbarch, int regnum)
   if (num_regs > gdbarch_num_regs (gdbarch))
     num_regs = gdbarch_num_regs (gdbarch);
 
-  if (regnum < num_regs && regnum < gdbarch_num_regs (gdbarch))
-    return reg_offset[regnum];
+  if (regnum >= num_regs)
+    return -1;
 
-  return -1;
+  return reg_offset[regnum];
 }
 
 /* Return whether the native general-purpose register set supplies