diff options
author | Andrew Burgess <aburgess@redhat.com> | 2022-08-31 13:32:59 +0100 |
---|---|---|
committer | Andrew Burgess <aburgess@redhat.com> | 2022-10-02 14:21:25 +0100 |
commit | 9b9e61c7cf49abdf9c2703c4d1f555d762c6e49f (patch) | |
tree | 72ea91b5f98c1da25d5fde14425980aebd71a1b4 /gdb/sparc64-tdep.c | |
parent | 7ac20d65a8d0c9cdb329d49e8d9e58e38c39fec4 (diff) | |
download | gdb-9b9e61c7cf49abdf9c2703c4d1f555d762c6e49f.zip gdb-9b9e61c7cf49abdf9c2703c4d1f555d762c6e49f.tar.gz gdb-9b9e61c7cf49abdf9c2703c4d1f555d762c6e49f.tar.bz2 |
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.
Diffstat (limited to 'gdb/sparc64-tdep.c')
-rw-r--r-- | gdb/sparc64-tdep.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 5e69657..6b9d9ea 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -810,12 +810,8 @@ sparc64_pseudo_register_name (struct gdbarch *gdbarch, int regnum) { regnum -= gdbarch_num_regs (gdbarch); - if (regnum < SPARC64_NUM_PSEUDO_REGS) - return sparc64_pseudo_register_names[regnum]; - - internal_error (__FILE__, __LINE__, - _("sparc64_pseudo_register_name: bad register number %d"), - regnum); + gdb_assert (regnum < SPARC64_NUM_PSEUDO_REGS); + return sparc64_pseudo_register_names[regnum]; } /* Return the name of register REGNUM. */ |