[binutils-gdb] gas char/unsigned char casts

Alan Modra amodra@sourceware.org
Wed Jul 9 00:07:13 GMT 2025


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=a32922a7b97430d7681d96b82683d9d81755b088

commit a32922a7b97430d7681d96b82683d9d81755b088
Author: Alan Modra <amodra@gmail.com>
Date:   Wed Jul 9 09:12:20 2025 +0930

    gas char/unsigned char casts
    
    This patch removes many unneeded casts to char or unsigned char.  It's
    worth noting that safe-ctype.h macros ISDIGIT and the like cope with
    either signed or unsigned char.
    In some cases a cast to unsigned char is replaced by anding with 0xff,
    which accomplishes the same thing but doesn't rely on char being eight
    bits.  The patch also removes pointer casts, and a few unsigned char
    pointer variables.

Diff:
---
 gas/app.c                 |  4 +--
 gas/atof-generic.c        |  2 +-
 gas/config/tc-arm.c       |  5 ++-
 gas/config/tc-cr16.c      |  2 +-
 gas/config/tc-d10v.c      |  4 +--
 gas/config/tc-dlx.c       |  6 ++--
 gas/config/tc-ft32.c      |  3 +-
 gas/config/tc-loongarch.c | 29 ++++++++---------
 gas/config/tc-m68hc11.c   |  2 +-
 gas/config/tc-mmix.c      |  4 +--
 gas/config/tc-mn10300.c   |  2 +-
 gas/config/tc-moxie.c     |  5 ++-
 gas/config/tc-score7.c    |  7 ++--
 gas/config/tc-sh.c        | 82 +++++++++++++++++++++++------------------------
 gas/config/tc-spu.c       |  6 ++--
 gas/config/tc-tic4x.c     |  2 +-
 gas/config/tc-tic6x.c     |  5 ++-
 gas/config/tc-tilegx.c    |  2 +-
 gas/config/tc-v850.c      |  2 +-
 gas/config/tc-xtensa.c    |  4 +--
 gas/config/tc-z80.c       | 14 ++++----
 gas/ecoff.c               |  2 +-
 22 files changed, 93 insertions(+), 101 deletions(-)

diff --git a/gas/app.c b/gas/app.c
index 9e05ef11beb..b9df9daba56 100644
--- a/gas/app.c
+++ b/gas/app.c
@@ -577,7 +577,7 @@ do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen,
 
       if (check_multibyte)
 	(void) scan_for_multibyte_characters ((const unsigned char *) from,
-					      (const unsigned char* ) fromend,
+					      (const unsigned char *) fromend,
 					      true /* Generate warnings.  */);
     }
 
@@ -1218,7 +1218,7 @@ do_scrub_chars (size_t (*get) (char *, size_t), char *tostart, size_t tolen,
 	      else
 		ch = process_escape (ch);
 	    }
-	  sprintf (out_buf, "%d", (int) (unsigned char) ch);
+	  sprintf (out_buf, "%d", ch & 0xff);
 
 	  /* None of these 'x constants for us.  We want 'x'.  */
 	  if ((ch = GET ()) != '\'')
diff --git a/gas/atof-generic.c b/gas/atof-generic.c
index 5bf0867ccdf..944f209654a 100644
--- a/gas/atof-generic.c
+++ b/gas/atof-generic.c
@@ -303,7 +303,7 @@ atof_generic (/* return pointer to just AFTER number we read.  */
 	    {
 	      if (decimal_exponent > LONG_MAX / 10
 		  || (decimal_exponent == LONG_MAX / 10
-		      && c > '0' + (char) (LONG_MAX - LONG_MAX / 10 * 10)))
+		      && c > '0' + (LONG_MAX - LONG_MAX / 10 * 10)))
 		return_value = ERROR_EXPONENT_OVERFLOW;
 	      decimal_exponent = decimal_exponent * 10 + c - '0';
 	    }
diff --git a/gas/config/tc-arm.c b/gas/config/tc-arm.c
index 9a1ef1bd1c0..5fabf71c2f5 100644
--- a/gas/config/tc-arm.c
+++ b/gas/config/tc-arm.c
@@ -26038,14 +26038,13 @@ static valueT
 md_chars_to_number (char * buf, int n)
 {
   valueT result = 0;
-  unsigned char * where = (unsigned char *) buf;
 
   if (target_big_endian)
     {
       while (n--)
 	{
 	  result <<= 8;
-	  result |= (*where++ & 255);
+	  result |= (*buf++ & 255);
 	}
     }
   else
@@ -26053,7 +26052,7 @@ md_chars_to_number (char * buf, int n)
       while (n--)
 	{
 	  result <<= 8;
-	  result |= (where[n] & 255);
+	  result |= (buf[n] & 255);
 	}
     }
 
