From 9b9e61c7cf49abdf9c2703c4d1f555d762c6e49f Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Wed, 31 Aug 2022 13:32:59 +0100 Subject: gdb: final cleanup of various gdbarch_register_name methods Building on the previous commits, this commit goes through the various gdbarch_register_name methods and removes all the remaining 'return NULL' cases, I claim that these either couldn't be hit, or should be returning the empty string. In all cases the return of NULL was used if the register number being passed to gdbarch_register_name was "invalid", i.e. negative, or greater than the total number of declared registers. I don't believe either of these cases can occur, and the previous commit asserts that this is the case. As a result we can simplify the code by removing these checks. In many cases, where the register names are held in an array, I was able to add a static assert that the array contains the correct number of strings, after that, a direct access into the array is fine. I don't have any means of testing these changes. --- gdb/msp430-tdep.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gdb/msp430-tdep.c') diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c index 2abc7cf..6c729af 100644 --- a/gdb/msp430-tdep.c +++ b/gdb/msp430-tdep.c @@ -196,6 +196,8 @@ msp430_register_name (struct gdbarch *gdbarch, int regnr) "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15" }; + gdb_static_assert (ARRAY_SIZE (reg_names) == (MSP430_NUM_REGS + + MSP430_NUM_PSEUDO_REGS)); return reg_names[regnr]; } -- cgit v1.1