diff options
44 files changed, 190 insertions, 224 deletions
diff --git a/gas/atof-generic.c b/gas/atof-generic.c index 944f209..59d1110 100644 --- a/gas/atof-generic.c +++ b/gas/atof-generic.c @@ -351,7 +351,6 @@ atof_generic (/* return pointer to just AFTER number we read. */ unsigned int more_than_enough_bits_for_digits; unsigned int more_than_enough_littlenums_for_digits; unsigned int size_of_digits_in_littlenums; - unsigned int size_of_digits_in_chars; FLONUM_TYPE power_of_10_flonum; FLONUM_TYPE digits_flonum; @@ -375,11 +374,8 @@ atof_generic (/* return pointer to just AFTER number we read. */ number_of_digits_to_use = number_of_digits_available; } - /* Cast these to SIGNED LONG first, otherwise, on systems with - LONG wider than INT (such as Alpha OSF/1), unsignedness may - cause unexpected results. */ - decimal_exponent += ((long) number_of_digits_before_decimal - - (long) number_of_digits_to_use); + decimal_exponent += number_of_digits_before_decimal; + decimal_exponent -= number_of_digits_to_use; more_than_enough_bits_for_digits = (number_of_digits_to_use * 3321928 / 1000000 + 1); @@ -398,13 +394,9 @@ atof_generic (/* return pointer to just AFTER number we read. */ object). */ size_of_digits_in_littlenums = more_than_enough_littlenums_for_digits; - size_of_digits_in_chars = size_of_digits_in_littlenums - * sizeof (LITTLENUM_TYPE); - digits_binary_low = (LITTLENUM_TYPE *) - xmalloc (size_of_digits_in_chars); - - memset ((char *) digits_binary_low, '\0', size_of_digits_in_chars); + digits_binary_low = xcalloc (size_of_digits_in_littlenums, + sizeof (LITTLENUM_TYPE)); /* Digits_binary_low[] is allocated and zeroed. */ @@ -514,13 +506,13 @@ atof_generic (/* return pointer to just AFTER number we read. */ /* From now on: the decimal exponent is > 0. Its sign is separate. */ - size_of_power_in_chars = size_of_power_in_littlenums - * sizeof (LITTLENUM_TYPE) + 2; + size_of_power_in_chars = (size_of_power_in_littlenums + * sizeof (LITTLENUM_TYPE)) + 2; - power_binary_low = (LITTLENUM_TYPE *) xmalloc (size_of_power_in_chars); - temporary_binary_low = (LITTLENUM_TYPE *) xmalloc (size_of_power_in_chars); + power_binary_low = xmalloc (size_of_power_in_chars); + temporary_binary_low = xmalloc (size_of_power_in_chars); - memset ((char *) power_binary_low, '\0', size_of_power_in_chars); + memset (power_binary_low, '\0', size_of_power_in_chars); *power_binary_low = 1; power_of_10_flonum.exponent = 0; power_of_10_flonum.low = power_binary_low; @@ -632,8 +624,7 @@ atof_generic (/* return pointer to just AFTER number we read. */ #ifdef TRACE static void -flonum_print (f) - const FLONUM_TYPE *f; +flonum_print (const FLONUM_TYPE *f) { LITTLENUM_TYPE *lp; char littlenum_format[10]; @@ -504,7 +504,7 @@ ignore_input (void) else { if (s[-1] != '.') - return (current_cframe != NULL) && (current_cframe->ignoring); + return current_cframe != NULL && current_cframe->ignoring; } /* We cannot ignore certain pseudo ops. */ @@ -526,15 +526,14 @@ ignore_input (void) break; } - return (current_cframe != NULL) && (current_cframe->ignoring); + return current_cframe != NULL && current_cframe->ignoring; } static void initialize_cframe (struct conditional_frame *cframe) { memset (cframe, 0, sizeof (*cframe)); - cframe->if_file_line.file - = as_where (&cframe->if_file_line.line); + cframe->if_file_line.file = as_where (&cframe->if_file_line.line); cframe->previous_cframe = current_cframe; cframe->dead_tree = current_cframe != NULL && current_cframe->ignoring; cframe->macro_nest = macro_nest; diff --git a/gas/config/atof-ieee.c b/gas/config/atof-ieee.c index 92b9f74..a1c3ca2 100644 --- a/gas/config/atof-ieee.c +++ b/gas/config/atof-ieee.c @@ -147,12 +147,12 @@ make_invalid_floating_point_number (LITTLENUM_TYPE *words) { as_bad (_("cannot create floating-point number")); /* Zero the leftmost bit. */ - words[0] = (LITTLENUM_TYPE) ((unsigned) -1) >> 1; - words[1] = (LITTLENUM_TYPE) -1; - words[2] = (LITTLENUM_TYPE) -1; - words[3] = (LITTLENUM_TYPE) -1; - words[4] = (LITTLENUM_TYPE) -1; - words[5] = (LITTLENUM_TYPE) -1; + words[0] = (LITTLENUM_TYPE) -1 >> 1; + words[1] = -1; + words[2] = -1; + words[3] = -1; + words[4] = -1; + words[5] = -1; } /* Build a floating point constant at str into a IEEE floating @@ -283,7 +283,7 @@ atof_ieee (char *str, /* Text to convert to binary. */ default: make_invalid_floating_point_number (words); - return (NULL); + return NULL; } return atof_ieee_detail (str, precision, exponent_bits, words, NULL); diff --git a/gas/config/kvx-parse.c b/gas/config/kvx-parse.c index 06b21c9..ea96f3d 100644 --- a/gas/config/kvx-parse.c +++ b/gas/config/kvx-parse.c @@ -458,7 +458,7 @@ get_token_class (struct token_s *token, struct token_classes *classes, int insn_ { int cur = 0; int found = 0; - int tok_sz = token->end - token->begin; + size_t tok_sz = token->end - token->begin; char *tok = token->insn + token->begin; expressionS exp; @@ -557,7 +557,7 @@ get_token_class (struct token_s *token, struct token_classes *classes, int insn_ for (int i = 0; !found && i < class[cur].sz; ++i) { const char *ref = class[cur].class_values[i]; - found = ((long) strlen (ref) == tok_sz) && !strncmp (tok, ref, tok_sz); + found = (strlen (ref) == tok_sz) && !strncmp (tok, ref, tok_sz); token->val = i; } @@ -669,7 +669,7 @@ static struct token_list * create_token (struct token_s tok, int len, int loc) { struct token_list *tl = calloc (1, sizeof *tl); - int tok_sz = tok.end - tok.begin; + size_t tok_sz = tok.end - tok.begin; tl->tok = calloc (tok_sz + 1, sizeof (char)); memcpy (tl->tok, tok.insn + tok.begin, tok_sz * sizeof (char)); tl->val = tok.val; diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c index 6ca2433..03b6c24 100644 --- a/gas/config/obj-elf.c +++ b/gas/config/obj-elf.c @@ -1228,7 +1228,7 @@ obj_elf_section (int push) if (push && ISDIGIT (*input_line_pointer)) { /* .pushsection has an optional subsection. */ - new_subsection = (subsegT) get_absolute_expression (); + new_subsection = get_absolute_expression (); SKIP_WHITESPACE (); @@ -1459,7 +1459,7 @@ obj_elf_section (int push) char *t = input_line_pointer; match.sh_info = strtoul (input_line_pointer, &input_line_pointer, 0); - if (match.sh_info == (unsigned int) -1) + if (match.sh_info == -1u) { as_warn (_("unsupported mbind section info: %s"), t); match.sh_info = 0; @@ -1496,8 +1496,7 @@ obj_elf_section (int push) errno = 0; id = strtoul (input_line_pointer, &input_line_pointer, 0); - overflow = (id == (unsigned long) -1 - && errno == ERANGE); + overflow = id == -1ul && errno == ERANGE; } else { @@ -1506,7 +1505,7 @@ obj_elf_section (int push) (const char **) &input_line_pointer, 0); overflow = id == ~(bfd_vma) 0; } - if (overflow || id > (unsigned int) -1) + if (overflow || id > -1u) { char *linefeed, saved_char = 0; if ((linefeed = strchr (t, '\n')) != NULL) diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c index 17bb697..01e76c5 100644 --- a/gas/config/obj-macho.c +++ b/gas/config/obj-macho.c @@ -531,8 +531,8 @@ obj_mach_o_zerofill (int ignore ATTRIBUTE_UNUSED) SKIP_WHITESPACE (); if (*input_line_pointer == ',') { - align = (unsigned int) parse_align (0); - if (align == (unsigned int) -1) + align = parse_align (0); + if (align == -1u) { as_warn (_("align value not recognized, using size")); align = size; @@ -1800,7 +1800,7 @@ obj_mach_o_set_indirect_symbols (bfd *abfd, asection *sec, entry size, we're dead ... */ gas_assert (eltsiz != 0); - ncalc = (unsigned int) (sect_size / eltsiz); + ncalc = sect_size / eltsiz; if (nactual != ncalc) as_bad (_("the number of .indirect_symbols defined in section %s" " does not match the number expected (%d defined, %d" diff --git a/gas/config/tc-csky.c b/gas/config/tc-csky.c index cfd0b37..dc8ee74 100644 --- a/gas/config/tc-csky.c +++ b/gas/config/tc-csky.c @@ -5596,25 +5596,25 @@ md_apply_fix (fixS *fixP, case BFD_RELOC_CKCORE_PCREL_IMM8BY4: case BFD_RELOC_CKCORE_PCREL_IMM10BY4: case BFD_RELOC_CKCORE_PCREL_IMM16BY4: - max = (offsetT) howto->dst_mask; + max = howto->dst_mask; min = 0; break; /* lrw16. */ case BFD_RELOC_CKCORE_PCREL_IMM7BY4: if (do_extend_lrw) - max = (offsetT)((1 << (howto->bitsize + 1)) - 2); + max = ((valueT) 1 << (howto->bitsize + 1)) - 2; else - max = (offsetT)((1 << howto->bitsize) - 1); + max = ((valueT) 1 << howto->bitsize) - 1; min = 0; break; /* flrws, flrwd: the offset bits are divided in two parts. */ case BFD_RELOC_CKCORE_PCREL_FLRW_IMM8BY4: - max = (offsetT)((1 << howto->bitsize) - 1); + max = ((valueT) 1 << howto->bitsize) - 1; min = 0; break; /* Offset is signed. */ default: - max = (offsetT)(howto->dst_mask >> 1); + max = howto->dst_mask >> 1; min = - max - 1; issigned = 1; } @@ -5630,7 +5630,7 @@ md_apply_fix (fixS *fixP, if (do_extend_lrw && (opcode & 0xfc00) == CSKYV2_INST_LRW16) val &= 0xff; else - val &= issigned ? (offsetT)(howto->dst_mask) : max; + val &= issigned ? (offsetT) howto->dst_mask : max; if (fixP->fx_r_type == BFD_RELOC_CKCORE_PCREL_BLOOP_IMM4BY4) val = (val & 0xf) << 12; diff --git a/gas/config/tc-dlx.c b/gas/config/tc-dlx.c index 08948d2..69c8f49 100644 --- a/gas/config/tc-dlx.c +++ b/gas/config/tc-dlx.c @@ -539,7 +539,7 @@ static char * fix_ld_st_operand (unsigned long opcode, char* str) { /* Check the opcode. */ - switch ((int) opcode) + switch (opcode) { case LBOP: case LBUOP: diff --git a/gas/config/tc-hppa.c b/gas/config/tc-hppa.c index a22d094..744613f 100644 --- a/gas/config/tc-hppa.c +++ b/gas/config/tc-hppa.c @@ -1562,7 +1562,7 @@ md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, if (fragP->fr_type == rs_machine_dependent) { - switch ((int) fragP->fr_subtype) + switch (fragP->fr_subtype) { case 0: fragP->fr_type = rs_fill; @@ -6615,7 +6615,7 @@ pa_type_args (symbolS *symbolP, int is_export) than BFD understands. This is how we get this information to the SOM BFD backend. */ #ifdef obj_set_symbol_type - obj_set_symbol_type (bfdsym, (int) type); + obj_set_symbol_type (bfdsym, type); #else (void) type; #endif @@ -7548,7 +7548,6 @@ pa_subspace (int create_new) /* Now that all the flags are set, update an existing subspace, or create a new one. */ if (ssd) - current_subspace = update_subspace (space, ss_name, loadable, code_only, comdat, common, dup_common, sort, zero, access_ctr, @@ -7973,7 +7972,7 @@ pa_subsegment_to_subspace (asection *seg, subsegT subseg) for (subspace_chain = space_chain->sd_subspaces; subspace_chain; subspace_chain = subspace_chain->ssd_next) - if (subspace_chain->ssd_subseg == (int) subseg) + if (subspace_chain->ssd_subseg == subseg) return subspace_chain; } } @@ -8432,12 +8431,12 @@ hppa_force_relocation (struct fix *fixp) hppa_fixp = fixp->tc_fix_data; #ifdef OBJ_SOM - if (fixp->fx_r_type == (int) R_HPPA_ENTRY - || fixp->fx_r_type == (int) R_HPPA_EXIT - || fixp->fx_r_type == (int) R_HPPA_BEGIN_BRTAB - || fixp->fx_r_type == (int) R_HPPA_END_BRTAB - || fixp->fx_r_type == (int) R_HPPA_BEGIN_TRY - || fixp->fx_r_type == (int) R_HPPA_END_TRY + if (fixp->fx_r_type == R_HPPA_ENTRY + || fixp->fx_r_type == R_HPPA_EXIT + || fixp->fx_r_type == R_HPPA_BEGIN_BRTAB + || fixp->fx_r_type == R_HPPA_END_BRTAB + || fixp->fx_r_type == R_HPPA_BEGIN_TRY + || fixp->fx_r_type == R_HPPA_END_TRY || (fixp->fx_addsy != NULL && fixp->fx_subsy != NULL && (hppa_fixp->segment->flags & SEC_CODE) != 0)) return 1; diff --git a/gas/config/tc-ia64.c b/gas/config/tc-ia64.c index ac610b7..88f9563 100644 --- a/gas/config/tc-ia64.c +++ b/gas/config/tc-ia64.c @@ -741,7 +741,7 @@ typedef struct unw_rec_list { struct unw_rec_list *next; } unw_rec_list; -#define SLOT_NUM_NOT_SET (unsigned)-1 +#define SLOT_NUM_NOT_SET -1UL /* Linked list of saved prologue counts. A very poor implementation of a map from label numbers to prologue counts. */ @@ -1045,9 +1045,9 @@ obj_elf_vms_common (int ignore ATTRIBUTE_UNUSED) const char *sec_name; char *sym_name; char c; - offsetT size; - offsetT cur_size; - offsetT temp; + valueT size; + valueT cur_size; + valueT temp; symbolS *symbolP; segT current_seg = now_seg; subsegT current_subseg = now_subseg; @@ -1109,7 +1109,7 @@ obj_elf_vms_common (int ignore ATTRIBUTE_UNUSED) temp = get_absolute_expression (); size = temp; - size &= ((offsetT) 2 << (stdoutput->arch_info->bits_per_address - 1)) - 1; + size &= ((valueT) 2 << (stdoutput->arch_info->bits_per_address - 1)) - 1; if (temp != size) { as_warn (_("size (%ld) out of range, ignored"), (long) temp); @@ -1150,7 +1150,7 @@ obj_elf_vms_common (int ignore ATTRIBUTE_UNUSED) record_alignment (now_seg, log_align); cur_size = bfd_section_size (now_seg); - if ((int) size > cur_size) + if (size > cur_size) { char *pfrag = frag_var (rs_fill, 1, 1, 0, NULL, size - cur_size, NULL); *pfrag = 0; diff --git a/gas/config/tc-iq2000.c b/gas/config/tc-iq2000.c index 1a31e8e..76ff841 100644 --- a/gas/config/tc-iq2000.c +++ b/gas/config/tc-iq2000.c @@ -790,7 +790,7 @@ get_symbol (void) symbolS *p; c = get_symbol_name (&name); - p = (symbolS *) symbol_find_or_make (name); + p = symbol_find_or_make (name); (void) restore_line_pointer (c); return p; } diff --git a/gas/config/tc-kvx.c b/gas/config/tc-kvx.c index 59e2b29..b4ca25c 100644 --- a/gas/config/tc-kvx.c +++ b/gas/config/tc-kvx.c @@ -1021,7 +1021,7 @@ kvx_print_insn (struct kvxopc * op ATTRIBUTE_UNUSED) /* This is a hack which works because the Bundling is the same for all cores for now. */ - switch ((int) op->bundling) + switch (op->bundling) { case Bundling_kv3_v1_ALL: insn_type = "ALL "; @@ -1109,7 +1109,7 @@ kvx_reorder_bundle (struct kvxinsn *bundle_insn[], int bundle_insncnt) tag = -1, exu = -1; /* This is a hack. It works because all the Bundling are the same for all cores for now. */ - switch ((int) find_bundling (kvxinsn)) + switch (find_bundling (kvxinsn)) { case Bundling_kv3_v1_ALL: if (bundle_insncnt > 1) diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c index b620d47..7b53b6f 100644 --- a/gas/config/tc-loongarch.c +++ b/gas/config/tc-loongarch.c @@ -452,7 +452,7 @@ static hashval_t align_sec_sym_hash (const void *entry) { const align_sec_sym *e = entry; - return (hashval_t) (e->sec_id); + return e->sec_id; } static int diff --git a/gas/config/tc-m68k.c b/gas/config/tc-m68k.c index aa1354f..e5c8f5c 100644 --- a/gas/config/tc-m68k.c +++ b/gas/config/tc-m68k.c @@ -7333,7 +7333,7 @@ m68k_set_extension (char const *name, int allow_m, int silent) if (negated) not_current_architecture |= (ext->control_regs - ? *(unsigned *)ext->control_regs: ext->arch); + ? *ext->control_regs: ext->arch); else current_architecture |= ext->arch; return 1; diff --git a/gas/config/tc-microblaze.c b/gas/config/tc-microblaze.c index 5e0eaa2..055d9ee 100644 --- a/gas/config/tc-microblaze.c +++ b/gas/config/tc-microblaze.c @@ -484,7 +484,7 @@ parse_reg (char * s, unsigned * reg) } else as_bad (_("register expected, but saw '%.6s'"), s); - if ((int) tmpreg >= MIN_PVR_REGNUM && tmpreg <= MAX_PVR_REGNUM) + if (tmpreg - MIN_PVR_REGNUM <= MAX_PVR_REGNUM - MIN_PVR_REGNUM) *reg = REG_PVR + tmpreg; else { @@ -513,7 +513,7 @@ parse_reg (char * s, unsigned * reg) else as_bad (_("register expected, but saw '%.6s'"), s); - if ((int) tmpreg >= MIN_REGNUM && tmpreg <= MAX_REGNUM) + if (tmpreg - MIN_REGNUM <= MAX_REGNUM - MIN_REGNUM) *reg = tmpreg; else { @@ -550,7 +550,7 @@ parse_reg (char * s, unsigned * reg) else as_bad (_("register expected, but saw '%.6s'"), s); - if ((int)tmpreg >= MIN_REGNUM && tmpreg <= MAX_REGNUM) + if (tmpreg - MIN_REGNUM <= MAX_REGNUM - MIN_REGNUM) *reg = tmpreg; else { diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c index 8b648ae..9134cef 100644 --- a/gas/config/tc-mips.c +++ b/gas/config/tc-mips.c @@ -1135,8 +1135,7 @@ static bool mips_ignore_branch_isa; but it's not clear that it would actually improve performance. */ #define RELAX_BRANCH_ENCODE(at, pic, \ uncond, likely, link, toofar) \ - ((relax_substateT) \ - (0xc0000000 \ + ((0xc0000000 \ | ((at) & 0x1f) \ | ((pic) ? 0x20 : 0) \ | ((toofar) ? 0x40 : 0) \ @@ -16227,7 +16226,7 @@ get_symbol (void) symbolS *p; c = get_symbol_name (&name); - p = (symbolS *) symbol_find_or_make (name); + p = symbol_find_or_make (name); (void) restore_line_pointer (c); return p; } diff --git a/gas/config/tc-mmix.c b/gas/config/tc-mmix.c index 5ae158d..88b7bc4 100644 --- a/gas/config/tc-mmix.c +++ b/gas/config/tc-mmix.c @@ -2489,8 +2489,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT segment) case BFD_RELOC_MMIX_PUSHJ_STUBBABLE: /* If this fixup is out of range, punt to the linker to emit an error. This should only happen with -no-expand. */ - if (val < -(((offsetT) 1 << 19)/2) - || val >= ((offsetT) 1 << 19)/2 - 1 + if (val < -((1 << 19) / 2) + || val >= (1 << 19) / 2 - 1 || (val & 3) != 0) { if (warn_on_expansion) @@ -2513,8 +2513,8 @@ md_apply_fix (fixS *fixP, valueT *valP, segT segment) case BFD_RELOC_MMIX_JMP: /* If this fixup is out of range, punt to the linker to emit an error. This should only happen with -no-expand. */ - if (val < -(((offsetT) 1 << 27)/2) - || val >= ((offsetT) 1 << 27)/2 - 1 + if (val < -((1 << 27) / 2) + || val >= (1 << 27) / 2 - 1 || (val & 3) != 0) { if (warn_on_expansion) @@ -2773,7 +2773,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP) && (bfd_vma) val + 256 > lowest_data_loc && bfd_is_abs_section (addsec)) { - val -= (offsetT) lowest_data_loc; + val -= lowest_data_loc; addsy = section_symbol (data_section); } /* Likewise text section. */ @@ -2781,7 +2781,7 @@ tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixP) && (bfd_vma) val + 256 > lowest_text_loc && bfd_is_abs_section (addsec)) { - val -= (offsetT) lowest_text_loc; + val -= lowest_text_loc; addsy = section_symbol (text_section); } } @@ -3437,9 +3437,8 @@ mmix_md_relax_frag (segT seg, fragS *fragP, long stretch) if (fragP == seginfo->tc_segment_info_data.last_stubfrag) seginfo->tc_segment_info_data.nstubs = 0; - return - (mmix_relax_table[fragP->fr_subtype].rlx_length - - mmix_relax_table[prev_type].rlx_length); + return (mmix_relax_table[fragP->fr_subtype].rlx_length + - mmix_relax_table[prev_type].rlx_length); } case ENCODE_RELAX (STATE_PUSHJ, STATE_MAX): @@ -3634,7 +3633,7 @@ mmix_md_finish (void) if (! merge_gregs) continue; - osymval = (offsetT) S_GET_VALUE (symbolP); + osymval = S_GET_VALUE (symbolP); osymfrag = symbol_get_frag (symbolP); /* If the symbol isn't defined, we can't say that another symbol @@ -3725,7 +3724,7 @@ mmix_frob_file (void) } sym = fixP->fx_addsy; - offs = (offsetT) fixP->fx_offset; + offs = fixP->fx_offset; /* If the symbol is defined, then it must be resolved to a section symbol at this time, or else we don't know how to handle it. */ @@ -3748,7 +3747,7 @@ mmix_frob_file (void) && (bfd_vma) offs + 256 > lowest_data_loc && bfd_is_abs_section (S_GET_SEGMENT (sym))) { - offs -= (offsetT) lowest_data_loc; + offs -= lowest_data_loc; sym = section_symbol (data_section); } /* Likewise text section. */ @@ -3756,7 +3755,7 @@ mmix_frob_file (void) && (bfd_vma) offs + 256 > lowest_text_loc && bfd_is_abs_section (S_GET_SEGMENT (sym))) { - offs -= (offsetT) lowest_text_loc; + offs -= lowest_text_loc; sym = section_symbol (text_section); } diff --git a/gas/config/tc-mn10200.c b/gas/config/tc-mn10200.c index f57540e..210e9b0 100644 --- a/gas/config/tc-mn10200.c +++ b/gas/config/tc-mn10200.c @@ -828,8 +828,7 @@ mn10200_insert_operand (unsigned long *insnp, if (operand->bits < 24 && (operand->flags & MN10200_OPERAND_NOCHECK) == 0) { - long min, max; - offsetT test; + offsetT min, max; if ((operand->flags & MN10200_OPERAND_SIGNED) != 0) { @@ -842,11 +841,8 @@ mn10200_insert_operand (unsigned long *insnp, min = 0; } - test = val; - - if (test < min || test > max) - as_warn_value_out_of_range (_("operand"), test, (offsetT) min, - (offsetT) max, file, line); + if (val < min || val > max) + as_warn_value_out_of_range (_("operand"), val, min, max, file, line); } if ((operand->flags & MN10200_OPERAND_EXTENDED) == 0) diff --git a/gas/config/tc-mn10300.c b/gas/config/tc-mn10300.c index 537c2cb..a1d89f0 100644 --- a/gas/config/tc-mn10300.c +++ b/gas/config/tc-mn10300.c @@ -1103,7 +1103,7 @@ check_operand (const struct mn10300_operand *operand, test = val; - if (test < (offsetT) min || test > (offsetT) max) + if (test < min || test > max) return false; } return true; @@ -1146,8 +1146,9 @@ mn10300_insert_operand (unsigned long *insnp, test = val; - if (test < (offsetT) min || test > (offsetT) max) - as_warn_value_out_of_range (_("operand"), test, (offsetT) min, (offsetT) max, file, line); + if (test < min || test > max) + as_warn_value_out_of_range (_("operand"), test, (offsetT) min, + (offsetT) max, file, line); } if ((operand->flags & MN10300_OPERAND_SPLIT) != 0) @@ -1209,20 +1210,20 @@ mn10300_insert_operand (unsigned long *insnp, } else if ((operand->flags & MN10300_OPERAND_EXTENDED) == 0) { - *insnp |= (((long) val & ((1 << operand->bits) - 1)) + *insnp |= ((val & ((1 << operand->bits) - 1)) << (operand->shift + shift)); if ((operand->flags & MN10300_OPERAND_REPEATED) != 0) - *insnp |= (((long) val & ((1 << operand->bits) - 1)) + *insnp |= ((val & ((1 << operand->bits) - 1)) << (operand->shift + shift + operand->bits)); } else { - *extensionp |= (((long) val & ((1 << operand->bits) - 1)) + *extensionp |= ((val & ((1 << operand->bits) - 1)) << (operand->shift + shift)); if ((operand->flags & MN10300_OPERAND_REPEATED) != 0) - *extensionp |= (((long) val & ((1 << operand->bits) - 1)) + *extensionp |= ((val & ((1 << operand->bits) - 1)) << (operand->shift + shift + operand->bits)); } } diff --git a/gas/config/tc-nds32.c b/gas/config/tc-nds32.c index f5c021d..647744f 100644 --- a/gas/config/tc-nds32.c +++ b/gas/config/tc-nds32.c @@ -3896,7 +3896,7 @@ nds32_adjust_label (int n) /* Only frag by alignment when needed. Otherwise, it will fail to optimize labels on 4-byte boundary. (bug8454) See md_convert_frag () and RELAX_SET_RELAXABLE (frag) for details. */ - if (frag_now_fix () & ((1 << n) -1 )) + if (frag_now_fix () & (((addressT) 1 << n) - 1)) { if (subseg_text_p (now_seg)) { @@ -3921,7 +3921,7 @@ nds32_adjust_label (int n) old_frag = symbol_get_frag (label); old_value = S_GET_VALUE (label); - new_value = (valueT) frag_now_fix (); + new_value = frag_now_fix (); /* Multiple labels may be on the same address. And the last symbol may not be a label at all, e.g., register name, external function names, @@ -4208,8 +4208,6 @@ struct relax_hint_id *record_id_head = NULL; /* Is the buffer large enough? */ #define MAX_BUFFER 12 -static char *nds_itoa (int n); - static char * nds_itoa (int n) { diff --git a/gas/config/tc-pru.c b/gas/config/tc-pru.c index 9e12ab6..dcc23ba 100644 --- a/gas/config/tc-pru.c +++ b/gas/config/tc-pru.c @@ -255,7 +255,7 @@ pru_align (int log_size, const char *pfill, symbolS *label) old_frag = symbol_get_frag (label); old_value = S_GET_VALUE (label); - new_value = (valueT) frag_now_fix (); + new_value = frag_now_fix (); /* It is possible to have more than one label at a particular address, especially if debugging is enabled, so we must @@ -949,7 +949,7 @@ pru_assemble_expression (const char *exprstr, if (pru_mode == PRU_MODE_TEST && ep->X_op == O_constant) value = ep->X_add_number; - return (unsigned long) value; + return value; } /* Try to parse a non-relocatable expression. */ @@ -1100,7 +1100,6 @@ pru_assemble_arg_b (pru_insn_infoS *insn_info, const char *argstr) SET_INSN_FIELD (RS2, insn_info->insn_code, src2->index); SET_INSN_FIELD (RS2SEL, insn_info->insn_code, src2->regsel); } - } static void @@ -1554,7 +1553,6 @@ md_show_usage (FILE *stream) " -mlink-relax generate relocations for linker relaxation (default).\n" " -mno-link-relax don't generate relocations for linker relaxation.\n" )); - } /* This function is called once, at assembler startup time. diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c index 0492311..f0b119f 100644 --- a/gas/config/tc-riscv.c +++ b/gas/config/tc-riscv.c @@ -4322,12 +4322,12 @@ riscv_ip_hardcode (char *str, switch (imm_expr->X_op) { case O_constant: - values[num++] = (insn_t) imm_expr->X_add_number; + values[num++] = imm_expr->X_add_number; break; case O_big: /* Extract lower 32-bits of a big number. Assume that generic_bignum_to_int32 work on such number. */ - values[num++] = (insn_t) generic_bignum_to_int32 (); + values[num++] = generic_bignum_to_int32 (); break; default: /* The first value isn't constant, so it should be @@ -4616,7 +4616,7 @@ bool riscv_parse_name (const char *name, struct expressionS *ep, gas_assert (mode == expr_normal); regno = reg_lookup_internal (name, RCLASS_GPR); - if (regno == (unsigned int)-1) + if (regno == -1u) return false; if (symbol_find (name) != NULL) diff --git a/gas/config/tc-s12z.c b/gas/config/tc-s12z.c index 438418a..5110470 100644 --- a/gas/config/tc-s12z.c +++ b/gas/config/tc-s12z.c @@ -579,9 +579,7 @@ lex_opr (uint8_t *buffer, int *n_bytes, expressionS *exp, } else if (lex_reg_name (REG_BIT_Dn, ®2)) { - if (c >= -1 * (long) (0x1u << 17) - && - c < (long) (0x1u << 17) - 1) + if (c >= -1 * (1L << 17) && c < (1L << 17) - 1) { *n_bytes = 3; *xb = 0x80; diff --git a/gas/config/tc-s390.c b/gas/config/tc-s390.c index 6d4748e..d5d3976 100644 --- a/gas/config/tc-s390.c +++ b/gas/config/tc-s390.c @@ -727,9 +727,9 @@ s390_insert_operand (unsigned char *insn, { if (operand->flags & S390_OPERAND_PCREL) { - val = (offsetT) ((addressT) val << 1); - min = (offsetT) ((addressT) min << 1); - max = (offsetT) ((addressT) max << 1); + val = (addressT) val << 1; + min = (addressT) min << 1; + max = (addressT) max << 1; } s390_bad_operand_out_of_range (operand_number, val, min, max, @@ -738,7 +738,7 @@ s390_insert_operand (unsigned char *insn, return; } /* val is ok, now restrict it to operand->bits bits. */ - uval = (addressT) val & ((((addressT) 1 << (operand->bits-1)) << 1) - 1); + uval = val & ((((addressT) 1 << (operand->bits-1)) << 1) - 1); /* val is restrict, now check for special case. */ if (operand->bits == 20 && operand->shift == 20) uval = (uval >> 12) | ((uval & 0xfff) << 8); @@ -748,8 +748,8 @@ s390_insert_operand (unsigned char *insn, addressT min, max; max = (((addressT) 1 << (operand->bits - 1)) << 1) - 1; - min = (offsetT) 0; - uval = (addressT) val; + min = 0; + uval = val; /* Vector register operands have an additional bit in the RXB field. */ diff --git a/gas/config/tc-score.c b/gas/config/tc-score.c index cf8687bb..f3f1b2a 100644 --- a/gas/config/tc-score.c +++ b/gas/config/tc-score.c @@ -1507,7 +1507,7 @@ s3_data_op2 (char **str, int shift, enum score_data_type data_type) sprintf (s3_err_msg, _("invalid constant: %d bit expression not in range %u..%u"), s3_score_df_range[data_type].bits, - 0, (unsigned)0xffffffff); + 0, 0xffffffff); } else if (data_type == _IMM5_MULTI_LOAD) { @@ -4124,7 +4124,7 @@ s3_build_la_pic (int reg_rd, expressionS exp) var_num = 1; /* Fix part For an external symbol: addi rD, <constant> */ - sprintf (tmp, "addi r%d, %d", reg_rd, (int)add_number); + sprintf (tmp, "addi r%d, %d", reg_rd, (int) add_number); if (s3_append_insn (tmp, false) == s3_FAIL) return; @@ -4811,13 +4811,15 @@ s3_nopic_need_relax (symbolS * sym, int before_relaxing) { return 1; } - else if ((!S_IS_DEFINED (sym) || S_IS_COMMON (sym)) && (0 - /* We must defer this decision until after the whole file has been read, - since there might be a .extern after the first use of this symbol. */ - || (before_relaxing - && S_GET_VALUE (sym) == 0) - || (S_GET_VALUE (sym) != 0 - && S_GET_VALUE (sym) <= s3_g_switch_value))) + else if ((!S_IS_DEFINED (sym) || S_IS_COMMON (sym)) + && (0 + /* We must defer this decision until after the + whole file has been read, since there might be a + .extern after the first use of this symbol. */ + || (before_relaxing + && S_GET_VALUE (sym) == 0) + || (S_GET_VALUE (sym) != 0 + && S_GET_VALUE (sym) <= s3_g_switch_value))) { return 0; } @@ -5601,7 +5603,7 @@ s3_get_symbol (void) symbolS *p; c = get_symbol_name (&name); - p = (symbolS *) symbol_find_or_make (name); + p = symbol_find_or_make (name); (void) restore_line_pointer (c); return p; } @@ -6449,7 +6451,7 @@ s3_begin (void) s3_build_dependency_insn_hsh (); - for (i = (int)s3_REG_TYPE_FIRST; i < (int)s3_REG_TYPE_MAX; i++) + for (i = s3_REG_TYPE_FIRST; i < s3_REG_TYPE_MAX; i++) s3_build_reg_hsh (s3_all_reg_maps + i); /* Initialize dependency vector. */ @@ -6767,7 +6769,7 @@ s3_relax_branch_inst16 (fragS * fragp) if (s == NULL) frag_addr = 0; else - symbol_address = (addressT) symbol_get_frag (s)->fr_address; + symbol_address = symbol_get_frag (s)->fr_address; inst_value = s3_md_chars_to_number (fragp->fr_literal, s3_INSN16_SIZE); offset = (inst_value & 0x1ff) << 1; @@ -6810,7 +6812,7 @@ s3_relax_cmpbranch_inst32 (fragS * fragp) if (s == NULL) frag_addr = 0; else - symbol_address = (addressT) symbol_get_frag (s)->fr_address; + symbol_address = symbol_get_frag (s)->fr_address; inst_value = s3_md_chars_to_number (fragp->fr_literal, s3_INSN_SIZE); offset = (inst_value & 0x1) diff --git a/gas/config/tc-score7.c b/gas/config/tc-score7.c index 8543718..7b6b685 100644 --- a/gas/config/tc-score7.c +++ b/gas/config/tc-score7.c @@ -5251,7 +5251,7 @@ s7_b32_relax_to_b16 (fragS * fragp) if (s == NULL) frag_addr = 0; else - symbol_address = (addressT) symbol_get_frag (s)->fr_address; + symbol_address = symbol_get_frag (s)->fr_address; value = s7_md_chars_to_number (fragp->fr_literal, s7_INSN_SIZE); @@ -5440,7 +5440,7 @@ s7_get_symbol (void) symbolS *p; c = get_symbol_name (&name); - p = (symbolS *) symbol_find_or_make (name); + p = symbol_find_or_make (name); (void) restore_line_pointer (c); return p; } @@ -6080,7 +6080,7 @@ s7_begin (void) s7_build_dependency_insn_hsh (); - for (i = (int) REG_TYPE_FIRST; i < (int) s7_REG_TYPE_MAX; i++) + for (i = REG_TYPE_FIRST; i < s7_REG_TYPE_MAX; i++) s7_build_reg_hsh (s7_all_reg_maps + i); /* Initialize dependency vector. */ diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c index 2a25937..5653583 100644 --- a/gas/config/tc-sh.c +++ b/gas/config/tc-sh.c @@ -3703,8 +3703,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) if (val >= 0) val >>= shift; else - val = ((val >> shift) - | ((long) -1 & ~ ((long) -1 >> shift))); + val = (val >> shift) | (-1L & ~ (-1L >> shift)); } /* Extend sign for 64-bit host. */ diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c index 61f43e0..0dd9205 100644 --- a/gas/config/tc-sparc.c +++ b/gas/config/tc-sparc.c @@ -1254,7 +1254,7 @@ synthetize_setuw (const struct sparc_opcode *insn) && (the_insn.exp.X_add_number < -(offsetT) U0x80000000 || the_insn.exp.X_add_number > (offsetT) U0xffffffff)) as_warn (_("set: number not in -2147483648..4294967295 range")); - the_insn.exp.X_add_number = (int) the_insn.exp.X_add_number; + the_insn.exp.X_add_number = (int32_t) the_insn.exp.X_add_number; } } diff --git a/gas/config/tc-tic30.c b/gas/config/tc-tic30.c index 323f8bb..2c80f97 100644 --- a/gas/config/tc-tic30.c +++ b/gas/config/tc-tic30.c @@ -598,7 +598,7 @@ tic30_operand (char *token) current_op->immediate.s_number = current_op->immediate.imm_expr.X_add_number; current_op->immediate.u_number - = (unsigned int) current_op->immediate.imm_expr.X_add_number; + = current_op->immediate.imm_expr.X_add_number; current_op->immediate.resolved = 1; } } @@ -610,8 +610,8 @@ tic30_operand (char *token) current_op->immediate.decimal_found = 1; current_op->immediate.label = xstrdup (token); current_op->immediate.f_number = (float) atof (token); - current_op->immediate.s_number = (int) atoi (token); - current_op->immediate.u_number = (unsigned int) atoi (token); + current_op->immediate.s_number = atoi (token); + current_op->immediate.u_number = atoi (token); current_op->immediate.resolved = 1; } current_op->op_type = Disp | Abs24 | Imm16 | Imm24; @@ -1279,7 +1279,7 @@ md_atof (int what_statement_type, if (mant == 0) { mant |= 0x00800000; - exp = (long) exp - 0x01000000; + exp = exp - 0x01000000; } } tmsfloat = exp | mant; diff --git a/gas/config/tc-tic54x.c b/gas/config/tc-tic54x.c index 25efad6..515b843 100644 --- a/gas/config/tc-tic54x.c +++ b/gas/config/tc-tic54x.c @@ -478,7 +478,7 @@ tic54x_bss (int x ATTRIBUTE_UNUSED) char c; char *name; char *p; - int words; + offsetT words; segT current_seg; subsegT current_subseg; symbolS *symbolP; @@ -504,7 +504,7 @@ tic54x_bss (int x ATTRIBUTE_UNUSED) words = get_absolute_expression (); if (words < 0) { - as_bad (_(".bss size %d < 0!"), words); + as_bad (_(".bss size %d < 0!"), (int) words); ignore_rest_of_line (); return; } @@ -860,7 +860,7 @@ tic54x_tag (int ignore ATTRIBUTE_UNUSED) static void tic54x_struct_field (int type) { - int size; + unsigned int size; int count = 1; int new_bitfield_offset = 0; int field_align = current_stag->current_bitfield_offset != 0; @@ -964,12 +964,12 @@ tic54x_struct_field (int type) if (current_stag->is_union) { /* Note we treat the element as if it were an array of COUNT. */ - if (current_stag->size < (unsigned) size * count) + if (current_stag->size < size * count) current_stag->size = size * count; } else { - abs_section_offset += (unsigned) size * count; + abs_section_offset += size * count; current_stag->current_bitfield_offset = new_bitfield_offset; } line_label = NULL; @@ -1831,7 +1831,7 @@ tic54x_field (int ignore ATTRIBUTE_UNUSED) /* OR in existing value. */ if (alloc_frag->tc_frag_data) - value |= ((unsigned short) p[1] << 8) | p[0]; + value |= ((uint16_t) p[1] << 8) | p[0]; md_number_to_chars (p, value, 2); alloc_frag->tc_frag_data += size; if (alloc_frag->tc_frag_data == 16) @@ -3937,16 +3937,14 @@ encode_operand (tic54x_insn *insn, enum optype type, struct opstruct *operand) if (strcasecmp (operand->buf, "st0") == 0 || strcasecmp (operand->buf, "st1") == 0) { - insn->opcode[0].word |= - ((unsigned short) (operand->buf[2] - '0')) << 9; + insn->opcode[0].word |= ((uint16_t) (operand->buf[2] - '0')) << 9; return 1; } else if (operand->exp.X_op == O_constant && (operand->exp.X_add_number == 0 || operand->exp.X_add_number == 1)) { - insn->opcode[0].word |= - ((unsigned short) (operand->exp.X_add_number)) << 9; + insn->opcode[0].word |= ((uint16_t) (operand->exp.X_add_number)) << 9; return 1; } as_bad (_("Invalid status register \"%s\""), operand->buf); @@ -5269,7 +5267,7 @@ tic54x_relax_frag (fragS *frag, long stretch ATTRIBUTE_UNUSED) valueT value = bi->value; value <<= available - size; - value |= ((unsigned short) p[1] << 8) | p[0]; + value |= ((uint16_t) p[1] << 8) | p[0]; md_number_to_chars (p, value, 2); if ((prev_frag->tc_frag_data += size) == 16) prev_frag->tc_frag_data = 0; diff --git a/gas/config/tc-tic6x.c b/gas/config/tc-tic6x.c index 99ec7ec..7862236 100644 --- a/gas/config/tc-tic6x.c +++ b/gas/config/tc-tic6x.c @@ -3525,7 +3525,7 @@ md_assemble (char *str) bool found_match = false; for (i = 0; i < TIC6X_NUM_PREFER; i++) - opc_rank[i] = (unsigned int) -1; + opc_rank[i] = -1u; min_rank = TIC6X_NUM_PREFER - 1; max_rank = 0; @@ -3574,7 +3574,7 @@ md_assemble (char *str) if (rank > max_rank) max_rank = rank; - if (opc_rank[rank] == (unsigned int) -1) + if (opc_rank[rank] == -1u) opc_rank[rank] = i; else /* The opcode table should provide a total ordering @@ -3605,7 +3605,7 @@ md_assemble (char *str) { fix_needed = false; - if (opc_rank[try_rank] == (unsigned int) -1) + if (opc_rank[try_rank] == -1u) continue; opcode_value = tic6x_try_encode (opcm[opc_rank[try_rank]], operands, @@ -4466,7 +4466,7 @@ tic6x_pcrel_from_section (fixS *fixp, segT sec) && (!S_IS_DEFINED (fixp->fx_addsy) || S_GET_SEGMENT (fixp->fx_addsy) != sec)) return 0; - return (fixp->fx_where + fixp->fx_frag->fr_address) & ~(long) 0x1f; + return (fixp->fx_where + fixp->fx_frag->fr_address) & ~0x1fULL; } /* Round up a section size to the appropriate boundary. */ diff --git a/gas/config/tc-tilegx.c b/gas/config/tc-tilegx.c index 853e940..84daf05 100644 --- a/gas/config/tc-tilegx.c +++ b/gas/config/tc-tilegx.c @@ -441,25 +441,25 @@ apply_special_operator (operatorT op, offsetT num, const char *file, check_shift = 0; /* Fall through. */ case O_hw0: - ret = (signed short)num; + ret = (int16_t) num; break; case O_hw1_last: check_shift = 16; /* Fall through. */ case O_hw1: - ret = (signed short)(num >> 16); + ret = (int16_t) (num >> 16); break; case O_hw2_last: check_shift = 32; /* Fall through. */ case O_hw2: - ret = (signed short)(num >> 32); + ret = (int16_t) (num >> 32); break; case O_hw3: - ret = (signed short)(num >> 48); + ret = (int16_t) (num >> 48); break; default: @@ -959,10 +959,8 @@ tilegx_flush_bundle (void) /* Figure out what pipe the fnop must be in via arithmetic. * p0 + p1 + p2 must sum to the sum of TILEGX_PIPELINE_Y[012]. */ current_bundle[0].pipe = - (tilegx_pipeline)((TILEGX_PIPELINE_Y0 - + TILEGX_PIPELINE_Y1 - + TILEGX_PIPELINE_Y2) - - (current_bundle[1].pipe + current_bundle[2].pipe)); + (TILEGX_PIPELINE_Y0 + TILEGX_PIPELINE_Y1 + TILEGX_PIPELINE_Y2 + - current_bundle[1].pipe - current_bundle[2].pipe); } check_illegal_reg_writes (); diff --git a/gas/config/tc-tilepro.c b/gas/config/tc-tilepro.c index 4481731..8c90217 100644 --- a/gas/config/tc-tilepro.c +++ b/gas/config/tc-tilepro.c @@ -387,13 +387,13 @@ apply_special_operator (operatorT op, int num) switch (op) { case O_lo16: - return (signed short)num; + return (int16_t) num; case O_hi16: - return (signed short)(num >> 16); + return (int16_t) (num >> 16); case O_ha16: - return (signed short)((num + 0x8000) >> 16); + return (int16_t) ((num + 0x8000) >> 16); default: abort (); @@ -846,10 +846,8 @@ tilepro_flush_bundle (void) /* Figure out what pipe the fnop must be in via arithmetic. * p0 + p1 + p2 must sum to the sum of TILEPRO_PIPELINE_Y[012]. */ current_bundle[0].pipe = - (tilepro_pipeline)((TILEPRO_PIPELINE_Y0 - + TILEPRO_PIPELINE_Y1 - + TILEPRO_PIPELINE_Y2) - - (current_bundle[1].pipe + current_bundle[2].pipe)); + (TILEPRO_PIPELINE_Y0 + TILEPRO_PIPELINE_Y1 + TILEPRO_PIPELINE_Y2 + - current_bundle[1].pipe - current_bundle[2].pipe); } check_illegal_reg_writes (); diff --git a/gas/config/tc-visium.c b/gas/config/tc-visium.c index 1e3e3a8..01767f3 100644 --- a/gas/config/tc-visium.c +++ b/gas/config/tc-visium.c @@ -412,10 +412,9 @@ relaxed_symbol_addr (fragS *fragp, long stretch) if (f->fr_type == rs_align || f->fr_type == rs_align_code) { if (stretch < 0) - stretch = - ((- stretch) - & ~ ((1 << (int) f->fr_offset) - 1)); + stretch = -(-stretch & ~((1ul << f->fr_offset) - 1)); else - stretch &= ~ ((1 << (int) f->fr_offset) - 1); + stretch &= ~((1ul << f->fr_offset) - 1); if (stretch == 0) break; } @@ -683,7 +682,7 @@ md_apply_fix (fixS * fixP, valueT * value, segT segment) default: as_bad_where (fixP->fx_file, fixP->fx_line, "bad or unhandled relocation type: 0x%02x", - fixP->fx_r_type); + (unsigned int) fixP->fx_r_type); break; } @@ -1373,9 +1372,8 @@ md_assemble (char *str0) if (imm < 0 || imm > 31) as_bad ("immediate value out of range"); - opcode |= - (r1 << 10) | (r2 << 16) | (1 << 9) | ((imm & 0x1f) << - 4); + opcode |= ((r1 << 10) | (r2 << 16) | (1 << 9) + | ((imm & 0x1f) << 4)); } else { @@ -1889,9 +1887,8 @@ md_assemble (char *str0) if (finst < 0 || finst > 15) as_bad ("finst out of range"); - opcode |= - ((finst & 0xf) << 27) | (r1 << 10) | (r2 << 16) | (r3 << - 4); + opcode |= (((finst & 0xf) << 27) + | (r1 << 10) | (r2 << 16) | (r3 << 4)); } else { @@ -1955,9 +1952,8 @@ md_assemble (char *str0) if (finst < 0 || finst > 15) as_bad ("finst out of range"); - opcode |= - ((finst & 0xf) << 27) | (r1 << 10) | (r2 << 16) | (r3 << - 4); + opcode |= (((finst & 0xf) << 27) + | (r1 << 10) | (r2 << 16) | (r3 << 4)); } else { diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c index 38af6d0..af1154e 100644 --- a/gas/config/tc-xtensa.c +++ b/gas/config/tc-xtensa.c @@ -1869,7 +1869,7 @@ expression_end (const char *name) } -#define ERROR_REG_NUM ((unsigned) -1) +#define ERROR_REG_NUM (-1u) static unsigned tc_get_register (const char *prefix) @@ -1961,7 +1961,7 @@ expression_maybe_register (xtensa_opcode opc, int opnd, expressionS *tok) case BFD_RELOC_HI16: if (tok->X_op == O_constant) { - tok->X_add_number = ((unsigned) tok->X_add_number) >> 16; + tok->X_add_number = ((uint32_t) tok->X_add_number) >> 16; return; } break; diff --git a/gas/debug.c b/gas/debug.c index 794dc4c..9fe9a30 100644 --- a/gas/debug.c +++ b/gas/debug.c @@ -22,7 +22,8 @@ #include "as.h" #include "subsegs.h" -dmp_frags () +void +dmp_frags (void) { asection *s; frchainS *chp; @@ -48,9 +49,8 @@ dmp_frags () } } -dmp_frag (fp, indent) - struct frag *fp; - char *indent; +void +dmp_frag (struct frag *fp, char *indent) { for (; fp; fp = fp->fr_next) { @@ -90,9 +90,8 @@ dmp_frag (fp, indent) } } -var_chars (fp, n) - struct frag *fp; - int n; +void +var_chars (struct frag *fp, int n) { unsigned char *p; diff --git a/gas/ecoff.c b/gas/ecoff.c index ba8f6d8..7411595 100644 --- a/gas/ecoff.c +++ b/gas/ecoff.c @@ -3669,9 +3669,8 @@ ecoff_build_lineno (const struct ecoff_debug_swap *backend, else if (l->next->frag->fr_address + l->next->paddr > l->frag->fr_address + l->paddr) { - count = ((l->next->frag->fr_address + l->next->paddr - - (l->frag->fr_address + l->paddr)) - >> 2); + count = (l->next->frag->fr_address + l->next->paddr + - (l->frag->fr_address + l->paddr)) >> 2; } else { @@ -3785,7 +3784,7 @@ ecoff_build_lineno (const struct ecoff_debug_swap *backend, while (count > 0) { if (bufptr >= *bufend) - bufptr = ecoff_add_bytes (buf, bufend, bufptr, (long) 1); + bufptr = ecoff_add_bytes (buf, bufend, bufptr, 1); /* 1 is added to each count read. */ --count; if (count > 0x0f) diff --git a/gas/ehopt.c b/gas/ehopt.c index 8852820..5a9d9d6 100644 --- a/gas/ehopt.c +++ b/gas/ehopt.c @@ -537,7 +537,7 @@ eh_frame_convert_frag (fragS *frag) int loc4_fix, ca; loc4_frag = (fragS *) frag->fr_opcode; - loc4_fix = (int) frag->fr_offset; + loc4_fix = frag->fr_offset; diff = resolve_symbol_value (frag->fr_symbol); @@ -1991,8 +1991,8 @@ expr (int rankarg, /* Larger # is higher rank. */ symbol_get_frag (right.X_add_symbol), &frag_off)) { - offsetT symval_diff = S_GET_VALUE (resultP->X_add_symbol) - - S_GET_VALUE (right.X_add_symbol); + offsetT symval_diff = (S_GET_VALUE (resultP->X_add_symbol) + - S_GET_VALUE (right.X_add_symbol)); subtract_from_result (resultP, right.X_add_number, right.X_extrabit); subtract_from_result (resultP, frag_off / OCTETS_PER_BYTE, 0); add_to_result (resultP, symval_diff, symval_diff < 0); diff --git a/gas/input-scrub.c b/gas/input-scrub.c index 93d1e8e..c967a39 100644 --- a/gas/input-scrub.c +++ b/gas/input-scrub.c @@ -419,8 +419,8 @@ input_scrub_next_buffer (char **bufp) partial_size = limit - p; /* Save the fragment after that last newline. */ - memcpy (save_source, partial_where, (int) AFTER_SIZE); - memcpy (partial_where, AFTER_STRING, (int) AFTER_SIZE); + memcpy (save_source, partial_where, AFTER_SIZE); + memcpy (partial_where, AFTER_STRING, AFTER_SIZE); return partial_where; read_more: diff --git a/gas/listing.c b/gas/listing.c index dbf4782..92c560c 100644 --- a/gas/listing.c +++ b/gas/listing.c @@ -795,7 +795,7 @@ calc_hex (list_info_type *list) { size_t data_buffer_size; list_info_type *first = list; - unsigned int address = ~(unsigned int) 0; + unsigned int address = ~0u; fragS *frag; fragS *frag_ptr; unsigned int octet_in_frag; @@ -817,7 +817,7 @@ calc_hex (list_info_type *list) while (octet_in_frag < frag_ptr->fr_fix && data_buffer_size < MAX_BYTES - 3) { - if (address == ~(unsigned int) 0) + if (address == ~0u) address = frag_ptr->fr_address / OCTETS_PER_BYTE; sprintf (data_buffer + data_buffer_size, @@ -836,7 +836,7 @@ calc_hex (list_info_type *list) < frag_ptr->fr_fix + frag_ptr->fr_var * frag_ptr->fr_offset) && data_buffer_size < MAX_BYTES - 3) { - if (address == ~(unsigned int) 0) + if (address == ~0u) address = frag_ptr->fr_address / OCTETS_PER_BYTE; sprintf (data_buffer + data_buffer_size, @@ -875,7 +875,7 @@ print_lines (list_info_type *list, unsigned int lineno, nchars = (LISTING_WORD_SIZE * 2 + 1) * listing_lhs_width; /* Print the hex for the first line. */ - if (address == ~(unsigned int) 0) + if (address == ~0u) { fprintf (list_file, "% 4d ", lineno); for (idx = 0; idx < nchars; idx++) @@ -1302,7 +1302,7 @@ listing_listing (char *name ATTRIBUTE_UNUSED) p = buffer_line (list->file, buffer, width); if (list->file->linenum < list_line) - address = ~(unsigned int) 0; + address = ~0u; else address = calc_hex (list); @@ -1354,11 +1354,11 @@ print_timestamp (void) } static void -print_single_option (char * opt, int *pos) +print_single_option (char *opt, size_t *pos) { size_t opt_len = strlen (opt); - if ((*pos + opt_len) < paper_width) + if (*pos + opt_len < paper_width) { fprintf (list_file, _("%s "), opt); *pos = *pos + opt_len; @@ -1376,7 +1376,7 @@ static void print_options (char ** argv) { const char *field_name = _("\n options passed\t: "); - int pos = strlen (field_name); + size_t pos = strlen (field_name); char **p; fputs (field_name, list_file); @@ -3174,7 +3174,7 @@ s_rept (int expand_count) { size_t count; - count = (size_t) get_absolute_expression (); + count = get_absolute_expression (); do_repeat (count, "REPT", "ENDR", expand_count ? "" : NULL); } @@ -4636,7 +4636,7 @@ emit_expr_with_reloc (expressionS *exp, /* We can ignore any carry out, because it will be handled by extra_digit if it is needed. */ - extra_digit = (valueT) -1; + extra_digit = -1; op = O_big; } @@ -5453,7 +5453,7 @@ emit_leb128_expr (expressionS *exp, int sign) /* Let check_eh_frame know that data is being emitted. nbytes == -1 is a signal that this is leb128 data. It shouldn't optimize this away. */ - nbytes = (unsigned int) -1; + nbytes = -1u; if (check_eh_frame (exp, &nbytes)) abort (); @@ -6293,7 +6293,7 @@ char /* Return terminator. */ get_absolute_expression_and_terminator (long *val_pointer /* Return value of expression. */) { /* FIXME: val_pointer should probably be offsetT *. */ - *val_pointer = (long) get_absolute_expression (); + *val_pointer = get_absolute_expression (); return (*input_line_pointer++); } @@ -6357,7 +6357,7 @@ demand_copy_string (int *lenP) ignore_rest_of_line (); } *lenP = len; - return (retval); + return retval; } /* In: Input_line_pointer->next character. diff --git a/gas/symbols.c b/gas/symbols.c index 5d6d141..275d056 100644 --- a/gas/symbols.c +++ b/gas/symbols.c @@ -746,7 +746,7 @@ symbol_find_or_make (const char *name) symbol_table_insert (symbolP); } /* if symbol wasn't found */ - return (symbolP); + return symbolP; } symbolS * @@ -760,7 +760,7 @@ symbol_make (const char *name) if (!symbolP) symbolP = symbol_new (name, undefined_section, &zero_address_frag, 0); - return (symbolP); + return symbolP; } symbolS * @@ -2241,7 +2241,7 @@ S_GET_VALUE_WHERE (symbolS *s, const char * file, unsigned int line) S_GET_NAME (s)); } } - return (valueT) s->x->value.X_add_number; + return s->x->value.X_add_number; } valueT diff --git a/gas/write.c b/gas/write.c index ca6fedf..455dc44 100644 --- a/gas/write.c +++ b/gas/write.c @@ -587,8 +587,8 @@ size_seg (bfd *abfd ATTRIBUTE_UNUSED, asection *sec, void *xxx ATTRIBUTE_UNUSED) size = 0; flags = bfd_section_flags (sec); - if (size == 0 && bfd_section_size (sec) != 0 && - (flags & SEC_HAS_CONTENTS) != 0) + if (size == 0 && bfd_section_size (sec) != 0 + && (flags & SEC_HAS_CONTENTS) != 0) return; if (size > 0 && ! seginfo->bss) |