This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 06/13] make various variables in gas const
- From: tbsaunde+binutils at tbsaunde dot org
- To: binutils at sourceware dot org
- Date: Sun, 21 Feb 2016 21:02:06 -0500
- Subject: [PATCH 06/13] make various variables in gas const
- Authentication-results: sourceware.org; auth=none
- References: <1456106533-19089-1-git-send-email-tbsaunde+binutils at tbsaunde dot org>
From: Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
gas/ChangeLog:
2016-02-21 Trevor Saunders <tbsaunde+binutils@tbsaunde.org>
* as.h (found_comment_file): Change type to const char *.
* cond.c (file_line::file): Likewise.
* config/obj-coff.c (obj_coff_init_stab_section): Make variable const.
* config/obj-elf.c (obj_elf_init_stab_section): Likewise.
* config/obj-som.c (obj_som_init_stab_section): Likewise.
* config/tc-aarch64.c (output_info): Likewise.
* config/tc-alpha.c (insert_operand): Likewise.
* config/tc-arc.c (insert_operand): Likewise.
* config/tc-d30v.c (check_size): Likewise.
* config/tc-ia64.c (struct alias): Likewise.
* config/tc-m68k.c (struct label_line): Likewise.
* config/tc-mcore.c (md_apply_fix): Likewise.
* config/tc-microblaze.c (md_estimate_size_before_relax): Likewise.
* config/tc-mips.c (mips16_immed): Likewise.
* config/tc-mmix.c (mmix_handle_mmixal): Likewise.
* config/tc-ppc.c (ppc_insert_operand): Likewise.
* config/tc-rx.c (rx_include): Likewise.
* config/tc-s390.c (s390_insert_operand): Likewise.
* config/tc-tic54x.c (tic54x_set_default_include): Likewise.
(tic54x_adjust_symtab): Likewise.
* config/tc-tilegx.c (insert_operand): Likewise.
(apply_special_operator): Likewise.
* config/tc-tilepro.c (insert_operand): Likewise.
* config/tc-xtensa.c (directive_push): Likewise.
* ecoff.c (add_file): Likewise.
(ecoff_generate_asm_lineno): Likewise.
* listing.c (listing_newline): Likewise.
* read.c (s_irp): Likewise.
* write.c (install_reloc): Likewise.
* write.h (struct fix): Likewise.
---
gas/as.h | 2 +-
gas/cond.c | 2 +-
gas/config/obj-coff.c | 2 +-
gas/config/obj-elf.c | 2 +-
gas/config/obj-som.c | 3 ++-
gas/config/tc-aarch64.c | 2 +-
gas/config/tc-alpha.c | 2 +-
gas/config/tc-arc.c | 2 +-
gas/config/tc-d30v.c | 2 +-
gas/config/tc-ia64.c | 2 +-
gas/config/tc-m68k.c | 2 +-
gas/config/tc-mcore.c | 2 +-
gas/config/tc-microblaze.c | 6 +++---
gas/config/tc-mips.c | 4 ++--
gas/config/tc-mmix.c | 6 +++---
gas/config/tc-ppc.c | 2 +-
gas/config/tc-rx.c | 8 ++++----
gas/config/tc-s390.c | 2 +-
gas/config/tc-tic54x.c | 5 ++---
gas/config/tc-tilegx.c | 5 +++--
gas/config/tc-tilepro.c | 2 +-
gas/config/tc-xtensa.c | 2 +-
gas/ecoff.c | 7 ++-----
gas/listing.c | 4 ++--
gas/read.c | 3 ++-
gas/write.c | 2 +-
gas/write.h | 2 +-
27 files changed, 42 insertions(+), 43 deletions(-)
diff --git a/gas/as.h b/gas/as.h
index 7c5ea4f..496ebca 100644
--- a/gas/as.h
+++ b/gas/as.h
@@ -580,7 +580,7 @@ COMMON int flag_m68k_mri;
#ifdef WARN_COMMENTS
COMMON int warn_comment;
COMMON unsigned int found_comment;
-COMMON char * found_comment_file;
+COMMON const char * found_comment_file;
#endif
#if defined OBJ_ELF || defined OBJ_MAYBE_ELF
diff --git a/gas/cond.c b/gas/cond.c
index 4be6061..824ba77 100644
--- a/gas/cond.c
+++ b/gas/cond.c
@@ -29,7 +29,7 @@
struct obstack cond_obstack;
struct file_line {
- char *file;
+ const char *file;
unsigned int line;
};
diff --git a/gas/config/obj-coff.c b/gas/config/obj-coff.c
index ef3747b..03be655 100644
--- a/gas/config/obj-coff.c
+++ b/gas/config/obj-coff.c
@@ -1810,7 +1810,7 @@ coff_frob_section (segT sec)
void
obj_coff_init_stab_section (segT seg)
{
- char *file;
+ const char *file;
char *p;
char *stabstr_name;
unsigned int stroff;
diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index 31a2877..e8af394 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -2045,7 +2045,7 @@ obj_elf_ident (int ignore ATTRIBUTE_UNUSED)
void
obj_elf_init_stab_section (segT seg)
{
- char *file;
+ const char *file;
char *p;
char *stabstr_name;
unsigned int stroff;
diff --git a/gas/config/obj-som.c b/gas/config/obj-som.c
index 34571e8..c0b2b41 100644
--- a/gas/config/obj-som.c
+++ b/gas/config/obj-som.c
@@ -210,7 +210,8 @@ obj_som_init_stab_section (segT seg)
segT saved_seg = now_seg;
segT space;
subsegT saved_subseg = now_subseg;
- char *p, *file;
+ char *p;
+ const char * file;
unsigned int stroff;
/* Make the space which will contain the debug subspaces. */
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index ca92ab0..b455dc8 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -4259,7 +4259,7 @@ print_operands (char *buf, const aarch64_opcode *opcode,
static void
output_info (const char *format, ...)
{
- char *file;
+ const char *file;
unsigned int line;
va_list args;
diff --git a/gas/config/tc-alpha.c b/gas/config/tc-alpha.c
index 5d754c9..e849a95 100644
--- a/gas/config/tc-alpha.c
+++ b/gas/config/tc-alpha.c
@@ -1973,7 +1973,7 @@ static unsigned
insert_operand (unsigned insn,
const struct alpha_operand *operand,
offsetT val,
- char *file,
+ const char *file,
unsigned line)
{
if (operand->bits != 32 && !(operand->flags & AXP_OPERAND_NOOVERFLOW))
diff --git a/gas/config/tc-arc.c b/gas/config/tc-arc.c
index bfe9ae1..82cff9a 100644
--- a/gas/config/tc-arc.c
+++ b/gas/config/tc-arc.c
@@ -2239,7 +2239,7 @@ static unsigned
insert_operand (unsigned insn,
const struct arc_operand *operand,
offsetT val,
- char *file,
+ const char *file,
unsigned line)
{
offsetT min = 0, max = 0;
diff --git a/gas/config/tc-d30v.c b/gas/config/tc-d30v.c
index 68880e0..1ac1605 100644
--- a/gas/config/tc-d30v.c
+++ b/gas/config/tc-d30v.c
@@ -1840,7 +1840,7 @@ d30v_start_line (void)
}
static void
-check_size (long value, int bits, char *file, int line)
+check_size (long value, int bits, const char *file, int line)
{
int tmp, max;
diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c
index 987858c..f88c3c2 100644
--- a/gas/config/tc-ia64.c
+++ b/gas/config/tc-ia64.c
@@ -11766,7 +11766,7 @@ ia64_check_label (symbolS *label)
the relocatable file. */
struct alias
{
- char *file; /* The file where the directive is seen. */
+ const char *file; /* The file where the directive is seen. */
unsigned int line; /* The line number the directive is at. */
const char *name; /* The original name of the symbol. */
};
diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c
index be9fa3d..7ef5ff4 100644
--- a/gas/config/tc-m68k.c
+++ b/gas/config/tc-m68k.c
@@ -122,7 +122,7 @@ struct label_line
{
struct label_line *next;
symbolS *label;
- char *file;
+ const char *file;
unsigned int line;
int text;
};
diff --git a/gas/config/tc-mcore.c b/gas/config/tc-mcore.c
index e4dda2d..f73f3b7 100644
--- a/gas/config/tc-mcore.c
+++ b/gas/config/tc-mcore.c
@@ -1917,7 +1917,7 @@ md_apply_fix (fixS * fixP,
segT segment ATTRIBUTE_UNUSED)
{
char * buf = fixP->fx_where + fixP->fx_frag->fr_literal;
- char * file = fixP->fx_file ? fixP->fx_file : _("unknown");
+ const char * file = fixP->fx_file ? fixP->fx_file : _("unknown");
const char * symname;
/* Note: use offsetT because it is signed, valueT is unsigned. */
offsetT val = *valP;
diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c
index 5484b30..16c70ad 100644
--- a/gas/config/tc-microblaze.c
+++ b/gas/config/tc-microblaze.c
@@ -1960,7 +1960,7 @@ md_apply_fix (fixS * fixP,
segT segment)
{
char * buf = fixP->fx_where + fixP->fx_frag->fr_literal;
- char * file = fixP->fx_file ? fixP->fx_file : _("unknown");
+ const char * file = fixP->fx_file ? fixP->fx_file : _("unknown");
const char * symname;
/* Note: use offsetT because it is signed, valueT is unsigned. */
offsetT val = (offsetT) * valp;
@@ -2257,7 +2257,7 @@ md_estimate_size_before_relax (fragS * fragP,
{
/* Variable not in small data read only segment accessed
using small data read only anchor. */
- char *file = fragP->fr_file ? fragP->fr_file : _("unknown");
+ const char *file = fragP->fr_file ? fragP->fr_file : _("unknown");
as_bad_where (file, fragP->fr_line,
_("Variable is accessed using small data read "
@@ -2280,7 +2280,7 @@ md_estimate_size_before_relax (fragS * fragP,
}
else
{
- char *file = fragP->fr_file ? fragP->fr_file : _("unknown");
+ const char *file = fragP->fr_file ? fragP->fr_file : _("unknown");
as_bad_where (file, fragP->fr_line,
_("Variable is accessed using small data read "
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 7b34a4b..862454d 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -1307,7 +1307,7 @@ static void mips16_macro (struct mips_cl_insn * ip);
static void mips_ip (char *str, struct mips_cl_insn * ip);
static void mips16_ip (char *str, struct mips_cl_insn * ip);
static void mips16_immed
- (char *, unsigned int, int, bfd_reloc_code_real_type, offsetT,
+ (const char *, unsigned int, int, bfd_reloc_code_real_type, offsetT,
unsigned int, unsigned long *);
static size_t my_getSmallExpression
(expressionS *, bfd_reloc_code_real_type *, char *);
@@ -13784,7 +13784,7 @@ mips16_immed_in_range_p (const struct mips_int_operand *operand,
is the length that the user requested, or 0 if none. */
static void
-mips16_immed (char *file, unsigned int line, int type,
+mips16_immed (const char *file, unsigned int line, int type,
bfd_reloc_code_real_type reloc, offsetT val,
unsigned int user_insn_length, unsigned long *insn)
{
diff --git a/gas/config/tc-mmix.c b/gas/config/tc-mmix.c
index b40f078..dac38d0 100644
--- a/gas/config/tc-mmix.c
+++ b/gas/config/tc-mmix.c
@@ -186,7 +186,7 @@ int mmix_next_semicolon_is_eoln = 1;
/* Do we have a BSPEC in progress? */
static int doing_bspec = 0;
-static char *bspec_file;
+static const char *bspec_file;
static unsigned int bspec_line;
struct option md_longopts[] =
@@ -2940,7 +2940,7 @@ mmix_handle_mmixal (void)
if (is_end_of_line[(unsigned int) *s])
{
unsigned int line;
- char * name = as_where (&line);
+ const char * name = as_where (&line);
as_bad_where (name, line + 1,
_("[0-9]H labels may not appear alone on a line"));
current_fb_label = -1;
@@ -2948,7 +2948,7 @@ mmix_handle_mmixal (void)
if (*s == '.')
{
unsigned int line;
- char * name = as_where (&line);
+ const char * name = as_where (&line);
as_bad_where (name, line + 1,
_("[0-9]H labels do not mix with dot-pseudos"));
current_fb_label = -1;
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index 57029f7..69dc0e8 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -1774,7 +1774,7 @@ ppc_insert_operand (unsigned long insn,
const struct powerpc_operand *operand,
offsetT val,
ppc_cpu_t cpu,
- char *file,
+ const char *file,
unsigned int line)
{
long min, max, right;
diff --git a/gas/config/tc-rx.c b/gas/config/tc-rx.c
index aeb409e..91d4828 100644
--- a/gas/config/tc-rx.c
+++ b/gas/config/tc-rx.c
@@ -266,10 +266,10 @@ rx_include (int ignore)
FILE * try;
char * path;
char * filename;
- char * current_filename;
+ const char * current_filename;
char * last_char;
- char * p;
- char * d;
+ const char * p;
+ const char * d;
char * f;
char end_char;
size_t len;
@@ -308,7 +308,7 @@ rx_include (int ignore)
of any directory prefixes or extensions. */
if ((p = rx_strcasestr (filename, "..file")) != NULL)
{
- char * c;
+ const char * c;
len = 6; /* strlen ("..file"); */
diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c
index 66b54ea..e1ea68e 100644
--- a/gas/config/tc-s390.c
+++ b/gas/config/tc-s390.c
@@ -582,7 +582,7 @@ static void
s390_insert_operand (unsigned char *insn,
const struct s390_operand *operand,
offsetT val,
- char *file,
+ const char *file,
unsigned int line)
{
addressT uval;
diff --git a/gas/config/tc-tic54x.c b/gas/config/tc-tic54x.c
index a91f3e7..3ed7933 100644
--- a/gas/config/tc-tic54x.c
+++ b/gas/config/tc-tic54x.c
@@ -1876,7 +1876,7 @@ tic54x_set_default_include (int dot)
if (!dot)
{
- char *curfile;
+ const char *curfile;
unsigned lineno;
curfile = as_where (&lineno);
@@ -5002,9 +5002,8 @@ tic54x_adjust_symtab (void)
if (symbol_rootP == NULL
|| S_GET_STORAGE_CLASS (symbol_rootP) != C_FILE)
{
- char *filename;
unsigned lineno;
- filename = as_where (&lineno);
+ const char * filename = as_where (&lineno);
c_dot_file_symbol (filename, 0);
}
}
diff --git a/gas/config/tc-tilegx.c b/gas/config/tc-tilegx.c
index 0b4ece6..7897aca 100644
--- a/gas/config/tc-tilegx.c
+++ b/gas/config/tc-tilegx.c
@@ -396,7 +396,7 @@ static tilegx_bundle_bits
insert_operand (tilegx_bundle_bits bits,
const struct tilegx_operand *operand,
int operand_value,
- char *file,
+ const char *file,
unsigned lineno)
{
/* Range-check the immediate. */
@@ -434,7 +434,8 @@ insert_operand (tilegx_bundle_bits bits,
static int
-apply_special_operator (operatorT op, offsetT num, char *file, unsigned lineno)
+apply_special_operator (operatorT op, offsetT num, const char *file,
+ unsigned lineno)
{
int ret;
int check_shift = -1;
diff --git a/gas/config/tc-tilepro.c b/gas/config/tc-tilepro.c
index 00eeaa6..90ce09a 100644
--- a/gas/config/tc-tilepro.c
+++ b/gas/config/tc-tilepro.c
@@ -352,7 +352,7 @@ static tilepro_bundle_bits
insert_operand (tilepro_bundle_bits bits,
const struct tilepro_operand *operand,
int operand_value,
- char *file,
+ const char *file,
unsigned lineno)
{
/* Range-check the immediate. */
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index f169ef8..aa6f8dc 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -1163,7 +1163,7 @@ do_align_targets (void)
static void
directive_push (directiveE directive, bfd_boolean negated, const void *datum)
{
- char *file;
+ const char *file;
unsigned int line;
state_stackS *stack = (state_stackS *) xmalloc (sizeof (state_stackS));
diff --git a/gas/ecoff.c b/gas/ecoff.c
index d33ffc7..25c3d94 100644
--- a/gas/ecoff.c
+++ b/gas/ecoff.c
@@ -2196,12 +2196,9 @@ add_file (const char *file_name, int indx ATTRIBUTE_UNUSED, int fake)
want to use the actual file name. */
if (file_name == (const char *) NULL)
{
- char *file;
-
if (first_file != (efdr_t *) NULL)
as_fatal (_("fake .file after real one"));
- file = as_where ((unsigned int *) NULL);
- file_name = (const char *) file;
+ file_name = as_where ((unsigned int *) NULL);
/* Automatically generate ECOFF debugging information, since I
think that's what other ECOFF assemblers do. We don't do
@@ -5181,7 +5178,7 @@ void
ecoff_generate_asm_lineno (void)
{
unsigned int lineno;
- char *filename;
+ const char *filename;
lineno_list_t *list;
filename = as_where (&lineno);
diff --git a/gas/listing.c b/gas/listing.c
index 26f2722..4b5fd34 100644
--- a/gas/listing.c
+++ b/gas/listing.c
@@ -297,10 +297,10 @@ new_frag (void)
void
listing_newline (char *ps)
{
- char *file;
+ const char *file;
unsigned int line;
static unsigned int last_line = 0xffff;
- static char *last_file = NULL;
+ static const char *last_file = NULL;
list_info_type *new_i = NULL;
if (listing == 0)
diff --git a/gas/read.c b/gas/read.c
index f85a014..e5f7a6b 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -2348,7 +2348,8 @@ s_globl (int ignore ATTRIBUTE_UNUSED)
void
s_irp (int irpc)
{
- char *file, *eol;
+ char * eol;
+ const char * file;
unsigned int line;
sb s;
const char *err;
diff --git a/gas/write.c b/gas/write.c
index b1ccba2..f623b00 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -1137,7 +1137,7 @@ fix_segment (bfd *abfd ATTRIBUTE_UNUSED,
static void
install_reloc (asection *sec, arelent *reloc, fragS *fragp,
- char *file, unsigned int line)
+ const char *file, unsigned int line)
{
char *err;
bfd_reloc_status_type s;
diff --git a/gas/write.h b/gas/write.h
index 4aee78d..95c7dec 100644
--- a/gas/write.h
+++ b/gas/write.h
@@ -112,7 +112,7 @@ struct fix
/* The location of the instruction which created the reloc, used
in error messages. */
- char *fx_file;
+ const char *fx_file;
unsigned fx_line;
#ifdef USING_CGEN
--
2.7.0