diff --git a/gas/config/tc-cr16.c b/gas/config/tc-cr16.c
index 4bbab7f2dee..5b5b651dae8 100644
--- a/gas/config/tc-cr16.c
+++ b/gas/config/tc-cr16.c
@@ -2514,7 +2514,7 @@ md_assemble (char *op)
       strcpy (param1, get_b_cc (op));
       strcat (param1,",");
       strcat (param1, param);
-      param = (char *) &param1;
+      param = param1;
       cr16_assemble ("b", param);
       return;
     }
diff --git a/gas/config/tc-d10v.c b/gas/config/tc-d10v.c
index 3bdca91ba8d..98d5e8bc0cf 100644
--- a/gas/config/tc-d10v.c
+++ b/gas/config/tc-d10v.c
@@ -283,11 +283,11 @@ md_begin (void)
      on the operands.  This hash table then provides a quick index to
      the first opcode with a particular name in the opcode table.  */
 
-  for (opcode = (struct d10v_opcode *) d10v_opcodes; opcode->name; opcode++)
+  for (opcode = d10v_opcodes; opcode->name; opcode++)
     {
       if (strcmp (prev_name, opcode->name))
 	{
-	  prev_name = (char *) opcode->name;
+	  prev_name = opcode->name;
 	  str_hash_insert (d10v_hash, opcode->name, opcode, 0);
 	}
     }
diff --git a/gas/config/tc-dlx.c b/gas/config/tc-dlx.c
index abb283dda32..08948d2f7da 100644
--- a/gas/config/tc-dlx.c
+++ b/gas/config/tc-dlx.c
@@ -187,7 +187,7 @@ is_ldst_registers (char *name)
 
   /* The first character of the register name got to be either %, $, r of R.  */
   if ((ptr[0] == '%' || ptr[0] == '$' || ptr[0] == 'r' || ptr[0] == 'R')
-      && ISDIGIT ((unsigned char) ptr[1]))
+      && ISDIGIT (ptr[1]))
     return 1;
 
   /* Now check the software register representation.  */
