forked from Imagelibrary/binutils-gdb
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.
This commit is contained in:
@@ -632,10 +632,8 @@ hppa32_register_name (struct gdbarch *gdbarch, int i)
|
||||
"fr28", "fr28R", "fr29", "fr29R",
|
||||
"fr30", "fr30R", "fr31", "fr31R"
|
||||
};
|
||||
if (i < 0 || i >= (sizeof (names) / sizeof (*names)))
|
||||
return NULL;
|
||||
else
|
||||
return names[i];
|
||||
gdb_static_assert (ARRAY_SIZE (names) == hppa32_num_regs);
|
||||
return names[i];
|
||||
}
|
||||
|
||||
static const char *
|
||||
@@ -667,10 +665,8 @@ hppa64_register_name (struct gdbarch *gdbarch, int i)
|
||||
"fr24", "fr25", "fr26", "fr27",
|
||||
"fr28", "fr29", "fr30", "fr31"
|
||||
};
|
||||
if (i < 0 || i >= (sizeof (names) / sizeof (*names)))
|
||||
return NULL;
|
||||
else
|
||||
return names[i];
|
||||
gdb_static_assert (ARRAY_SIZE (names) == hppa64_num_regs);
|
||||
return names[i];
|
||||
}
|
||||
|
||||
/* Map dwarf DBX register numbers to GDB register numbers. */
|
||||
|
||||
Reference in New Issue
Block a user