Skip to content

Commit d24a60f

Browse files
committed
gas various other const pointer changes
This removes a bunch of casts involving const pointers, in some cases by making variables const pointers so a cast is not needed. In a couple of places the cast hid errors with "&array" written rather than "array", see iq2000_macro_defs and s_pru_align. tc-xgate.c cmp_opcode is changed to be the standard qsort predicate to avoid a function cast.
1 parent de8acd2 commit d24a60f

File tree

16 files changed

+82
-87
lines changed

16 files changed

+82
-87
lines changed

gas/config/kvx-parse.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ has_relocation_of_size (const struct kvx_reloc **relocs)
6868
if (!relocs)
6969
return 0;
7070

71-
struct kvx_reloc **relocs_it = (struct kvx_reloc **) relocs;
71+
const struct kvx_reloc **relocs_it = relocs;
7272
int has_only_one_p = relocs[0] && !relocs[1];
7373

7474
while (*relocs_it)
@@ -101,15 +101,13 @@ has_relocation_of_size (const struct kvx_reloc **relocs)
101101
return 0;
102102
}
103103

104-
struct pseudo_func *
105-
kvx_get_pseudo_func2 (symbolS * sym, struct kvx_reloc **relocs);
106-
struct pseudo_func *
107-
kvx_get_pseudo_func2 (symbolS *sym, struct kvx_reloc **relocs)
104+
static struct pseudo_func *
105+
kvx_get_pseudo_func2 (symbolS *sym, const struct kvx_reloc **relocs)
108106
{
109107
if (!relocs)
110108
return NULL;
111109

112-
struct kvx_reloc **relocs_it = (struct kvx_reloc **) relocs;
110+
const struct kvx_reloc **relocs_it = relocs;
113111

114112
for (int i = 0; i < 26; i++)
115113
{

gas/config/obj-elf.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -942,13 +942,12 @@ obj_elf_parse_section_letters (char *str, size_t len,
942942
if (ISDIGIT (*str))
943943
{
944944
char * end;
945-
struct elf_backend_data *bed;
945+
const struct elf_backend_data *bed;
946946
bfd_vma numeric_flags = strtoul (str, &end, 0);
947947

948948
attr |= numeric_flags;
949949

950-
bed = (struct elf_backend_data *)
951-
get_elf_backend_data (stdoutput);
950+
bed = get_elf_backend_data (stdoutput);
952951

953952
if (bed->elf_osabi == ELFOSABI_NONE
954953
|| bed->elf_osabi == ELFOSABI_STANDALONE

gas/config/tc-alpha.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2180,7 +2180,7 @@ emit_ir_load (const expressionS *tok,
21802180
basereg = tok[2].X_add_number;
21812181

21822182
lituse = load_expression (tok[0].X_add_number, &tok[1],
2183-
&basereg, &newtok[1], (const char *) opname);
2183+
&basereg, &newtok[1], opname);
21842184

21852185
if (basereg == alpha_gp_register &&
21862186
(symlen > 4 && strcmp (&symname [symlen - 4], "..lk") == 0))
@@ -2189,7 +2189,7 @@ emit_ir_load (const expressionS *tok,
21892189
newtok[0] = tok[0];
21902190
set_tok_preg (newtok[2], basereg);
21912191

2192-
assemble_tokens_to_insn ((const char *) opname, newtok, 3, &insn);
2192+
assemble_tokens_to_insn (opname, newtok, 3, &insn);
21932193

21942194
if (lituse)
21952195
{
@@ -2227,7 +2227,7 @@ emit_loadstore (const expressionS *tok,
22272227
as_bad (_("macro requires $at register while noat in effect"));
22282228

22292229
lituse = load_expression (AXP_REG_AT, &tok[1],
2230-
&basereg, &newtok[1], (const char *) opname);
2230+
&basereg, &newtok[1], opname);
22312231
}
22322232
else
22332233
{
@@ -2238,7 +2238,7 @@ emit_loadstore (const expressionS *tok,
22382238
newtok[0] = tok[0];
22392239
set_tok_preg (newtok[2], basereg);
22402240

2241-
assemble_tokens_to_insn ((const char *) opname, newtok, 3, &insn);
2241+
assemble_tokens_to_insn (opname, newtok, 3, &insn);
22422242

22432243
if (lituse)
22442244
{
@@ -2684,7 +2684,7 @@ emit_division (const expressionS *tok,
26842684
}
26852685
}
26862686

2687-
sym = symbol_find_or_make ((const char *) symname);
2687+
sym = symbol_find_or_make (symname);
26882688

26892689
set_tok_reg (newtok[0], AXP_REG_AT);
26902690
set_tok_sym (newtok[1], sym, 0);
@@ -2737,7 +2737,7 @@ emit_division (const expressionS *tok,
27372737
else
27382738
rr = regno (tok[2].X_add_number);
27392739

2740-
sym = symbol_find_or_make ((const char *) symname);
2740+
sym = symbol_find_or_make (symname);
27412741

27422742
/* Move the operands into the right place. */
27432743
if (yr == AXP_REG_T10 && xr == AXP_REG_T11)
@@ -2818,7 +2818,7 @@ emit_jsrjmp (const expressionS *tok,
28182818
int ntok,
28192819
const void * vopname)
28202820
{
2821-
const char *opname = (const char *) vopname;
2821+
const char *opname = vopname;
28222822
struct alpha_insn insn;
28232823
expressionS newtok[3];
28242824
int r, tokidx = 0;
@@ -2914,7 +2914,7 @@ emit_retjcr (const expressionS *tok,
29142914
int ntok,
29152915
const void * vopname)
29162916
{
2917-
const char *opname = (const char *) vopname;
2917+
const char *opname = vopname;
29182918
expressionS newtok[3];
29192919
int r, tokidx = 0;
29202920

gas/config/tc-arc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3659,7 +3659,7 @@ find_reloc (const char *name,
36593659
if (!nflg)
36603660
continue;
36613661
found_flag = false;
3662-
unsigned * psflg = (unsigned *)r->flags;
3662+
const unsigned *psflg = r->flags;
36633663
do
36643664
{
36653665
tmp = false;
@@ -4673,7 +4673,7 @@ arc_extinsn (int ignore ATTRIBUTE_UNUSED)
46734673
as_warn ("%s", errmsg);
46744674

46754675
/* Insert the extension instruction. */
4676-
arc_insert_opcode ((const struct arc_opcode *) arc_ext_opcodes);
4676+
arc_insert_opcode (arc_ext_opcodes);
46774677

46784678
create_extinst_section (&einsn);
46794679
}

gas/config/tc-d10v.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ void
275275
md_begin (void)
276276
{
277277
const char *prev_name = "";
278-
struct d10v_opcode *opcode;
278+
const struct d10v_opcode *opcode;
279279
d10v_hash = str_htab_create ();
280280

281281
/* Insert unique names into hash table. The D10v instruction set
@@ -325,7 +325,7 @@ postfix (char *p)
325325
}
326326

327327
static bfd_reloc_code_real_type
328-
get_reloc (struct d10v_operand *op)
328+
get_reloc (const struct d10v_operand *op)
329329
{
330330
int bits = op->bits;
331331

@@ -564,7 +564,7 @@ build_insn (struct d10v_opcode *opcode,
564564
else
565565
{
566566
fixups->fix[fixups->fc].reloc =
567-
get_reloc ((struct d10v_operand *) &d10v_operands[opcode->operands[i]]);
567+
get_reloc (&d10v_operands[opcode->operands[i]]);
568568

569569
/* Check that an immediate was passed to ops that expect one. */
570570
if ((flags & OPERAND_NUM)
@@ -1521,7 +1521,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
15211521
}
15221522
else
15231523
fixP->fx_r_type =
1524-
get_reloc ((struct d10v_operand *) &d10v_operands[op_type]);
1524+
get_reloc (&d10v_operands[op_type]);
15251525
}
15261526

15271527
/* Fetch the instruction, insert the fully resolved operand

gas/config/tc-iq2000.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -198,29 +198,29 @@ static const char * li_expn = "\n\
198198

199199
static iq2000_macro_defs_s iq2000_macro_defs[] =
200200
{
201-
{"abs", (const char **) & abs_expn, (const char **) & abs_args},
202-
{"la", (const char **) & la_expn, (const char **) & la_args},
203-
{"bge", (const char **) & bge_expn, (const char **) & bxx_args},
204-
{"bgeu", (const char **) & bgeu_expn, (const char **) & bxx_args},
205-
{"bgt", (const char **) & bgt_expn, (const char **) & bxx_args},
206-
{"bgtu", (const char **) & bgtu_expn, (const char **) & bxx_args},
207-
{"ble", (const char **) & ble_expn, (const char **) & bxx_args},
208-
{"bleu", (const char **) & bleu_expn, (const char **) & bxx_args},
209-
{"blt", (const char **) & blt_expn, (const char **) & bxx_args},
210-
{"bltu", (const char **) & bltu_expn, (const char **) & bxx_args},
211-
{"sge", (const char **) & sge_expn, (const char **) & sxx_args},
212-
{"sgeu", (const char **) & sgeu_expn, (const char **) & sxx_args},
213-
{"sle", (const char **) & sle_expn, (const char **) & sxx_args},
214-
{"sleu", (const char **) & sleu_expn, (const char **) & sxx_args},
215-
{"sgt", (const char **) & sgt_expn, (const char **) & sxx_args},
216-
{"sgtu", (const char **) & sgtu_expn, (const char **) & sxx_args},
217-
{"seq", (const char **) & seq_expn, (const char **) & sxx_args},
218-
{"sne", (const char **) & sne_expn, (const char **) & sxx_args},
219-
{"neg", (const char **) & neg_expn, (const char **) & neg_args},
220-
{"negu", (const char **) & negu_expn, (const char **) & neg_args},
221-
{"li", (const char **) & li_expn, (const char **) & li_args},
222-
{"ori32", (const char **) & ori32_expn, (const char **) & ai32_args},
223-
{"andi32",(const char **) & andi32_expn,(const char **) & ai32_args},
201+
{"abs", &abs_expn, abs_args},
202+
{"la", &la_expn, la_args},
203+
{"bge", &bge_expn, bxx_args},
204+
{"bgeu", &bgeu_expn, bxx_args},
205+
{"bgt", &bgt_expn, bxx_args},
206+
{"bgtu", &bgtu_expn, bxx_args},
207+
{"ble", &ble_expn, bxx_args},
208+
{"bleu", &bleu_expn, bxx_args},
209+
{"blt", &blt_expn, bxx_args},
210+
{"bltu", &bltu_expn, bxx_args},
211+
{"sge", &sge_expn, sxx_args},
212+
{"sgeu", &sgeu_expn, sxx_args},
213+
{"sle", &sle_expn, sxx_args},
214+
{"sleu", &sleu_expn, sxx_args},
215+
{"sgt", &sgt_expn, sxx_args},
216+
{"sgtu", &sgtu_expn, sxx_args},
217+
{"seq", &seq_expn, sxx_args},
218+
{"sne", &sne_expn, sxx_args},
219+
{"neg", &neg_expn, neg_args},
220+
{"negu", &negu_expn, neg_args},
221+
{"li", &li_expn, li_args},
222+
{"ori32", &ori32_expn, ai32_args},
223+
{"andi32", &andi32_expn, ai32_args},
224224
};
225225

226226
static void

gas/config/tc-kvx.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,7 +700,7 @@ assemble_insn (const struct kvxopc * opcode, struct token_list *tok, struct kvxi
700700
insn->immx1 = NOIMMX;
701701

702702
struct token_list *tok_ = tok;
703-
struct kvx_operand **format = (struct kvx_operand **) opcode->format;
703+
struct kvx_operand *const *format = opcode->format;
704704

705705
while (tok_)
706706
{
@@ -1441,8 +1441,8 @@ kvx_set_cpu (void)
14411441
static int
14421442
kvxop_compar (const void *a, const void *b)
14431443
{
1444-
const struct kvxopc *opa = (const struct kvxopc *) a;
1445-
const struct kvxopc *opb = (const struct kvxopc *) b;
1444+
const struct kvxopc *opa = a;
1445+
const struct kvxopc *opb = b;
14461446
int res = strcmp (opa->as_op, opb->as_op);
14471447

14481448
if (res)

gas/config/tc-metag.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ parse_gp_reg (const char *name)
267267

268268
entry.name = name;
269269

270-
reg = (const metag_reg *) htab_find (reg_htab, &entry);
270+
reg = htab_find (reg_htab, &entry);
271271

272272
return reg;
273273
}
@@ -4112,7 +4112,7 @@ __parse_dsp_reg (const char *line, const metag_reg **reg, htab_t dsp_regtab)
41124112
name[len] = '\0';
41134113
entry.name = name;
41144114

4115-
_reg = (const metag_reg *) htab_find (dsp_regtab, &entry);
4115+
_reg = htab_find (dsp_regtab, &entry);
41164116
if (!_reg)
41174117
return NULL;
41184118

@@ -6003,7 +6003,7 @@ parse_split_condition (const char *line, metag_insn *insn)
60036003

60046004
entry.name = buf;
60056005

6006-
scond = (const split_condition *) htab_find (scond_htab, &entry);
6006+
scond = htab_find (scond_htab, &entry);
60076007

60086008
if (!scond)
60096009
return NULL;
@@ -6324,16 +6324,15 @@ create_mnemonic_htab (void)
63246324
for (i = 0; i < num_templates; i++)
63256325
{
63266326
const insn_template *template = &metag_optab[i];
6327-
insn_templates **slot = NULL;
6327+
void **slot;
63286328
insn_templates *new_entry;
63296329

63306330
new_entry = XNEW (insn_templates);
63316331

63326332
new_entry->template = template;
63336333
new_entry->next = NULL;
63346334

6335-
slot = (insn_templates **) htab_find_slot (mnemonic_htab, new_entry,
6336-
INSERT);
6335+
slot = htab_find_slot (mnemonic_htab, new_entry, INSERT);
63376336

63386337
if (*slot)
63396338
{
@@ -6355,7 +6354,7 @@ create_mnemonic_htab (void)
63556354
static hashval_t
63566355
hash_regs (const void *p)
63576356
{
6358-
metag_reg *rp = (metag_reg *)p;
6357+
const metag_reg *rp = p;
63596358
char buf[MAX_REG_LEN];
63606359

63616360
strupper (buf, rp->name);
@@ -6367,8 +6366,8 @@ hash_regs (const void *p)
63676366
static int
63686367
eq_regs (const void *a, const void *b)
63696368
{
6370-
metag_reg *ra = (metag_reg *)a;
6371-
metag_reg *rb = (metag_reg *)b;
6369+
const metag_reg *ra = a;
6370+
const metag_reg *rb = b;
63726371
return strcasecmp (ra->name, rb->name) == 0;
63736372
}
63746373

gas/config/tc-nds32.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5209,7 +5209,7 @@ static struct nds32_relax_hint_table relax_ls_table[] =
52095209
elimination itself or not, we have to return the next instruction range. */
52105210

52115211
static int
5212-
nds32_elf_sethi_range (struct nds32_relocs_pattern *pattern)
5212+
nds32_elf_sethi_range (const struct nds32_relocs_pattern *pattern)
52135213
{
52145214
int range = 0;
52155215
while (pattern)
@@ -5658,12 +5658,12 @@ static struct nds32_hint_map hint_map [] =
56585658
/* Find the relaxation pattern according to instructions. */
56595659

56605660
static bool
5661-
nds32_find_reloc_table (struct nds32_relocs_pattern *relocs_pattern,
5661+
nds32_find_reloc_table (const struct nds32_relocs_pattern *relocs_pattern,
56625662
struct nds32_relax_hint_table *hint_info)
56635663
{
56645664
unsigned int opcode, seq_size;
56655665
enum nds32_br_range range;
5666-
struct nds32_relocs_pattern *pattern, *hi_pattern = NULL;
5666+
const struct nds32_relocs_pattern *pattern, *hi_pattern = NULL;
56675667
const char *opc = NULL;
56685668
relax_info_t *relax_info = NULL;
56695669
nds32_relax_fixup_info_t *fixup_info, *hint_fixup;
@@ -5928,9 +5928,8 @@ nds32_match_hint_insn (struct nds32_opcode *opcode, uint32_t seq)
59285928
static void
59295929
nds32_elf_append_relax_relocs (const char *key, const void *value)
59305930
{
5931-
struct nds32_relocs_pattern *relocs_pattern =
5932-
(struct nds32_relocs_pattern *) value;
5933-
struct nds32_relocs_pattern *pattern_temp, *pattern_now;
5931+
const struct nds32_relocs_pattern *relocs_pattern = value;
5932+
const struct nds32_relocs_pattern *pattern_temp, *pattern_now;
59345933
symbolS *sym, *hi_sym = NULL;
59355934
expressionS exp;
59365935
fragS *fragP;
@@ -6265,7 +6264,7 @@ static int
62656264
nds32_elf_append_relax_relocs_traverse (void **slot, void *arg ATTRIBUTE_UNUSED)
62666265
{
62676266
string_tuple_t *tuple = *((string_tuple_t **) slot);
6268-
nds32_elf_append_relax_relocs (tuple->key, (void *) tuple->value);
6267+
nds32_elf_append_relax_relocs (tuple->key, (const void *) tuple->value);
62696268
return 1;
62706269
}
62716270

gas/config/tc-pru.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,10 +341,10 @@ s_pru_align (int ignore ATTRIBUTE_UNUSED)
341341
{
342342
input_line_pointer++;
343343
fill = get_absolute_expression ();
344-
pfill = (const char *) &fill;
344+
pfill = &fill;
345345
}
346346
else if (subseg_text_p (now_seg))
347-
pfill = (const char *) &nop;
347+
pfill = nop;
348348
else
349349
{
350350
pfill = NULL;

0 commit comments

Comments
 (0)