diff options
author | Tom Tromey <tromey@adacore.com> | 2020-09-15 08:38:22 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-09-15 08:38:22 -0600 |
commit | db92ac4568f1d4cc1a3409098d033afbe8b555f5 (patch) | |
tree | 9acf4726c5541a4702d58f6af0da8c747e403c8d /gdb | |
parent | 7e30b1ebbf2fcf5e6bcfc3a7791d9a52614dcc43 (diff) | |
download | gdb-db92ac4568f1d4cc1a3409098d033afbe8b555f5.zip gdb-db92ac4568f1d4cc1a3409098d033afbe8b555f5.tar.gz gdb-db92ac4568f1d4cc1a3409098d033afbe8b555f5.tar.bz2 |
Use arrays rather than pointers for global string constants
My understanding is that it's mildly better to use a static const
array, as opposed to a "const char *", for a global string constant,
when possible. This makes sense to me because the pointer requires a
load from an address, whereas the array is just the address.
So, I searched for these in gdb and gdbserver. This patch fixes the
ones I found.
gdb/ChangeLog
2020-09-15 Tom Tromey <tromey@adacore.com>
* unittests/memory-map-selftests.c (valid_mem_map): Now array.
* ui-style.c (ansi_regex_text): Now array.
* rust-exp.y (number_regex_text): Now array.
* linespec.c (linespec_quote_characters): Now array.
* jit.c (jit_break_name, jit_descriptor_name, reader_init_fn_sym):
Now arrays.
gdbserver/ChangeLog
2020-09-15 Tom Tromey <tromey@adacore.com>
* linux-x86-low.cc (xmltarget_i386_linux_no_xml)
(xmltarget_amd64_linux_no_xml): Now arrays.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 9 | ||||
-rw-r--r-- | gdb/jit.c | 6 | ||||
-rw-r--r-- | gdb/linespec.c | 2 | ||||
-rw-r--r-- | gdb/rust-exp.y | 2 | ||||
-rw-r--r-- | gdb/ui-style.c | 2 | ||||
-rw-r--r-- | gdb/unittests/memory-map-selftests.c | 2 |
6 files changed, 16 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7ed944a..fe19f19 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,12 @@ +2020-09-15 Tom Tromey <tromey@adacore.com> + + * unittests/memory-map-selftests.c (valid_mem_map): Now array. + * ui-style.c (ansi_regex_text): Now array. + * rust-exp.y (number_regex_text): Now array. + * linespec.c (linespec_quote_characters): Now array. + * jit.c (jit_break_name, jit_descriptor_name, reader_init_fn_sym): + Now arrays. + 2020-09-14 Simon Marchi <simon.marchi@polymtl.ca> * debuginfod-support.c (debuginfod_client_deleter): New. @@ -45,9 +45,9 @@ static std::string jit_reader_dir; -static const char *const jit_break_name = "__jit_debug_register_code"; +static const char jit_break_name[] = "__jit_debug_register_code"; -static const char *const jit_descriptor_name = "__jit_debug_descriptor"; +static const char jit_descriptor_name[] = "__jit_debug_descriptor"; static void jit_inferior_init (struct gdbarch *gdbarch); static void jit_inferior_exit_hook (struct inferior *inf); @@ -173,7 +173,7 @@ struct jit_reader static struct jit_reader *loaded_jit_reader = NULL; typedef struct gdb_reader_funcs * (reader_init_fn_type) (void); -static const char *reader_init_fn_sym = "gdb_init_reader"; +static const char reader_init_fn_sym[] = "gdb_init_reader"; /* Try to load FILE_NAME as a JIT debug info reader. */ diff --git a/gdb/linespec.c b/gdb/linespec.c index 9c80864..686992e 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -421,7 +421,7 @@ static bool compare_msymbols (const bound_minimal_symbol &a, /* Permitted quote characters for the parser. This is different from the completer's quote characters to allow backward compatibility with the previous parser. */ -static const char *const linespec_quote_characters = "\"\'"; +static const char linespec_quote_characters[] = "\"\'"; /* Lexer functions. */ diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y index 4e7878f..db88809 100644 --- a/gdb/rust-exp.y +++ b/gdb/rust-exp.y @@ -123,7 +123,7 @@ static struct stoken make_stoken (const char *); since it is very long and this gives us a way to comment the sections. */ -static const char *number_regex_text = +static const char number_regex_text[] = /* subexpression 1: allows use of alternation, otherwise uninteresting */ "^(" /* First comes floating point. */ diff --git a/gdb/ui-style.c b/gdb/ui-style.c index 2d6640b..4ed08da 100644 --- a/gdb/ui-style.c +++ b/gdb/ui-style.c @@ -23,7 +23,7 @@ /* A regular expression that is used for matching ANSI terminal escape sequences. */ -static const char *ansi_regex_text = +static const char ansi_regex_text[] = /* Introduction. */ "^\033\\[" #define DATA_SUBEXP 1 diff --git a/gdb/unittests/memory-map-selftests.c b/gdb/unittests/memory-map-selftests.c index 42b5db6..0be5cb5 100644 --- a/gdb/unittests/memory-map-selftests.c +++ b/gdb/unittests/memory-map-selftests.c @@ -28,7 +28,7 @@ namespace memory_map_tests { /* A simple valid test input for parse_memory_map. */ -static const char *valid_mem_map = R"(<?xml version="1.0"?> +static const char valid_mem_map[] = R"(<?xml version="1.0"?> <!DOCTYPE memory-map PUBLIC "+//IDN gnu.org//DTD GDB Memory Map V1.0//EN" "http://sourceware.org/gdb/gdb-memory-map.dtd"> |