diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2024-04-17 16:55:28 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2024-04-18 10:31:54 -0400 |
commit | 523e454fab831e07c83a648c5d07370375a1c376 (patch) | |
tree | b8d5751d5d9215243ae787c6da707f246f0b65bb /gdbsupport/print-utils.cc | |
parent | 31d5afc19d98869aa13c3197f55b8a208fd19da2 (diff) | |
download | binutils-523e454fab831e07c83a648c5d07370375a1c376.zip binutils-523e454fab831e07c83a648c5d07370375a1c376.tar.gz binutils-523e454fab831e07c83a648c5d07370375a1c376.tar.bz2 |
gdbsupport: constify some return values in print-utils.{h,cc}
There is no reason the callers of these functions need to change the
returned string, so change the `char *` return types to `const char *`.
Update a few callers to also use `const char *`.
Change-Id: I94adff574d5e1b326e8cc688cf1817a15b408b96
Approved-By: Tom Tromey <tom@tromey.com>
Diffstat (limited to 'gdbsupport/print-utils.cc')
-rw-r--r-- | gdbsupport/print-utils.cc | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/gdbsupport/print-utils.cc b/gdbsupport/print-utils.cc index 565a479..a2e4357 100644 --- a/gdbsupport/print-utils.cc +++ b/gdbsupport/print-utils.cc @@ -122,7 +122,7 @@ octal2str (ULONGEST addr, int width) /* See print-utils.h. */ -char * +const char * pulongest (ULONGEST u) { return decimal2str ("", u, 0); @@ -130,7 +130,7 @@ pulongest (ULONGEST u) /* See print-utils.h. */ -char * +const char * plongest (LONGEST l) { if (l < 0) @@ -144,7 +144,7 @@ static int thirty_two = 32; /* See print-utils.h. */ -char * +const char * phex (ULONGEST l, int sizeof_l) { char *str; @@ -170,7 +170,7 @@ phex (ULONGEST l, int sizeof_l) xsnprintf (str, PRINT_CELL_SIZE, "%02x", (unsigned short) (l & 0xff)); break; default: - str = phex (l, sizeof (l)); + return phex (l, sizeof (l)); break; } @@ -179,7 +179,7 @@ phex (ULONGEST l, int sizeof_l) /* See print-utils.h. */ -char * +const char * phex_nz (ULONGEST l, int sizeof_l) { char *str; @@ -212,7 +212,7 @@ phex_nz (ULONGEST l, int sizeof_l) xsnprintf (str, PRINT_CELL_SIZE, "%x", (unsigned short) (l & 0xff)); break; default: - str = phex_nz (l, sizeof (l)); + return phex_nz (l, sizeof (l)); break; } @@ -221,7 +221,7 @@ phex_nz (ULONGEST l, int sizeof_l) /* See print-utils.h. */ -char * +const char * hex_string (LONGEST num) { char *result = get_print_cell (); @@ -232,7 +232,7 @@ hex_string (LONGEST num) /* See print-utils.h. */ -char * +const char * hex_string_custom (LONGEST num, int width) { char *result = get_print_cell (); @@ -254,7 +254,7 @@ hex_string_custom: insufficient space to store result")); /* See print-utils.h. */ -char * +const char * int_string (LONGEST val, int radix, int is_signed, int width, int use_c_format) { @@ -262,7 +262,7 @@ int_string (LONGEST val, int radix, int is_signed, int width, { case 16: { - char *result; + const char *result; if (width == 0) result = hex_string (val); |