@@ -616,7 +616,7 @@ parse_operand (char *s, expressionS *operandp)
 
   /* Check for the % and $ register representation    */
   if ((s[0] == '%' || s[0] == '$' || s[0] == 'r' || s[0] == 'R')
-      && ISDIGIT ((unsigned char) s[1]))
+      && ISDIGIT (s[1]))
     {
       /* We have a numeric register expression.  No biggy.  */
       s += 1;
@@ -1124,7 +1124,7 @@ md_operand (expressionS* expressionP)
 {
   /* Check for the #number representation    */
   if (input_line_pointer[0] == '#' &&
-      ISDIGIT ((unsigned char) input_line_pointer[1]))
+      ISDIGIT (input_line_pointer[1]))
     {
       /* We have a numeric number expression.  No biggy.  */
       input_line_pointer += 1;	/* Skip # */
diff --git a/gas/config/tc-ft32.c b/gas/config/tc-ft32.c
index e5d9a8a9bc6..7e68e83f90d 100644
--- a/gas/config/tc-ft32.c
+++ b/gas/config/tc-ft32.c
@@ -530,12 +530,11 @@ static valueT
 md_chars_to_number (char * buf, int n)
 {
   valueT result = 0;
-  unsigned char * where = (unsigned char *) buf;
 
   while (n--)
     {
       result <<= 8;
-      result |= (where[n] & 255);
+      result |= (buf[n] & 255);
     }
 
   return result;
diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c
index a91b12eaa9c..047dc6fd3bb 100644
--- a/gas/config/tc-loongarch.c
+++ b/gas/config/tc-loongarch.c
@@ -180,7 +180,6 @@ md_parse_option (int c, const char *arg)
   int ret = 1;
   char lp64[256] = "";
   char ilp32[256] = "";
-  unsigned char *suf = (unsigned char *)arg;
 
   lp64['s'] = lp64['S'] = EF_LOONGARCH_ABI_SOFT_FLOAT;
   lp64['f'] = lp64['F'] = EF_LOONGARCH_ABI_SINGLE_FLOAT;
@@ -193,7 +192,7 @@ md_parse_option (int c, const char *arg)
   switch (c)
     {
     case OPTION_ABI:
-      if (strncasecmp (arg, "lp64", 4) == 0 && lp64[suf[4]] != 0)
+      if (strncasecmp (arg, "lp64", 4) == 0 && lp64[arg[4] & 0xff] != 0)
 	{
 	  LARCH_opts.ase_ilp32 = 1;
 	  LARCH_opts.ase_lp64 = 1;
@@ -201,11 +200,11 @@ md_parse_option (int c, const char *arg)
 	  LARCH_opts.ase_lasx = 1;
 	  LARCH_opts.ase_lvz = 1;
 	  LARCH_opts.ase_lbt = 1;
-	  LARCH_opts.ase_abi = lp64[suf[4]];
+	  LARCH_opts.ase_abi = lp64[arg[4] & 0xff];
 	}
-      else if (strncasecmp (arg, "ilp32", 5) == 0 && ilp32[suf[5]] != 0)
+      else if (strncasecmp (arg, "ilp32", 5) == 0 && ilp32[arg[5] & 0xff] != 0)
 	{
-	  LARCH_opts.ase_abi = ilp32[suf[5]];
+	  LARCH_opts.ase_abi = ilp32[arg[5] & 0xff];
 	  LARCH_opts.ase_ilp32 = 1;
 	}
       else
@@ -2284,12 +2283,12 @@ loongarch_relax_frag (asection *sec, fragS *fragp,
 static void
 loongarch_convert_frag_branch (fragS *fragp)
 {
-  bfd_byte *buf;
+  char *buf;
   expressionS exp;
   fixS *fixp;
   insn_t insn;
 
-  buf = (bfd_byte *)fragp->fr_literal + fragp->fr_fix;
+  buf = fragp->fr_literal + fragp->fr_fix;
 
   exp.X_op = O_symbol;
   exp.X_add_symbol = fragp->fr_symbol;
@@ -2319,17 +2318,17 @@ loongarch_convert_frag_branch (fragS *fragp)
 
       /* Add the B instruction and jump to the original target.  */
       bfd_putl32 (LARCH_B, buf);
-      fixp = fix_new_exp (fragp, buf - (bfd_byte *)fragp->fr_literal,
+      fixp = fix_new_exp (fragp, buf - fragp->fr_literal,
 			  4, &exp, false, BFD_RELOC_LARCH_B26);
       buf += 4;
       break;
     case RELAX_BRANCH_21:
-      fixp = fix_new_exp (fragp, buf - (bfd_byte *)fragp->fr_literal,
+      fixp = fix_new_exp (fragp, buf - fragp->fr_literal,
 			  4, &exp, false, BFD_RELOC_LARCH_B21);
       buf += 4;
       break;
     case RELAX_BRANCH_16:
-      fixp = fix_new_exp (fragp, buf - (bfd_byte *)fragp->fr_literal,
+      fixp = fix_new_exp (fragp, buf - fragp->fr_literal,
 			  4, &exp, false, BFD_RELOC_LARCH_B16);
       buf += 4;
       break;
@@ -2341,8 +2340,7 @@ loongarch_convert_frag_branch (fragS *fragp)
   fixp->fx_file = fragp->fr_file;
   fixp->fx_line = fragp->fr_line;
 
-  gas_assert (buf == (bfd_byte *)fragp->fr_literal
-	      + fragp->fr_fix + fragp->fr_var);
+  gas_assert (buf == fragp->fr_literal + fragp->fr_fix + fragp->fr_var);
 
   fragp->fr_fix += fragp->fr_var;
 }
@@ -2352,7 +2350,7 @@ loongarch_convert_frag_branch (fragS *fragp)
 static void
 loongarch_convert_frag_align (fragS *fragp, asection *sec)
 {
-  bfd_byte *buf = (bfd_byte *)fragp->fr_literal + fragp->fr_fix;
+  char *buf = fragp->fr_literal + fragp->fr_fix;
 
   offsetT nop_bytes;
   if (NULL == fragp->fr_symbol)
@@ -2371,7 +2369,7 @@ loongarch_convert_frag_align (fragS *fragp, asection *sec)
       exp.X_add_symbol = fragp->fr_symbol;
       exp.X_add_number = fragp->fr_offset;
 
-      fixS *fixp = fix_new_exp (fragp, buf - (bfd_byte *)fragp->fr_literal,
+      fixS *fixp = fix_new_exp (fragp, buf - fragp->fr_literal,
 				nop_bytes, &exp, false, BFD_RELOC_LARCH_ALIGN);
       fixp->fx_file = fragp->fr_file;
       fixp->fx_line = fragp->fr_line;
@@ -2379,8 +2377,7 @@ loongarch_convert_frag_align (fragS *fragp, asection *sec)
       buf += nop_bytes;
     }
 
-  gas_assert (buf == (bfd_byte *)fragp->fr_literal
-	      + fragp->fr_fix + fragp->fr_var);
+  gas_assert (buf == fragp->fr_literal + fragp->fr_fix + fragp->fr_var);
 
   fragp->fr_fix += fragp->fr_var;
 }
diff --git a/gas/config/tc-m68hc11.c b/gas/config/tc-m68hc11.c
index 17856390c23..6dd8120cc35 100644
--- a/gas/config/tc-m68hc11.c
+++ b/gas/config/tc-m68hc11.c
@@ -989,7 +989,7 @@ print_opcode_list (void)
 		printf ("\n");
 
 	      printf ("%-5.5s ", opcodes->name);
-	      prev_name = (char *) opcodes->name;
+	      prev_name = opcodes->name;
 	    }
 	  if (fmt[0])
 	    printf ("  [%s]", fmt);
diff --git a/gas/config/tc-mmix.c b/gas/config/tc-mmix.c
index d86ae7a25de..8b052dce967 100644
--- a/gas/config/tc-mmix.c
+++ b/gas/config/tc-mmix.c
@@ -504,7 +504,7 @@ get_operands (int max_operands, char *s, expressionS *exp)
   /* Mark the end of the valid operands with an illegal expression.  */
   exp[numexp].X_op = O_illegal;
 
-  return (numexp);
+  return numexp;
 }
 
 /* Get the value of a special register, or -1 if the name does not match
@@ -1912,7 +1912,7 @@ mmix_assemble_return_nonzero (char *str)
   /* Normal instruction handling downcases, so we must too.  */
   while (ISALNUM (*s2))
     {
-      if (ISUPPER ((unsigned char) *s2))
+      if (ISUPPER (*s2))
 	*s2 = TOLOWER (*s2);
       s2++;
     }
diff --git a/gas/config/tc-mn10300.c b/gas/config/tc-mn10300.c
index 4e24254e4e1..4e0072d0826 100644
--- a/gas/config/tc-mn10300.c
+++ b/gas/config/tc-mn10300.c
@@ -923,7 +923,7 @@ md_begin (void)
     {
       if (strcmp (prev_name, op->name))
 	{
-	  prev_name = (char *) op->name;
+	  prev_name = op->name;
 	  str_hash_insert (mn10300_hash, op->name, op, 0);
 	}
       op++;
diff --git a/gas/config/tc-moxie.c b/gas/config/tc-moxie.c
index 2d5e112a4f2..cb8adfb2ce4 100644
--- a/gas/config/tc-moxie.c
+++ b/gas/config/tc-moxie.c
@@ -731,14 +731,13 @@ static valueT
 md_chars_to_number (char * buf, int n)
 {
   valueT result = 0;
-  unsigned char * where = (unsigned char *) buf;
 
   if (target_big_endian)
     {
       while (n--)
 	{
 	  result <<= 8;
-	  result |= (*where++ & 255);
+	  result |= (*buf++ & 255);
 	}
     }
   else
@@ -746,7 +745,7 @@ md_chars_to_number (char * buf, int n)
       while (n--)
 	{
 	  result <<= 8;
-	  result |= (where[n] & 255);
+	  result |= (buf[n] & 255);
 	}
     }
 
diff --git a/gas/config/tc-score7.c b/gas/config/tc-score7.c
index d0b5c1bccc7..bf15007941f 100644
--- a/gas/config/tc-score7.c
+++ b/gas/config/tc-score7.c
@@ -5130,14 +5130,13 @@ static valueT
 s7_md_chars_to_number (char *buf, int n)
 {
   valueT result = 0;
-  unsigned char *where = (unsigned char *) buf;
 
   if (target_big_endian)
     {
       while (n--)
         {
           result <<= 8;
-          result |= (*where++ & 255);
+          result |= (*buf++ & 255);
         }
     }
   else
@@ -5145,7 +5144,7 @@ s7_md_chars_to_number (char *buf, int n)
       while (n--)
         {
           result <<= 8;
-          result |= (where[n] & 255);
+          result |= (buf[n] & 255);
         }
     }
 
@@ -5679,7 +5678,7 @@ s7_s_score_set (int x ATTRIBUTE_UNUSED)
 
   while (!is_end_of_stmt (*input_line_pointer))
     {
-      name[i] = (char) * input_line_pointer;
+      name[i] = *input_line_pointer;
       i++;
       ++input_line_pointer;
     }
diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c
index 6d077b27a74..c87a2e12396 100644
--- a/gas/config/tc-sh.c
+++ b/gas/config/tc-sh.c
@@ -605,7 +605,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
       if (l1 == '1')
 	{
 	  if (src[2] >= '0' && src[2] <= '5'
-	      && ! IDENT_CHAR ((unsigned char) src[3]))
+	      && ! IDENT_CHAR (src[3]))
 	    {
 	      *mode = A_REG_N;
 	      *reg = 10 + src[2] - '0';
@@ -613,26 +613,26 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
 	    }
 	}
       if (l1 >= '0' && l1 <= '9'
-	  && ! IDENT_CHAR ((unsigned char) src[2]))
+	  && ! IDENT_CHAR (src[2]))
 	{
 	  *mode = A_REG_N;
 	  *reg = (l1 - '0');
 	  return 2;
 	}
       if (l1 >= '0' && l1 <= '7' && strncasecmp (&src[2], "_bank", 5) == 0
-	  && ! IDENT_CHAR ((unsigned char) src[7]))
+	  && ! IDENT_CHAR (src[7]))
 	{
 	  *mode = A_REG_B;
 	  *reg  = (l1 - '0');
 	  return 7;
 	}
 
-      if (l1 == 'e' && ! IDENT_CHAR ((unsigned char) src[2]))
+      if (l1 == 'e' && ! IDENT_CHAR (src[2]))
 	{
 	  *mode = A_RE;
 	  return 2;
 	}
-      if (l1 == 's' && ! IDENT_CHAR ((unsigned char) src[2]))
+      if (l1 == 's' && ! IDENT_CHAR (src[2]))
 	{
 	  *mode = A_RS;
 	  return 2;
@@ -643,13 +643,13 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
     {
       if (l1 == '0')
 	{
-	  if (! IDENT_CHAR ((unsigned char) src[2]))
+	  if (! IDENT_CHAR (src[2]))
 	    {
 	      *mode = DSP_REG_N;
 	      *reg = A_A0_NUM;
 	      return 2;
 	    }
-	  if (TOLOWER (src[2]) == 'g' && ! IDENT_CHAR ((unsigned char) src[3]))
+	  if (TOLOWER (src[2]) == 'g' && ! IDENT_CHAR (src[3]))
 	    {
 	      *mode = DSP_REG_N;
 	      *reg = A_A0G_NUM;
@@ -658,13 +658,13 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
 	}
       if (l1 == '1')
 	{
-	  if (! IDENT_CHAR ((unsigned char) src[2]))
+	  if (! IDENT_CHAR (src[2]))
 	    {
 	      *mode = DSP_REG_N;
 	      *reg = A_A1_NUM;
 	      return 2;
 	    }
-	  if (TOLOWER (src[2]) == 'g' && ! IDENT_CHAR ((unsigned char) src[3]))
+	  if (TOLOWER (src[2]) == 'g' && ! IDENT_CHAR (src[3]))
 	    {
 	      *mode = DSP_REG_N;
 	      *reg = A_A1G_NUM;
@@ -673,21 +673,21 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
 	}
 
       if (l1 == 'x' && src[2] >= '0' && src[2] <= '1'
-	  && ! IDENT_CHAR ((unsigned char) src[3]))
+	  && ! IDENT_CHAR (src[3]))
 	{
 	  *mode = A_REG_N;
 	  *reg = 4 + (l1 - '0');
 	  return 3;
 	}
       if (l1 == 'y' && src[2] >= '0' && src[2] <= '1'
-	  && ! IDENT_CHAR ((unsigned char) src[3]))
+	  && ! IDENT_CHAR (src[3]))
 	{
 	  *mode = A_REG_N;
 	  *reg = 6 + (l1 - '0');
 	  return 3;
 	}
       if (l1 == 's' && src[2] >= '0' && src[2] <= '3'
-	  && ! IDENT_CHAR ((unsigned char) src[3]))
+	  && ! IDENT_CHAR (src[3]))
 	{
 	  int n = l1 - '0';
 
@@ -697,7 +697,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
 	}
     }
 
-  if (l0 == 'i' && l1 && ! IDENT_CHAR ((unsigned char) src[2]))
+  if (l0 == 'i' && l1 && ! IDENT_CHAR (src[2]))
     {
       if (l1 == 's')
 	{
@@ -720,7 +720,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
     }
 
   if (l0 == 'x' && l1 >= '0' && l1 <= '1'
-      && ! IDENT_CHAR ((unsigned char) src[2]))
+      && ! IDENT_CHAR (src[2]))
     {
       *mode = DSP_REG_N;
       *reg = A_X0_NUM + l1 - '0';
@@ -728,7 +728,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
     }
 
   if (l0 == 'y' && l1 >= '0' && l1 <= '1'
-      && ! IDENT_CHAR ((unsigned char) src[2]))
+      && ! IDENT_CHAR (src[2]))
     {
       *mode = DSP_REG_N;
       *reg = A_Y0_NUM + l1 - '0';
@@ -736,7 +736,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
     }
 
   if (l0 == 'm' && l1 >= '0' && l1 <= '1'
-      && ! IDENT_CHAR ((unsigned char) src[2]))
+      && ! IDENT_CHAR (src[2]))
     {
       *mode = DSP_REG_N;
       *reg = l1 == '0' ? A_M0_NUM : A_M1_NUM;
@@ -745,59 +745,59 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
 
   if (l0 == 's'
       && l1 == 's'
-      && TOLOWER (src[2]) == 'r' && ! IDENT_CHAR ((unsigned char) src[3]))
+      && TOLOWER (src[2]) == 'r' && ! IDENT_CHAR (src[3]))
     {
       *mode = A_SSR;
       return 3;
     }
 
   if (l0 == 's' && l1 == 'p' && TOLOWER (src[2]) == 'c'
-      && ! IDENT_CHAR ((unsigned char) src[3]))
+      && ! IDENT_CHAR (src[3]))
     {
       *mode = A_SPC;
       return 3;
     }
 
   if (l0 == 's' && l1 == 'g' && TOLOWER (src[2]) == 'r'
-      && ! IDENT_CHAR ((unsigned char) src[3]))
+      && ! IDENT_CHAR (src[3]))
     {
       *mode = A_SGR;
       return 3;
     }
 
   if (l0 == 'd' && l1 == 's' && TOLOWER (src[2]) == 'r'
-      && ! IDENT_CHAR ((unsigned char) src[3]))
+      && ! IDENT_CHAR (src[3]))
     {
       *mode = A_DSR;
       return 3;
     }
 
   if (l0 == 'd' && l1 == 'b' && TOLOWER (src[2]) == 'r'
-      && ! IDENT_CHAR ((unsigned char) src[3]))
+      && ! IDENT_CHAR (src[3]))
     {
       *mode = A_DBR;
       return 3;
     }
 
