]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gas remove assorted unnecessary casts
authorAlan Modra <amodra@gmail.com>
Tue, 8 Jul 2025 23:43:51 +0000 (09:13 +0930)
committerAlan Modra <amodra@gmail.com>
Wed, 9 Jul 2025 00:05:07 +0000 (09:35 +0930)
This continues the saga of removing unnecessary casts, and making
small code tidies in gas.  Hopefully this sees the last of K&R
anachronisms.

44 files changed:
gas/atof-generic.c
gas/cond.c
gas/config/atof-ieee.c
gas/config/kvx-parse.c
gas/config/obj-elf.c
gas/config/obj-macho.c
gas/config/tc-csky.c
gas/config/tc-dlx.c
gas/config/tc-hppa.c
gas/config/tc-ia64.c
gas/config/tc-iq2000.c
gas/config/tc-kvx.c
gas/config/tc-loongarch.c
gas/config/tc-m68k.c
gas/config/tc-microblaze.c
gas/config/tc-mips.c
gas/config/tc-mmix.c
gas/config/tc-mn10200.c
gas/config/tc-mn10300.c
gas/config/tc-nds32.c
gas/config/tc-pru.c
gas/config/tc-riscv.c
gas/config/tc-s12z.c
gas/config/tc-s390.c
gas/config/tc-score.c
gas/config/tc-score7.c
gas/config/tc-sh.c
gas/config/tc-sparc.c
gas/config/tc-tic30.c
gas/config/tc-tic54x.c
gas/config/tc-tic6x.c
gas/config/tc-tilegx.c
gas/config/tc-tilepro.c
gas/config/tc-visium.c
gas/config/tc-xtensa.c
gas/debug.c
gas/ecoff.c
gas/ehopt.c
gas/expr.c
gas/input-scrub.c
gas/listing.c
gas/read.c
gas/symbols.c
gas/write.c

index 944f209654ada30041633dd651333dd3d3863e31..59d11109744cfa5177e404f361d01d2390f41c3c 100644 (file)
@@ -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];
index 2e3b3fd6f6cddacf9b82af83dead4772f84d0ac9..56e8c72673f4170cfb56191d25b9de505b185d82 100644 (file)
@@ -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;
index 92b9f74d4f3b4a88974d70a6670923ac0b81ce40..a1c3ca263c2e26e0666d6676dc83b674017db13a 100644 (file)
@@ -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);
index 06b21c936abd7d233a4c80221bc64f858a84a119..ea96f3d787bf6a3f476cf5d941be4aa4a1c4ba5e 100644 (file)
@@ -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;
index 6ca2433b4b913712d2a74c62a2206977fa538e85..03b6c2470e741904a23c635001e98ffb58024133 100644 (file)
@@ -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)
index 17bb697d796178c801bebceed51b87fb6aab981e..01e76c5d3e5161e14d8c41bb32123c6624387b86 100644 (file)
@@ -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"
index cfd0b37c90d16266c76fbad2dda716062d79867f..dc8ee744341215d9801155b68886c77ab3f36080 100644 (file)
@@ -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;
index 08948d2f7da5a894e1ada01be85062e64cc7344b..69c8f49234bbb9debc3226e89a3efd21a14f30f2 100644 (file)
@@ -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:
index a22d094dd19f19cf6de95c317247582bd4cd4635..744613fa2e27c15789a52dfb4c69ce47ce7c7728 100644 (file)
@@ -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;
index ac610b77046c4e6104d4edba587ec1737dd32035..88f956388607c1aa9c0ce20d8575395f48592c9d 100644 (file)
@@ -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;
index 1a31e8e8a85752caffca69fb6ad6eee1bb236432..76ff841a61e64342f215c710500ed1ad1c97dfd6 100644 (file)
@@ -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;
 }
index 59e2b2974482c3d583fc8ac6a4e4d0ec625dc33c..b4ca25c5c9b59e1c87653fa7097b181621a0ffc1 100644 (file)
@@ -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)
index b620d47366147944ce36a1fac458aac3188fbc40..7b53b6f6a52554d487053024094532e6024dd005 100644 (file)
@@ -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
index aa1354f2aa977834ad2b1e74cc949182f908dcc9..e5c8f5cac85889aa163e4bbb98e50606a892c6cc 100644 (file)
@@ -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;
index 5e0eaa2170c91d06f4e19a52920ceb5198699906..055d9ee22dd030704aca81b3c92034647da795d3 100644 (file)
@@ -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
            {
index 8b648ae89ce1faa6b7179f07d44a5273b614e4ab..9134cef96beede4a20cac705ff5e3adde1f727a6 100644 (file)
@@ -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;
 }
index 5ae158d6f8c8cd2ad191fe632884b94b4c727e9e..88b7bc49324322f27f74dcb5ee575eafac8ff0f9 100644 (file)
@@ -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);
        }
 
index f57540e6fb6bf24dbdc4331944c31d4574994343..210e9b016fc6d44781baf9048984ad6ab22ef571 100644 (file)
@@ -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)
index 537c2cb4e7c9ab90a8cefca712ce7e0d6a025f90..a1d89f09f165b21d9af71b051317a199d4e75b29 100644 (file)
@@ -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));
     }
 }
