This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

pushed [PATCH] amd64: remove additional comparison for validity of a register number.

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		<>

	* 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,
Managing Directors: Christin Eisenschmid, Christian Lamprechter
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]