This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

[PATCH 3/3] make more variables const


From: Trevor Saunders <tbsaunde+binutils@tbsaunde.org>

Hi,

not very interesting, basically just adding a bunch of const.

built and regtested on x86_64-linux-gnu, and built one target per tc-*.c, ok?

Trev

gas/ChangeLog:

2016-03-20  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

	* config/tc-h8300.c (h8300_elf_section): Add const qualifiers.
	* config/tc-ia64.c (obj_elf_vms_common): Likewise.
	* config/tc-m68hc11.c (md_begin): Likewise.
	(print_opcode_list): Likewise.
	* config/tc-msp430.c (msp430_section): Likewise.
	* config/tc-score.c (struct s3_insn_to_dependency): Likewise.
	(s3_build_dependency_insn_hsh): Likewise.
	* config/tc-score7.c (struct s7_insn_to_dependency): Likewise.
	(s7_build_dependency_insn_hsh): Likewise.
	* config/tc-tic4x.c: Likewise.
	* config/tc-tic54x.c (tic54x_set_default_include): Likewise.
	(subsym_get_arg): Likewise.
	* config/tc-xtensa.c (struct suffix_reloc_map): Likewise.
	(get_directive): Likewise.
	(cache_literal_section): Likewise.
	* config/xtensa-relax.c: Likewise.
	* symbols.c (symbol_create): Likewise.
	(local_symbol_make): Likewise.
	(symbol_relc_make_expr): Likewise.

include/ChangeLog:

2016-03-20  Trevor Saunders  <tbsaunde+binutils@tbsaunde.org>

	* opcode/i960.h: Add const qualifiers.
	* opcode/tic4x.h (struct tic4x_inst): Likewise.
---
 gas/config/tc-h8300.c     |  2 +-
 gas/config/tc-ia64.c      |  2 +-
 gas/config/tc-m68hc11.c   |  4 ++--
 gas/config/tc-msp430.c    |  2 +-
 gas/config/tc-score.c     |  9 +++++----
 gas/config/tc-score7.c    |  9 +++++----
 gas/config/tc-tic4x.c     |  2 +-
 gas/config/tc-tic54x.c    | 10 +++++-----
 gas/config/tc-xtensa.c    | 13 +++++++------
 gas/config/xtensa-relax.c |  2 +-
 gas/symbols.c             | 10 +++++-----
 include/opcode/i960.h     |  2 +-
 include/opcode/tic4x.h    |  2 +-
 13 files changed, 36 insertions(+), 33 deletions(-)

diff --git a/gas/config/tc-h8300.c b/gas/config/tc-h8300.c
index 1b075c4..a620e6d 100644
--- a/gas/config/tc-h8300.c
+++ b/gas/config/tc-h8300.c
@@ -152,7 +152,7 @@ h8300_elf_section (int push)
   static const char * known_data_sections [] = { ".rodata", ".tdata", ".tbss" };
   static const char * known_data_prefixes [] = { ".debug", ".zdebug", ".gnu.warning" };
   char * saved_ilp = input_line_pointer;
-  char * name;
+  const char * name;
 
   name = obj_elf_section_name ();
   if (name == NULL)
diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c
index e43a7f9..76d3a46 100644
--- a/gas/config/tc-ia64.c
+++ b/gas/config/tc-ia64.c
@@ -1054,7 +1054,7 @@ ia64_cons_align (int nbytes)
 static void
 obj_elf_vms_common (int ignore ATTRIBUTE_UNUSED)
 {
-  char *sec_name;
+  const char *sec_name;
   char *sym_name;
   char c;
   offsetT size;
diff --git a/gas/config/tc-m68hc11.c b/gas/config/tc-m68hc11.c
index 05992ef..54ece5f 100644
--- a/gas/config/tc-m68hc11.c
+++ b/gas/config/tc-m68hc11.c
@@ -603,7 +603,7 @@ cmp_opcode (struct m68hc11_opcode *op1, struct m68hc11_opcode *op2)
 void
 md_begin (void)
 {
-  char *prev_name = "";
+  const char *prev_name = "";
   struct m68hc11_opcode *opcodes;
   struct m68hc11_opcode_def *opc = 0;
   int i, j;
@@ -964,7 +964,7 @@ static void
 print_opcode_list (void)
 {
   int i;
-  char *prev_name = "";
+  const char *prev_name = "";
   struct m68hc11_opcode *opcodes;
   int example = flag_print_opcodes == 2;
 
diff --git a/gas/config/tc-msp430.c b/gas/config/tc-msp430.c
index eb7df08..ee14d20 100644
--- a/gas/config/tc-msp430.c
+++ b/gas/config/tc-msp430.c
@@ -1497,7 +1497,7 @@ static void
 msp430_section (int arg)
 {
   char * saved_ilp = input_line_pointer;
-  char * name = obj_elf_section_name ();
+  const char * name = obj_elf_section_name ();
 
   msp430_make_init_symbols (name);
 
diff --git a/gas/config/tc-score.c b/gas/config/tc-score.c
index fadae49..ee195e2 100644
--- a/gas/config/tc-score.c
+++ b/gas/config/tc-score.c
@@ -334,7 +334,7 @@ enum s3_insn_type_for_dependency
 
 struct s3_insn_to_dependency
 {
-  char *insn_name;
+  const char *insn_name;
   enum s3_insn_type_for_dependency type;
 };
 
@@ -6344,14 +6344,15 @@ s3_build_dependency_insn_hsh (void)
       const struct s3_insn_to_dependency *tmp = s3_insn_to_dependency_table + i;
       size_t len = strlen (tmp->insn_name);
       struct s3_insn_to_dependency *new_i2n;
+      char *buf;
 
       new_i2n = (struct s3_insn_to_dependency *)
 	obstack_alloc (&dependency_obstack,
 		       sizeof (struct s3_insn_to_dependency));
-      new_i2n->insn_name = (char *) obstack_alloc (&dependency_obstack,
-                                                   len + 1);
+      buf = (char *) obstack_alloc (&dependency_obstack, len + 1);
 
-      strcpy (new_i2n->insn_name, tmp->insn_name);
+      strcpy (buf, tmp->insn_name);
+      new_i2n->insn_name = buf;
       new_i2n->type = tmp->type;
       hash_insert (s3_dependency_insn_hsh, new_i2n->insn_name,
                    (void *) new_i2n);
diff --git a/gas/config/tc-score7.c b/gas/config/tc-score7.c
index 6070589..97dfea2 100644
--- a/gas/config/tc-score7.c
+++ b/gas/config/tc-score7.c
@@ -191,7 +191,7 @@ enum s7_insn_type_for_dependency
 
 struct s7_insn_to_dependency
 {
-  char *insn_name;
+  const char *insn_name;
   enum s7_insn_type_for_dependency type;
 };
 
@@ -5121,14 +5121,15 @@ s7_build_dependency_insn_hsh (void)
       const struct s7_insn_to_dependency *tmp = s7_insn_to_dependency_table + i;
       size_t len = strlen (tmp->insn_name);
       struct s7_insn_to_dependency *new_i2d;
+      char *insn_name;
 
       new_i2d = (struct s7_insn_to_dependency *)
           obstack_alloc (&dependency_obstack,
                          sizeof (struct s7_insn_to_dependency));
-      new_i2d->insn_name = (char *) obstack_alloc (&dependency_obstack,
-                                                   len + 1);
+      insn_name = (char *) obstack_alloc (&dependency_obstack, len + 1);
 
-      strcpy (new_i2d->insn_name, tmp->insn_name);
+      strcpy (insn_name, tmp->insn_name);
+      new_i2d->insn_name = insn_name;
       new_i2d->type = tmp->type;
       hash_insert (s7_dependency_insn_hsh, new_i2d->insn_name,
                    (void *) new_i2d);
diff --git a/gas/config/tc-tic4x.c b/gas/config/tc-tic4x.c
index 0905658..21e6e36 100644
--- a/gas/config/tc-tic4x.c
+++ b/gas/config/tc-tic4x.c
@@ -1239,7 +1239,7 @@ tic4x_inst_insert (const tic4x_inst_t *inst)
 
 /* Make a new instruction template.  */
 static tic4x_inst_t *
-tic4x_inst_make (const char *name, unsigned long opcode, char *args)
+tic4x_inst_make (const char *name, unsigned long opcode, const char *args)
 {
   static tic4x_inst_t *insts = NULL;
   static char *names = NULL;
diff --git a/gas/config/tc-tic54x.c b/gas/config/tc-tic54x.c
index e071f95..050aa84 100644
--- a/gas/config/tc-tic54x.c
+++ b/gas/config/tc-tic54x.c
@@ -1871,7 +1871,7 @@ tic54x_clink (int ignored ATTRIBUTE_UNUSED)
 static void
 tic54x_set_default_include (int dot)
 {
-  char *dir = ".";
+  const char *dir = ".";
   char *tmp = NULL;
 
   if (!dot)
@@ -2912,7 +2912,7 @@ math_tanh (float arg1, float ignore ATTRIBUTE_UNUSED)
 /* Built-in substitution symbol functions and math functions.  */
 typedef struct
 {
-  char *name;
+  const char *name;
   int (*proc) (char *, char *);
   int nargs;
 } subsym_proc_entry;
@@ -2936,7 +2936,7 @@ static const subsym_proc_entry subsym_procs[] =
 
 typedef struct
 {
-  char *name;
+  const char *name;
   float (*proc) (float, float);
   int nargs;
   int int_return;
@@ -4296,7 +4296,7 @@ tic54x_parse_parallel_insn_lastline (tic54x_insn *insn, char *line)
    replacement on the value.  */
 
 static char *
-subsym_get_arg (char *line, char *terminators, char **str, int nosub)
+subsym_get_arg (char *line, const char *terminators, char **str, int nosub)
 {
   char *ptr = line;
   char *endp;
@@ -4328,7 +4328,7 @@ subsym_get_arg (char *line, char *terminators, char **str, int nosub)
     }
   else
     {
-      char *term = terminators;
+      const char *term = terminators;
       char *value = NULL;
 
       while (*ptr && *ptr != *term)
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index d995131..180181c 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -361,7 +361,7 @@ op_placement_info_table op_placement_table;
 
 struct suffix_reloc_map
 {
-  char *suffix;
+  const char *suffix;
   int length;
   bfd_reloc_code_real_type reloc;
   unsigned char operator;
@@ -1244,7 +1244,7 @@ get_directive (directiveE *directive, bfd_boolean *negated)
 {
   int len;
   unsigned i;
-  char *directive_string;
+  const char *directive_string;
 
   if (strncmp (input_line_pointer, "no-", 3) != 0)
     *negated = FALSE;
@@ -2269,7 +2269,7 @@ xg_arg_is_constant (char *arg, offsetT *valp)
 
 
 static void
-xg_replace_opname (char **popname, char *newop)
+xg_replace_opname (char **popname, const char *newop)
 {
   free (*popname);
   *popname = (char *) xmalloc (strlen (newop) + 1);
@@ -2439,8 +2439,8 @@ xtensa_translate_old_userreg_ops (char **popname)
 
 
 static int
-xtensa_translate_zero_immed (char *old_op,
-			     char *new_op,
+xtensa_translate_zero_immed (const char *old_op,
+			     const char *new_op,
 			     char **popname,
 			     int *pnum_args,
 			     char **arg_strings)
@@ -11518,7 +11518,8 @@ static segT
 cache_literal_section (bfd_boolean use_abs_literals)
 {
   const char *text_name, *group_name = 0;
-  char *base_name, *name, *suffix;
+  const char *base_name, *suffix;
+  char *name;
   segT *pcached;
   segT seg, current_section;
   int current_subsec;
diff --git a/gas/config/xtensa-relax.c b/gas/config/xtensa-relax.c
index 41f5714..a67fbe6 100644
--- a/gas/config/xtensa-relax.c
+++ b/gas/config/xtensa-relax.c
@@ -1572,7 +1572,7 @@ transition_applies (insn_pattern *initial_insn,
 
 static bfd_boolean
 wide_branch_opcode (const char *opcode_name,
-		    char *suffix,
+		    const char *suffix,
 		    xtensa_opcode *popcode)
 {
   xtensa_isa isa = xtensa_default_isa;
diff --git a/gas/symbols.c b/gas/symbols.c
index e117049..32236ba 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -66,7 +66,7 @@ struct obstack notes;
 const char * an_external_name;
 #endif
 
-static char *save_symbol_name (const char *);
+static const char *save_symbol_name (const char *);
 static void fb_label_init (void);
 static long dollar_label_instance (long);
 static long fb_label_instance (long);
@@ -101,7 +101,7 @@ symbol_new (const char *name, segT segment, valueT valu, fragS *frag)
 /* Save a symbol name on a permanent obstack, and convert it according
    to the object file format.  */
 
-static char *
+static const char *
 save_symbol_name (const char *name)
 {
   size_t name_length;
@@ -132,7 +132,7 @@ symbol_create (const char *name, /* It is copied, the caller can destroy/modify.
 	       valueT valu,	/* Symbol value.  */
 	       fragS *frag	/* Associated fragment.  */)
 {
-  char *preserved_copy_of_name;
+  const char *preserved_copy_of_name;
   symbolS *symbolP;
 
   preserved_copy_of_name = save_symbol_name (name);
@@ -190,7 +190,7 @@ static unsigned long local_symbol_conversion_count;
 struct local_symbol *
 local_symbol_make (const char *name, segT section, valueT val, fragS *frag)
 {
-  char *name_copy;
+  const char *name_copy;
   struct local_symbol *ret;
 
   ++local_symbol_count;
@@ -3103,7 +3103,7 @@ symbol_relc_make_value (offsetT val)
 char *
 symbol_relc_make_expr (expressionS * exp)
 {
-  char * opstr = NULL; /* Operator prefix string.  */
+  const char * opstr = NULL; /* Operator prefix string.  */
   int    arity = 0;    /* Arity of this operator.  */
   char * operands[3];  /* Up to three operands.  */
   char * concat_string = NULL;
diff --git a/include/opcode/i960.h b/include/opcode/i960.h
index 0904e1b..be3ac10 100644
--- a/include/opcode/i960.h
+++ b/include/opcode/i960.h
@@ -134,7 +134,7 @@
 /* Description of a single i80960 instruction */
 struct i960_opcode {
 	long opcode;	/* 32 bits, constant fields filled in, rest zeroed */
-	char *name;	/* Assembler mnemonic				   */
+	const char *name;	/* Assembler mnemonic				   */
 	short iclass;	/* Class: see #defines below			   */
 	char format;	/* REG, COBR, CTRL, MEMn, COJ, FBRA, or CALLJ	   */
 	char num_ops;	/* Number of operands				   */
diff --git a/include/opcode/tic4x.h b/include/opcode/tic4x.h
index f95d46a..b4209a1 100644
--- a/include/opcode/tic4x.h
+++ b/include/opcode/tic4x.h
@@ -226,7 +226,7 @@ struct tic4x_inst
   const char *  name;
   unsigned long opcode;
   unsigned long opmask;
-  char *        args;
+  const char *        args;
   unsigned long oplevel;
 };
 
-- 
2.1.4


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