From 82b8a7851fb9d7724c53d13a4319d1e47acc4460 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Wed, 23 Mar 2016 22:39:13 -0400 Subject: [PATCH] add more const qualifiers gas/ChangeLog: 2016-03-28 Trevor Saunders * config/obj-elf.c (obj_elf_section_name): Return const char *. * config/obj-elf.h (obj_elf_section_name): Adjust. * config/tc-aarch64.c (aarch64_parse_features): Likewise. (aarch64_parse_cpu): Likewise. (aarch64_parse_arch): Likewise. * config/tc-arm.c (arm_parse_extension): Likewise. (arm_parse_cpu): Likewise. (arm_parse_arch): Likewise. * config/tc-nds32.c: Likewise. * config/xtensa-relax.c (parse_special_fn): Likewise. * stabs.c (generate_asm_file): Likewise. --- gas/ChangeLog | 14 ++++++++++++++ gas/config/obj-elf.c | 5 +++-- gas/config/obj-elf.h | 2 +- gas/config/tc-aarch64.c | 8 ++++---- gas/config/tc-arm.c | 8 ++++---- gas/config/tc-nds32.c | 6 +++--- gas/config/xtensa-relax.c | 2 +- gas/stabs.c | 2 +- 8 files changed, 31 insertions(+), 16 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index e8bf967233..f9082da713 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,17 @@ +2016-03-28 Trevor Saunders + + * config/obj-elf.c (obj_elf_section_name): Return const char *. + * config/obj-elf.h (obj_elf_section_name): Adjust. + * config/tc-aarch64.c (aarch64_parse_features): Likewise. + (aarch64_parse_cpu): Likewise. + (aarch64_parse_arch): Likewise. + * config/tc-arm.c (arm_parse_extension): Likewise. + (arm_parse_cpu): Likewise. + (arm_parse_arch): Likewise. + * config/tc-nds32.c: Likewise. + * config/xtensa-relax.c (parse_special_fn): Likewise. + * stabs.c (generate_asm_file): Likewise. + 2016-03-25 Trevor Saunders * config/tc-cr16.c (cr16_assemble): New function. diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index c7a4ee410f..40c6e35274 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -918,7 +918,7 @@ obj_elf_section_word (char *str, size_t len, int *type) } /* Get name of section. */ -char * +const char * obj_elf_section_name (void) { char *name; @@ -984,7 +984,8 @@ obj_elf_section_name (void) void obj_elf_section (int push) { - char *name, *group_name, *beg; + const char *name, *group_name; + char *beg; int type, dummy; bfd_vma attr; int entsize; diff --git a/gas/config/obj-elf.h b/gas/config/obj-elf.h index 257d877831..02b3f7477e 100644 --- a/gas/config/obj-elf.h +++ b/gas/config/obj-elf.h @@ -155,7 +155,7 @@ extern void elf_file_symbol (const char *, int); extern void obj_elf_section_change_hook (void); extern void obj_elf_section (int); -extern char * obj_elf_section_name (void); +extern const char * obj_elf_section_name (void); extern void obj_elf_previous (int); extern void obj_elf_version (int); extern void obj_elf_common (int); diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 64a732b829..5c60dd8ab3 100644 --- a/gas/config/tc-aarch64.c +++ b/gas/config/tc-aarch64.c @@ -7830,7 +7830,7 @@ struct aarch64_long_option_table }; static int -aarch64_parse_features (char *str, const aarch64_feature_set **opt_p, +aarch64_parse_features (const char *str, const aarch64_feature_set **opt_p, bfd_boolean ext_only) { /* We insist on extensions being added before being removed. We achieve @@ -7847,7 +7847,7 @@ aarch64_parse_features (char *str, const aarch64_feature_set **opt_p, while (str != NULL && *str != 0) { const struct aarch64_option_cpu_value_table *opt; - char *ext = NULL; + const char *ext = NULL; int optlen; if (!ext_only) @@ -7920,7 +7920,7 @@ static int aarch64_parse_cpu (char *str) { const struct aarch64_cpu_option_table *opt; - char *ext = strchr (str, '+'); + const char *ext = strchr (str, '+'); size_t optlen; if (ext != NULL) @@ -7952,7 +7952,7 @@ static int aarch64_parse_arch (char *str) { const struct aarch64_arch_option_table *opt; - char *ext = strchr (str, '+'); + const char *ext = strchr (str, '+'); size_t optlen; if (ext != NULL) diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c index 4cc808d18d..eb842d510e 100644 --- a/gas/config/tc-arm.c +++ b/gas/config/tc-arm.c @@ -25586,7 +25586,7 @@ struct arm_long_option_table }; static bfd_boolean -arm_parse_extension (char *str, const arm_feature_set **opt_p) +arm_parse_extension (const char *str, const arm_feature_set **opt_p) { arm_feature_set *ext_set = (arm_feature_set *) xmalloc (sizeof (arm_feature_set)); @@ -25606,7 +25606,7 @@ arm_parse_extension (char *str, const arm_feature_set **opt_p) while (str != NULL && *str != 0) { - char *ext; + const char *ext; size_t len; if (*str != '+') @@ -25712,7 +25712,7 @@ static bfd_boolean arm_parse_cpu (char *str) { const struct arm_cpu_option_table *opt; - char *ext = strchr (str, '+'); + const char *ext = strchr (str, '+'); size_t len; if (ext != NULL) @@ -25762,7 +25762,7 @@ static bfd_boolean arm_parse_arch (char *str) { const struct arm_arch_option_table *opt; - char *ext = strchr (str, '+'); + const char *ext = strchr (str, '+'); size_t len; if (ext != NULL) diff --git a/gas/config/tc-nds32.c b/gas/config/tc-nds32.c index 66b8136346..90b4d27165 100644 --- a/gas/config/tc-nds32.c +++ b/gas/config/tc-nds32.c @@ -2986,7 +2986,7 @@ nds32_init_nds32_pseudo_opcodes (void) } static struct nds32_pseudo_opcode * -nds32_lookup_pseudo_opcode (char *str) +nds32_lookup_pseudo_opcode (const char *str) { int i = 0; /* Assume pseudo-opcode are less than 16-char in length. */ @@ -4138,7 +4138,7 @@ nds32_elf_save_pseudo_pattern (fixS* fixP, struct nds32_opcode *opcode, /* Check X_md to transform relocation. */ static fixS* -nds32_elf_record_fixup_exp (fragS *fragP, char *str, +nds32_elf_record_fixup_exp (fragS *fragP, const char *str, const struct nds32_field *fld, expressionS *pexp, char* out, struct nds32_asm_insn *insn) @@ -5102,7 +5102,7 @@ restore: /* Check instruction if it can be used for the baseline. */ static bfd_boolean -nds32_check_insn_available (struct nds32_asm_insn insn, char *str) +nds32_check_insn_available (struct nds32_asm_insn insn, const char *str) { int attr = insn.attr & ATTR_ALL; static int baseline_isa = 0; diff --git a/gas/config/xtensa-relax.c b/gas/config/xtensa-relax.c index a67fbe60bf..3adbf2aa60 100644 --- a/gas/config/xtensa-relax.c +++ b/gas/config/xtensa-relax.c @@ -1024,7 +1024,7 @@ parse_special_fn (const char *name, const char **fn_name_p, const char **arg_name_p) { - char *p_start; + const char *p_start; const char *p_end; p_start = strchr (name, '('); diff --git a/gas/stabs.c b/gas/stabs.c index c489af0962..8d54f7373c 100644 --- a/gas/stabs.c +++ b/gas/stabs.c @@ -545,7 +545,7 @@ generate_asm_file (int type, const char *file) while (tmp < file_endp) { - char *bslash = strchr (tmp, '\\'); + const char *bslash = strchr (tmp, '\\'); size_t len = (bslash) ? (size_t) (bslash - tmp + 1) : strlen (tmp); /* Double all backslashes, since demand_copy_C_string (used by -- 2.34.1