gdb: final cleanup of various gdbarch_register_name methods
authorAndrew Burgess <aburgess@redhat.com>
Wed, 31 Aug 2022 12:32:59 +0000 (13:32 +0100)
committerAndrew Burgess <aburgess@redhat.com>
Sun, 2 Oct 2022 13:21:25 +0000 (14:21 +0100)
commit9b9e61c7cf49abdf9c2703c4d1f555d762c6e49f
tree72ea91b5f98c1da25d5fde14425980aebd71a1b4
parent7ac20d65a8d0c9cdb329d49e8d9e58e38c39fec4
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.
29 files changed:
gdb/alpha-tdep.c
gdb/avr-tdep.c
gdb/bpf-tdep.c
gdb/cris-tdep.c
gdb/frv-tdep.c
gdb/ft32-tdep.c
gdb/h8300-tdep.c
gdb/hppa-tdep.c
gdb/iq2000-tdep.c
gdb/lm32-tdep.c
gdb/m32r-tdep.c
gdb/m68hc11-tdep.c
gdb/m68k-tdep.c
gdb/microblaze-tdep.c
gdb/mn10300-tdep.c
gdb/moxie-tdep.c
gdb/msp430-tdep.c
gdb/nds32-tdep.c
gdb/nios2-tdep.c
gdb/sh-tdep.c
gdb/sparc-tdep.c
gdb/sparc64-tdep.c
gdb/tic6x-tdep.c
gdb/tilegx-tdep.c
gdb/v850-tdep.c
gdb/vax-tdep.c
gdb/xstormy16-tdep.c
gdb/xtensa-tdep.c
gdb/z80-tdep.c