This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[obv] Code cleanup: add_setshow_enum_cmd: Make 1440 bytes of data segment read-only


Hello,

I understand it is not much a real world issue but I had to still write new
code with wrong (sub-optimal) const-ness.

So I made it const, it makes 1440 bytes const.

add_setshow_enum_cmd remains compatible with callers `const char **' (while
now it uses `const char *const *').


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2012-01/msg00243.html

--- src/gdb/ChangeLog	2012/01/27 20:31:12	1.13787
+++ src/gdb/ChangeLog	2012/01/28 18:08:12	1.13788
@@ -1,3 +1,38 @@
+2012-01-28  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	Code cleanup: Make 1440 bytes of data segment read-only.
+	* arch-utils.c (endian_enum): Make it const char *const [].
+	* arm-tdep.c (fp_model_strings, arm_abi_strings, arm_mode_strings):
+	Likewise.
+	* breakpoint.c (always_inserted_enums): Likewise.
+	* cli/cli-cmds.c (script_ext_enums): Likewise.
+	* cli/cli-decode.c (add_setshow_enum_cmd, complete_on_enum): Make the
+	enumlist parameter const char *const *.
+	* cli/cli-decode.h (struct cmd_list_element): Make the enums field
+	const char *const *.
+	* command.h (complete_on_enum, add_setshow_enum_cmd): Make the enumlist
+	parameter const char *const *.
+	* cris-tdep.c (cris_modes): Make it const char *const [].
+	* filesystem.c (target_file_system_kinds): Likewise.
+	* i386-tdep.c (valid_flavors, valid_conventions): Likewise.
+	* infrun.c (follow_fork_mode_kind_names, follow_exec_mode_names)
+	(can_use_displaced_stepping_enum, scheduler_enums)
+	(exec_direction_names): Likewise.
+	* language.c (_initialize_language): Make the type_or_range_names and
+	case_sensitive_names variables const char *const [].
+	* mips-tdep.c (mips_abi_strings): Make it const char *const [].
+	* python/python.c (python_excp_enums): Likewise.
+	* remote.c (interrupt_sequence_modes): Likewise.
+	* rs6000-tdep.c (powerpc_vector_strings): Likewise.
+	* serial.c (logbase_enums): Likewise.
+	* sh-tdep.c (sh_cc_enum): Likewise.
+	* stack.c (print_frame_arguments_choices, print_entry_values_choices):
+	Likewise.
+	* symtab.c (multiple_symbols_modes): Likewise.
+	* tui/tui-win.c (tui_border_kind_enums, tui_border_mode_enums):
+	Likewise.
+	* utils.c (internal_problem_modes): Likewise.
+
 2012-01-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
 
 	Fix the 2012-01-26 regression by la_get_symbol_name_match_p.
--- src/gdb/arch-utils.c	2012/01/04 13:51:36	1.196
+++ src/gdb/arch-utils.c	2012/01/28 18:08:16	1.197
@@ -251,7 +251,7 @@
 static const char endian_big[] = "big";
 static const char endian_little[] = "little";
 static const char endian_auto[] = "auto";
