diff options
author | Walfred Tedeschi <walfred.tedeschi@intel.com> | 2017-01-27 15:19:12 +0100 |
---|---|---|
committer | Walfred Tedeschi <walfred.tedeschi@intel.com> | 2017-01-27 15:20:12 +0100 |
commit | 7005d26ac72abbf12e02947ab87dbb3804f326a8 (patch) | |
tree | 8ff4f102d8056f1f2403ff47915c589177d94d9b | |
parent | 239b6d10954b18ce089e9c3a667e7f2df3655476 (diff) | |
download | binutils-gdb-7005d26ac72abbf12e02947ab87dbb3804f326a8.tar.gz |
amd64: remove additional comparison for validity of a register number.
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.
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/amd64-nat.c | 6 |
2 files changed, 8 insertions, 3 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index c146e0b38d2..401372c7631 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -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 diff --git a/gdb/amd64-nat.c b/gdb/amd64-nat.c index 18c8a99ae0c..680105b47c8 100644 --- a/gdb/amd64-nat.c +++ b/gdb/amd64-nat.c @@ -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 |