index f5c021ddbbcc8962623b019e87e7c43174e9bf12..647744fd6d1d362532f6f49d3362b98e97f53d82 100644 (file)
@@ -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)
 {
index 9e12ab68f7687b335b461f60bc2370fa7eb22f00..dcc23ba9def72dc62bdd40db703fa50a0eef2cca 100644 (file)
@@ -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.
index 0492311b40a9ac729c6d5be8a22707b8b92e131e..f0b119fbfedfae31ef8b310e3cb57df0b0469df7 100644 (file)
@@ -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)
index 438418a0c1d147770b3f5af3f78b9867364d61b2..5110470b9052defb261240e4f76d41072fd9277b 100644 (file)
@@ -579,9 +579,7 @@ lex_opr (uint8_t *buffer, int *n_bytes, expressionS *exp,
            }
          else if (lex_reg_name (REG_BIT_Dn, &reg2))
            {
-             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;
index 6d4748ece023b766ccb6be0a390b1b3a9fb5b420..d5d3976d5fce2004c53e87feee13d84fb28cb8a3 100644 (file)
@@ -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.  */
index cf8687bb78f854fe314fd32740518e1f92d0323e..f3f1b2a0066bc7ebf6a01950a757d1c16c56640f 100644 (file)
@@ -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)
index 85437184b5b5d548e61ea595583623e5eb80d7b2..7b6b6857d95371a8fb7523f41f9770fc79834d2f 100644 (file)
@@ -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.  */
index 2a259376710ca9d5c7f7bcd89cb77af8d6516965..56535830b87f427f0e8b1ecd01915c30ed93c88e 100644 (file)
@@ -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.  */
index 61f43e0ea08d0d16fc8ddde9c676365ce51f3fc0..0dd920574386b278fabf577efb677725a509c963 100644 (file)
@@ -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;
        }
     }
 
index 323f8bb23dbc0833d7487da04060ea6ef9fd4720..2c80f97f21c830a88dc5765417d4b7f3eadd7b17 100644 (file)
@@ -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;
index 25efad6a4616f9ad14685ec274eba9d1954c3180..515b8435c505e5faa1eb2e439751438e3b9b52ba 100644 (file)
@@ -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;
index 99ec7ecc178f5b34cf98447280190dbcb3e7b508..7862236300686d9effcbe0d33535d562640cdcbe 100644 (file)
@@ -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.  */
index 853e940b733599319f1dc10b1520c81b8818c97c..84daf05baa2db3286b580479240f463911d5598e 100644 (file)
@@ -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 ();
index 4481731daac677df3d1a499c5096c4dd3f56da24..8c90217573dd26426ea393e708430529a1f1a8fc 100644 (file)
@@ -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 ();
index 1e3e3a847bebad129c5e65a73574ad6da84f98a3..01767f32b5aeb9645ce852353ba0f5ea35b8e27f 100644 (file)
@@ -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
                {
index 38af6d0c95985144b5e1db7c7fe7d10b40e21233..af1154e8972edec0560dcaed451e0e4d0b5631be 100644 (file)
@@ -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;
index 794dc4c24503999ca372c1c8b1ec8259f135fbf0..9fe9a307f598c8747320a29efe9c40e114f8d00b 100644 (file)
@@ -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;
 
index ba8f6d8eaea3cf33aca8c80dc5d628ca59669248..74115959f94183a8b3890fab9b4a4770ad891d74 100644 (file)
@@ -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)
index 88528204a026e0064c8c0b8d20f006ee186102a9..5a9d9d641219b5a158d55e5cd1a33ce302a8931b 100644 (file)
@@ -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);
 
index 06283c29b9cddc061e9b219bbc2dc165d4e6a2c1..aaad288a8c81f44cf1eb7b8e7c9d01170f3abc65 100644 (file)
@@ -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);
index 93d1e8e444d6e3f7fcc0aa414623508d3a3e0c04..c967a390c078bc8d006470f919a343a734375103 100644 (file)
@@ -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:
index dbf4782b8d45ee52d833f39e2c1ec921bec5e9cd..92c560ce444465e134df3e0ddede423e8fb46a30 100644 (file)
@@ -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);
index e01d6397fd146c3584c16cff0e39fececd0ce686..d604d95d67a43ee4d65f9a9d16942ba45baf7b38 100644 (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++);
 }
 \f
@@ -6357,7 +6357,7 @@ demand_copy_string (int *lenP)
       ignore_rest_of_line ();
     }
   *lenP = len;
-  return (retval);
+  return retval;
 }
 \f
 /* In: Input_line_pointer->next character.
index 5d6d141e04a2d87b5391dc8dddd0d5da43e518d9..275d056cd4284a58c381d9e73bdcbfbc6da8c585 100644 (file)
@@ -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
index ca6fedf743c831e5db023906e10530011b983264..455dc446a01b738e406e0bc6cc8c6be698d8c8f2 100644 (file)
@@ -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)