-static const char *endian_enum[] =
+static const char *const endian_enum[] =
 {
   endian_big,
   endian_little,
--- src/gdb/arm-tdep.c	2012/01/04 08:16:56	1.356
+++ src/gdb/arm-tdep.c	2012/01/28 18:08:16	1.357
@@ -97,7 +97,7 @@
 
 /* The type of floating-point to use.  Keep this in sync with enum
    arm_float_model, and the help string in _initialize_arm_tdep.  */
-static const char *fp_model_strings[] =
+static const char *const fp_model_strings[] =
 {
   "auto",
   "softfpa",
@@ -112,7 +112,7 @@
 static const char *current_fp_model = "auto";
 
 /* The ABI to use.  Keep this in sync with arm_abi_kind.  */
-static const char *arm_abi_strings[] =
+static const char *const arm_abi_strings[] =
 {
   "auto",
   "APCS",
@@ -125,7 +125,7 @@
 static const char *arm_abi_string = "auto";
 
 /* The execution mode to assume.  */
-static const char *arm_mode_strings[] =
+static const char *const arm_mode_strings[] =
   {
     "auto",
     "arm",
--- src/gdb/breakpoint.c	2012/01/25 15:57:04	1.648
+++ src/gdb/breakpoint.c	2012/01/28 18:08:17	1.649
@@ -373,7 +373,7 @@
 static const char always_inserted_auto[] = "auto";
 static const char always_inserted_on[] = "on";
 static const char always_inserted_off[] = "off";
-static const char *always_inserted_enums[] = {
+static const char *const always_inserted_enums[] = {
   always_inserted_auto,
   always_inserted_off,
   always_inserted_on,
--- src/gdb/command.h	2012/01/05 11:39:31	1.77
+++ src/gdb/command.h	2012/01/28 18:08:17	1.78
@@ -211,7 +211,7 @@
 extern char **complete_on_cmdlist (struct cmd_list_element *,
 				   char *, char *);
 
-extern char **complete_on_enum (const char *enumlist[],
+extern char **complete_on_enum (const char *const *enumlist,
 				char *, char *);
 
 /* Functions that implement commands about CLI commands.  */
@@ -232,7 +232,7 @@
 
 extern void add_setshow_enum_cmd (char *name,
 				  enum command_class class,
-				  const char *enumlist[],
+				  const char *const *enumlist,
 				  const char **var,
 				  const char *set_doc,
 				  const char *show_doc,
--- src/gdb/cris-tdep.c	2012/01/04 08:17:00	1.181
+++ src/gdb/cris-tdep.c	2012/01/28 18:08:17	1.182
@@ -151,7 +151,7 @@
 
 static const char cris_mode_normal[] = "normal";
 static const char cris_mode_guru[] = "guru";
-static const char *cris_modes[] = {
+static const char *const cris_modes[] = {
   cris_mode_normal,
   cris_mode_guru,
   0
--- src/gdb/filesystem.c	2012/01/04 08:17:02	1.4
+++ src/gdb/filesystem.c	2012/01/28 18:08:17	1.5
@@ -25,7 +25,7 @@
 const char file_system_kind_auto[] = "auto";
 const char file_system_kind_unix[] = "unix";
 const char file_system_kind_dos_based[] = "dos-based";
-const char *target_file_system_kinds[] =
+const char *const target_file_system_kinds[] =
 {
   file_system_kind_auto,
   file_system_kind_unix,
--- src/gdb/i386-tdep.c	2012/01/12 15:39:36	1.342
+++ src/gdb/i386-tdep.c	2012/01/28 18:08:17	1.343
@@ -376,7 +376,7 @@
    its legitimate values.  */
 static const char att_flavor[] = "att";
 static const char intel_flavor[] = "intel";
-static const char *valid_flavors[] =
+static const char *const valid_flavors[] =
 {
   att_flavor,
   intel_flavor,
@@ -2545,7 +2545,7 @@
 static const char default_struct_convention[] = "default";
 static const char pcc_struct_convention[] = "pcc";
 static const char reg_struct_convention[] = "reg";
-static const char *valid_conventions[] =
+static const char *const valid_conventions[] =
 {
   default_struct_convention,
   pcc_struct_convention,
--- src/gdb/infrun.c	2012/01/24 21:39:15	1.521
+++ src/gdb/infrun.c	2012/01/28 18:08:18	1.522
@@ -389,7 +389,7 @@
 static const char follow_fork_mode_child[] = "child";
 static const char follow_fork_mode_parent[] = "parent";
 
-static const char *follow_fork_mode_kind_names[] = {
+static const char *const follow_fork_mode_kind_names[] = {
   follow_fork_mode_child,
   follow_fork_mode_parent,
   NULL
@@ -778,7 +778,7 @@
 
 static const char follow_exec_mode_new[] = "new";
 static const char follow_exec_mode_same[] = "same";
-static const char *follow_exec_mode_names[] =
+static const char *const follow_exec_mode_names[] =
 {
   follow_exec_mode_new,
   follow_exec_mode_same,
@@ -1175,7 +1175,7 @@
 static const char can_use_displaced_stepping_auto[] = "auto";
 static const char can_use_displaced_stepping_on[] = "on";
 static const char can_use_displaced_stepping_off[] = "off";
-static const char *can_use_displaced_stepping_enum[] =
+static const char *const can_use_displaced_stepping_enum[] =
 {
   can_use_displaced_stepping_auto,
   can_use_displaced_stepping_on,
@@ -1579,7 +1579,7 @@
 static const char schedlock_off[] = "off";
 static const char schedlock_on[] = "on";
 static const char schedlock_step[] = "step";
-static const char *scheduler_enums[] = {
+static const char *const scheduler_enums[] = {
   schedlock_off,
   schedlock_on,
   schedlock_step,
@@ -6907,7 +6907,7 @@
 static const char exec_forward[] = "forward";
 static const char exec_reverse[] = "reverse";
 static const char *exec_direction = exec_forward;
-static const char *exec_direction_names[] = {
+static const char *const exec_direction_names[] = {
   exec_forward,
   exec_reverse,
   NULL
--- src/gdb/language.c	2012/01/26 04:20:36	1.106
+++ src/gdb/language.c	2012/01/28 18:08:18	1.107
@@ -1109,10 +1109,10 @@
 void
 _initialize_language (void)
 {
-  static const char *type_or_range_names[]
+  static const char *const type_or_range_names[]
     = { "on", "off", "warn", "auto", NULL };
 
-  static const char *case_sensitive_names[]
+  static const char *const case_sensitive_names[]
     = { "on", "off", "auto", NULL };
 
   language_gdbarch_data
--- src/gdb/mips-tdep.c	2012/01/04 08:17:08	1.529
+++ src/gdb/mips-tdep.c	2012/01/28 18:08:18	1.530
@@ -82,7 +82,7 @@
 
 static const char *mips_abi_string;
 
-static const char *mips_abi_strings[] = {
+static const char *const mips_abi_strings[] = {
   "auto",
   "n32",
   "o32",
--- src/gdb/remote.c	2012/01/24 14:19:03	1.479
+++ src/gdb/remote.c	2012/01/28 18:08:18	1.480
@@ -742,7 +742,7 @@
 const char interrupt_sequence_control_c[] = "Ctrl-C";
 const char interrupt_sequence_break[] = "BREAK";
 const char interrupt_sequence_break_g[] = "BREAK-g";
-static const char *interrupt_sequence_modes[] =
+static const char *const interrupt_sequence_modes[] =
   {
     interrupt_sequence_control_c,
     interrupt_sequence_break,
--- src/gdb/rs6000-tdep.c	2012/01/04 08:17:10	1.354
+++ src/gdb/rs6000-tdep.c	2012/01/28 18:08:19	1.355
@@ -108,7 +108,7 @@
 static enum auto_boolean powerpc_soft_float_global = AUTO_BOOLEAN_AUTO;
 
 /* The vector ABI to use.  Keep this in sync with powerpc_vector_abi.  */
-static const char *powerpc_vector_strings[] =
+static const char *const powerpc_vector_strings[] =
 {
   "auto",
   "generic",
--- src/gdb/serial.c	2012/01/04 08:17:10	1.45
+++ src/gdb/serial.c	2012/01/28 18:08:20	1.46
@@ -53,7 +53,7 @@
 static const char logbase_hex[] = "hex";
 static const char logbase_octal[] = "octal";
 static const char logbase_ascii[] = "ascii";
-static const char *logbase_enums[] =
+static const char *const logbase_enums[] =
 {logbase_hex, logbase_octal, logbase_ascii, NULL};
 static const char *serial_logbase = logbase_ascii;
 
--- src/gdb/sh-tdep.c	2012/01/04 08:17:10	1.235
+++ src/gdb/sh-tdep.c	2012/01/28 18:08:20	1.236
@@ -59,7 +59,7 @@
 
 static const char sh_cc_gcc[] = "gcc";
 static const char sh_cc_renesas[] = "renesas";
-static const char *sh_cc_enum[] = {
+static const char *const sh_cc_enum[] = {
   sh_cc_gcc,
   sh_cc_renesas, 
   NULL
--- src/gdb/stack.c	2012/01/24 15:13:28	1.245
+++ src/gdb/stack.c	2012/01/28 18:08:20	1.246
@@ -59,7 +59,7 @@
 /* The possible choices of "set print frame-arguments", and the value
    of this setting.  */
 
-static const char *print_frame_arguments_choices[] =
+static const char *const print_frame_arguments_choices[] =
   {"all", "scalars", "none", NULL};
 static const char *print_frame_arguments = "scalars";
 
@@ -73,7 +73,7 @@
 const char print_entry_values_both[] = "both";
 const char print_entry_values_compact[] = "compact";
 const char print_entry_values_default[] = "default";
-static const char *print_entry_values_choices[] =
+static const char *const print_entry_values_choices[] =
 {
   print_entry_values_no,
   print_entry_values_only,
--- src/gdb/symtab.c	2012/01/26 23:41:54	1.293
+++ src/gdb/symtab.c	2012/01/28 18:08:20	1.294
@@ -122,7 +122,7 @@
 const char multiple_symbols_ask[] = "ask";
 const char multiple_symbols_all[] = "all";
 const char multiple_symbols_cancel[] = "cancel";
-static const char *multiple_symbols_modes[] =
+static const char *const multiple_symbols_modes[] =
 {
   multiple_symbols_ask,
   multiple_symbols_all,
--- src/gdb/utils.c	2012/01/23 17:12:30	1.272
+++ src/gdb/utils.c	2012/01/28 18:08:21	1.273
@@ -886,7 +886,7 @@
 const char internal_problem_ask[] = "ask";
 const char internal_problem_yes[] = "yes";
 const char internal_problem_no[] = "no";
-static const char *internal_problem_modes[] =
+static const char *const internal_problem_modes[] =
 {
   internal_problem_ask,
   internal_problem_yes,
--- src/gdb/cli/cli-cmds.c	2012/01/26 21:54:44	1.125
+++ src/gdb/cli/cli-cmds.c	2012/01/28 18:08:21	1.126
@@ -201,7 +201,7 @@
 static const char script_ext_soft[] = "soft";
 static const char script_ext_strict[] = "strict";
 
-static const char *script_ext_enums[] = {
+static const char *const script_ext_enums[] = {
   script_ext_off,
   script_ext_soft,
   script_ext_strict,
--- src/gdb/cli/cli-decode.c	2012/01/04 08:17:17	1.100
+++ src/gdb/cli/cli-decode.c	2012/01/28 18:08:21	1.101
@@ -412,7 +412,7 @@
 void
 add_setshow_enum_cmd (char *name,
 		      enum command_class class,
-		      const char *enumlist[],
+		      const char *const *enumlist,
 		      const char **var,
 		      const char *set_doc,
 		      const char *show_doc,
@@ -1733,7 +1733,7 @@
    "oobar"; if WORD is "baz/foo", return "baz/foobar".  */
 
 char **
-complete_on_enum (const char *enumlist[],
+complete_on_enum (const char *const *enumlist,
 		  char *text,
 		  char *word)
 {
--- src/gdb/cli/cli-decode.h	2012/01/05 11:39:31	1.40
+++ src/gdb/cli/cli-decode.h	2012/01/28 18:08:21	1.41
@@ -189,7 +189,7 @@
 
     /* Pointer to NULL terminated list of enumerated values (like
        argv).  */
-    const char **enums;
+    const char *const *enums;
 
     /* Pointer to command strings of user-defined commands */
     struct command_line *user_commands;
--- src/gdb/python/python.c	2012/01/26 21:54:45	1.84
+++ src/gdb/python/python.c	2012/01/28 18:08:22	1.85
@@ -41,7 +41,7 @@
 static const char python_excp_message[] = "message";
 
 /* "set python print-stack" choices.  */
-static const char *python_excp_enums[] =
+static const char *const python_excp_enums[] =
   {
     python_excp_none,
     python_excp_full,
--- src/gdb/tui/tui-win.c	2012/01/04 08:27:59	1.55
+++ src/gdb/tui/tui-win.c	2012/01/28 18:08:22	1.56
@@ -107,7 +107,7 @@
 #endif
 
 /* Possible values for tui-border-kind variable.  */
-static const char *tui_border_kind_enums[] = {
+static const char *const tui_border_kind_enums[] = {
   "space",
   "ascii",
   "acs",
@@ -115,7 +115,7 @@
 };
 
 /* Possible values for tui-border-mode and tui-active-border-mode.  */
-static const char *tui_border_mode_enums[] = {
+static const char *const tui_border_mode_enums[] = {
   "normal",
   "standout",
   "reverse",


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]