This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
pushed [PATCH] amd64: remove additional comparison for validity of a register number.
- From: "Tedeschi, Walfred" <walfred dot tedeschi at intel dot com>
- To: palves at redhat dot com, qiyaoltc at gmail dot com, brobecker at adacore dot com
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 30 Jan 2017 07:49:24 +0000
- Subject: pushed [PATCH] amd64: remove additional comparison for validity of a register number.
- Authentication-results: sourceware.org; auth=none
- References: <1485339204-7045-1-git-send-email-walfred.tedeschi@intel.com>
Am 1/25/2017 um 10:13 AM schrieb Walfred Tedeschi:
Second part of the && is already guaranteed in the "regnum < num_regs"
due to comparison above.
2017-01-24 Walfred Tedeschi <walfred.tedeschi@intel.com>
* amd64-nat.c (amd64_native_gregset_reg_offset): Simplify logic
that checks validity of a register number.
---
gdb/amd64-nat.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/gdb/amd64-nat.c b/gdb/amd64-nat.c
index 18c8a99..680105b 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
Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928