-  if (l0 == 's' && l1 == 'r' && ! IDENT_CHAR ((unsigned char) src[2]))
+  if (l0 == 's' && l1 == 'r' && ! IDENT_CHAR (src[2]))
     {
       *mode = A_SR;
       return 2;
     }
 
-  if (l0 == 's' && l1 == 'p' && ! IDENT_CHAR ((unsigned char) src[2]))
+  if (l0 == 's' && l1 == 'p' && ! IDENT_CHAR (src[2]))
     {
       *mode = A_REG_N;
       *reg = 15;
       return 2;
     }
 
-  if (l0 == 'p' && l1 == 'r' && ! IDENT_CHAR ((unsigned char) src[2]))
+  if (l0 == 'p' && l1 == 'r' && ! IDENT_CHAR (src[2]))
     {
       *mode = A_PR;
       return 2;
     }
-  if (l0 == 'p' && l1 == 'c' && ! IDENT_CHAR ((unsigned char) src[2]))
+  if (l0 == 'p' && l1 == 'c' && ! IDENT_CHAR (src[2]))
     {
       /* Don't use A_DISP_PC here - that would accept stuff like 'mova pc,r0'
          and use an uninitialized immediate.  */
@@ -805,26 +805,26 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
       return 2;
     }
   if (l0 == 'g' && l1 == 'b' && TOLOWER (src[2]) == 'r'
-      && ! IDENT_CHAR ((unsigned char) src[3]))
+      && ! IDENT_CHAR (src[3]))
     {
       *mode = A_GBR;
       return 3;
     }
   if (l0 == 'v' && l1 == 'b' && TOLOWER (src[2]) == 'r'
-      && ! IDENT_CHAR ((unsigned char) src[3]))
+      && ! IDENT_CHAR (src[3]))
     {
       *mode = A_VBR;
       return 3;
     }
 
   if (l0 == 't' && l1 == 'b' && TOLOWER (src[2]) == 'r'
-      && ! IDENT_CHAR ((unsigned char) src[3]))
+      && ! IDENT_CHAR (src[3]))
     {
       *mode = A_TBR;
       return 3;
     }
   if (l0 == 'm' && l1 == 'a' && TOLOWER (src[2]) == 'c'
-      && ! IDENT_CHAR ((unsigned char) src[4]))
+      && ! IDENT_CHAR (src[4]))
     {
       if (TOLOWER (src[3]) == 'l')
 	{
@@ -838,7 +838,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
 	}
     }
   if (l0 == 'm' && l1 == 'o' && TOLOWER (src[2]) == 'd'
-      && ! IDENT_CHAR ((unsigned char) src[3]))
+      && ! IDENT_CHAR (src[3]))
     {
       *mode = A_MOD;
       return 3;
@@ -848,7 +848,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
       if (src[2] == '1')
 	{
 	  if (src[3] >= '0' && src[3] <= '5'
-	      && ! IDENT_CHAR ((unsigned char) src[4]))
+	      && ! IDENT_CHAR (src[4]))
 	    {
 	      *mode = F_REG_N;
 	      *reg = 10 + src[3] - '0';
@@ -856,7 +856,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
 	    }
 	}
       if (src[2] >= '0' && src[2] <= '9'
-	  && ! IDENT_CHAR ((unsigned char) src[3]))
+	  && ! IDENT_CHAR (src[3]))
 	{
 	  *mode = F_REG_N;
 	  *reg = (src[2] - '0');
@@ -868,7 +868,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
       if (src[2] == '1')
 	{
 	  if (src[3] >= '0' && src[3] <= '4' && ! ((src[3] - '0') & 1)
-	      && ! IDENT_CHAR ((unsigned char) src[4]))
+	      && ! IDENT_CHAR (src[4]))
 	    {
 	      *mode = D_REG_N;
 	      *reg = 10 + src[3] - '0';
@@ -876,7 +876,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
 	    }
 	}
       if (src[2] >= '0' && src[2] <= '8' && ! ((src[2] - '0') & 1)
-	  && ! IDENT_CHAR ((unsigned char) src[3]))
+	  && ! IDENT_CHAR (src[3]))
 	{
 	  *mode = D_REG_N;
 	  *reg = (src[2] - '0');
@@ -888,7 +888,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
       if (src[2] == '1')
 	{
 	  if (src[3] >= '0' && src[3] <= '4' && ! ((src[3] - '0') & 1)
-	      && ! IDENT_CHAR ((unsigned char) src[4]))
+	      && ! IDENT_CHAR (src[4]))
 	    {
 	      *mode = X_REG_N;
 	      *reg = 11 + src[3] - '0';
@@ -896,7 +896,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
 	    }
 	}
       if (src[2] >= '0' && src[2] <= '8' && ! ((src[2] - '0') & 1)
-	  && ! IDENT_CHAR ((unsigned char) src[3]))
+	  && ! IDENT_CHAR (src[3]))
 	{
 	  *mode = X_REG_N;
 	  *reg = (src[2] - '0') + 1;
@@ -905,14 +905,14 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
     }
   if (l0 == 'f' && l1 == 'v')
     {
-      if (src[2] == '1'&& src[3] == '2' && ! IDENT_CHAR ((unsigned char) src[4]))
+      if (src[2] == '1'&& src[3] == '2' && ! IDENT_CHAR (src[4]))
 	{
 	  *mode = V_REG_N;
 	  *reg = 12;
 	  return 4;
 	}
       if ((src[2] == '0' || src[2] == '4' || src[2] == '8')
-	  && ! IDENT_CHAR ((unsigned char) src[3]))
+	  && ! IDENT_CHAR (src[3]))
 	{
 	  *mode = V_REG_N;
 	  *reg = (src[2] - '0');
@@ -921,7 +921,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
     }
   if (l0 == 'f' && l1 == 'p' && TOLOWER (src[2]) == 'u'
       && TOLOWER (src[3]) == 'l'
-      && ! IDENT_CHAR ((unsigned char) src[4]))
+      && ! IDENT_CHAR (src[4]))
     {
       *mode = FPUL_N;
       return 4;
@@ -929,7 +929,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
 
   if (l0 == 'f' && l1 == 'p' && TOLOWER (src[2]) == 's'
       && TOLOWER (src[3]) == 'c'
-      && TOLOWER (src[4]) == 'r' && ! IDENT_CHAR ((unsigned char) src[5]))
+      && TOLOWER (src[4]) == 'r' && ! IDENT_CHAR (src[5]))
     {
       *mode = FPSCR_N;
       return 5;
@@ -937,7 +937,7 @@ parse_reg_without_prefix (char *src, sh_arg_type *mode, int *reg)
 
   if (l0 == 'x' && l1 == 'm' && TOLOWER (src[2]) == 't'
       && TOLOWER (src[3]) == 'r'
-      && TOLOWER (src[4]) == 'x' && ! IDENT_CHAR ((unsigned char) src[5]))
+      && TOLOWER (src[4]) == 'x' && ! IDENT_CHAR (src[5]))
     {
       *mode = XMTRX_M4;
       return 5;
diff --git a/gas/config/tc-spu.c b/gas/config/tc-spu.c
index e189d1b88fa..f19ca7ee48f 100644
--- a/gas/config/tc-spu.c
+++ b/gas/config/tc-spu.c
@@ -569,7 +569,7 @@ get_reg (const char *param, struct spu_insn *insn, int arg, int accept_expr)
       char *save_ptr;
       expressionS ex;
       save_ptr = input_line_pointer;
-      input_line_pointer = (char *)param;
+      input_line_pointer = (char *) param;
       expression (&ex);
       param = input_line_pointer;
       input_line_pointer = save_ptr;
@@ -721,7 +721,7 @@ md_create_short_jump (char *ptr,
 		      fragS *frag,
 		      symbolS *to_symbol)
 {
-  ptr[0] = (char) 0xc0;
+  ptr[0] = 0xc0;
   ptr[1] = 0x00;
   ptr[2] = 0x00;
   ptr[3] = 0x00;
@@ -743,7 +743,7 @@ md_create_long_jump (char *ptr,
 		     fragS *frag,
 		     symbolS *to_symbol)
 {
-  ptr[0] = (char) 0xc0;
+  ptr[0] = 0xc0;
   ptr[1] = 0x00;
   ptr[2] = 0x00;
   ptr[3] = 0x00;
diff --git a/gas/config/tc-tic4x.c b/gas/config/tc-tic4x.c
index 22a4eb8007c..3a3123cbf6a 100644
--- a/gas/config/tc-tic4x.c
+++ b/gas/config/tc-tic4x.c
@@ -2814,7 +2814,7 @@ md_undefined_symbol (char *name)
       char *s = name + 1;
       int lab = 0;
 
-      while (ISDIGIT ((unsigned char) *s))
+      while (ISDIGIT (*s))
 	{
 	  lab = lab * 10 + *s - '0';
 	  s++;
diff --git a/gas/config/tc-tic6x.c b/gas/config/tc-tic6x.c
index b58074fbd00..0c88e60f8ae 100644
--- a/gas/config/tc-tic6x.c
+++ b/gas/config/tc-tic6x.c
@@ -3083,14 +3083,13 @@ static valueT
 md_chars_to_number (char *buf, int n)
 {
   valueT result = 0;
-  unsigned char *p = (unsigned char *) buf;
 
   if (target_big_endian)
     {
       while (n--)
 	{
 	  result <<= 8;
-	  result |= (*p++ & 0xff);
+	  result |= (*buf++ & 0xff);
 	}
     }
   else
@@ -3098,7 +3097,7 @@ md_chars_to_number (char *buf, int n)
       while (n--)
 	{
 	  result <<= 8;
-	  result |= (p[n] & 0xff);
+	  result |= (buf[n] & 0xff);
 	}
     }
 
diff --git a/gas/config/tc-tilegx.c b/gas/config/tc-tilegx.c
index 1392618c599..853e940b733 100644
--- a/gas/config/tc-tilegx.c
+++ b/gas/config/tc-tilegx.c
@@ -1678,7 +1678,7 @@ md_apply_fix (fixS *fixP, valueT * valP, segT seg ATTRIBUTE_UNUSED)
 	 ORing in values is OK since we know the existing bits for
 	 this operand are zero.  */
       for (; bits != 0; bits >>= 8)
-	*p++ |= (char)bits;
+	*p++ |= bits;
     }
   else
     {
diff --git a/gas/config/tc-v850.c b/gas/config/tc-v850.c
index d7f609f9fcd..8a86b1d2b89 100644
--- a/gas/config/tc-v850.c
+++ b/gas/config/tc-v850.c
@@ -1956,7 +1956,7 @@ md_begin (void)
     {
       if (strcmp (prev_name, op->name))
 	{
-	  prev_name = (char *) op->name;
+	  prev_name = op->name;
 	  str_hash_insert (v850_hash, op->name, op, 0);
 	}
       op++;
diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index 4b67f76289d..144016962cb 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -1903,7 +1903,7 @@ tc_get_register (const char *prefix)
       return ERROR_REG_NUM;
     }
 
-  if (!ISDIGIT ((unsigned char) *input_line_pointer))
+  if (!ISDIGIT (*input_line_pointer))
     {
       as_bad (_("bad register number: %s"), input_line_pointer);
       return ERROR_REG_NUM;
@@ -1911,7 +1911,7 @@ tc_get_register (const char *prefix)
 
   reg = 0;
 
-  while (ISDIGIT ((int) *input_line_pointer))
+  while (ISDIGIT (*input_line_pointer))
     reg = reg * 10 + *input_line_pointer++ - '0';
 
   if (!(next_expr = expression_end (input_line_pointer)))
diff --git a/gas/config/tc-z80.c b/gas/config/tc-z80.c
index 3abc0268699..7ffd82e0453 100644
--- a/gas/config/tc-z80.c
+++ b/gas/config/tc-z80.c
@@ -2966,10 +2966,10 @@ emit_lea (char prefix, char opcode, const char * args)
   switch (rnum)
     {
     case REG_IX:
-      opcode = (opcode == (char)0x33) ? 0x55 : (opcode|0x00);
+      opcode = opcode == 0x33 ? 0x55 : opcode | 0x00;
       break;
     case REG_IY:
-      opcode = (opcode == (char)0x32) ? 0x54 : (opcode|0x01);
+      opcode = opcode == 0x32 ? 0x54 : opcode | 0x01;
     }
 
   q = frag_more (2);
@@ -3420,7 +3420,7 @@ assemble_suffix (const char **suffix)
         i = 0x40;
         break;
     }
-  *frag_more (1) = (char)i;
+  *frag_more (1) = i;
   switch (i)
     {
     case 0x40: inst_mode = INST_MODE_FORCED | INST_MODE_S | INST_MODE_IS; break;
@@ -4064,8 +4064,8 @@ str_to_zeda32(char *litP, int *sizeP)
   else if (!sign)
     mantissa &= (1ull << 23) - 1;
   for (i = 0; i < 24; i += 8)
-    *litP++ = (char)(mantissa >> i);
-  *litP = (char)(0x80 + exponent);
+    *litP++ = mantissa >> i;
+  *litP = 0x80 + exponent;
   return NULL;
 }
 
@@ -4111,9 +4111,9 @@ str_to_float48(char *litP, int *sizeP)
     return _("overflow");
   if (!sign)
     mantissa &= (1ull << 39) - 1;
-  *litP++ = (char)(0x80 + exponent);
+  *litP++ = 0x80 + exponent;
   for (i = 0; i < 40; i += 8)
-    *litP++ = (char)(mantissa >> i);
+    *litP++ = mantissa >> i;
   return NULL;
 }
 
diff --git a/gas/ecoff.c b/gas/ecoff.c
index 235bb80aed6..db3d862deeb 100644
--- a/gas/ecoff.c
+++ b/gas/ecoff.c
@@ -3470,7 +3470,7 @@ ecoff_stab (int what,
 	  value = get_absolute_expression ();
 	  addend = 0;
 	}
-      else if (! is_name_beginner ((unsigned char) *input_line_pointer))
+      else if (! is_name_beginner (*input_line_pointer))
 	{
 	  as_warn (_("illegal .stab%c directive, bad character"), what);
 	  return;


More information about the Binutils-cvs mailing list