This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

more opcodes/ warning fixes


opcodes/ChangeLog
	* arm-dis.c (print_insn_arm): Constify "insn".  Formatting.
	(print_insn_thumb): Likewise.
	* h8500-dis.c (print_insn_h8500): Constify "opcode".
	* mcore-dis.c (print_insn_mcore): Constify "op".  Formatting.
	* ns32k-dis.c (print_insn_arg <case 'F'>): Use a union to avoid
	type-punned pointer warnings.
	<case 'L'>: Likewise.  Fix error message too.
	* pdp11-dis.c (print_reg): Warning fix.
	* sh-dis.c (print_movxy): Constify "op" param.
	(print_insn_ddt): Constify sh_opcode_info vars.
	(print_insn_ppi): Likewise.
	(print_insn_sh): Likewise.
	* tic30-dis.c (cnvt_tmsfloat_ieee): Use a union to avoid
	type-punned pointer warnings.
	* w65-dis.c (print_insn_w65): Constify "op".

Index: opcodes/arm-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/arm-dis.c,v
retrieving revision 1.29
diff -u -p -r1.29 arm-dis.c
--- opcodes/arm-dis.c	30 Nov 2002 08:39:46 -0000	1.29
+++ opcodes/arm-dis.c	2 Dec 2002 12:57:52 -0000
@@ -172,13 +172,13 @@ arm_decode_shift (given, func, stream)
 
 static int
 print_insn_arm (pc, info, given)
-     bfd_vma                   pc;
-     struct disassemble_info * info;
-     long                      given;
+     bfd_vma pc;
+     struct disassemble_info *info;
+     long given;
 {
-  struct arm_opcode *  insn;
-  void *               stream = info->stream;
-  fprintf_ftype        func   = info->fprintf_func;
+  const struct arm_opcode *insn;
+  void *stream = info->stream;
+  fprintf_ftype func   = info->fprintf_func;
 
   for (insn = arm_opcodes; insn->assembler; insn++)
     {
@@ -753,13 +753,13 @@ print_insn_arm (pc, info, given)
 
 static int
 print_insn_thumb (pc, info, given)
-     bfd_vma                   pc;
-     struct disassemble_info * info;
-     long                      given;
+     bfd_vma pc;
+     struct disassemble_info *info;
+     long given;
 {
-  struct thumb_opcode * insn;
-  void *                stream = info->stream;
-  fprintf_ftype         func = info->fprintf_func;
+  const struct thumb_opcode *insn;
+  void *stream = info->stream;
+  fprintf_ftype func = info->fprintf_func;
 
   for (insn = thumb_opcodes; insn->assembler; insn++)
     {
Index: opcodes/h8500-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/h8500-dis.c,v
retrieving revision 1.5
diff -u -p -r1.5 h8500-dis.c
--- opcodes/h8500-dis.c	26 Aug 2001 11:47:39 -0000	1.5
+++ opcodes/h8500-dis.c	2 Dec 2002 12:57:56 -0000
@@ -78,7 +78,7 @@ print_insn_h8500 (addr, info)
      bfd_vma addr;
      disassemble_info *info;
 {
-  h8500_opcode_info *opcode;
+  const h8500_opcode_info *opcode;
   void *stream = info->stream;
   fprintf_ftype func = info->fprintf_func;
 
Index: opcodes/mcore-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/mcore-dis.c,v
retrieving revision 1.16
diff -u -p -r1.16 mcore-dis.c
--- opcodes/mcore-dis.c	13 Aug 2001 08:09:58 -0000	1.16
+++ opcodes/mcore-dis.c	2 Dec 2002 12:58:03 -0000
@@ -1,5 +1,5 @@
 /* Disassemble Motorola M*Core instructions.
-   Copyright 1993, 1999, 2000 Free Software Foundation, Inc.
+   Copyright 1993, 1999, 2000, 2002 Free Software Foundation, Inc.
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
@@ -89,12 +89,12 @@ print_insn_mcore (memaddr, info)
      bfd_vma memaddr;
      struct disassemble_info *info;
 {
-  unsigned char       ibytes[4];
-  fprintf_ftype       fprintf = info->fprintf_func;
-  void *              stream = info->stream;
-  unsigned short      inst;
-  mcore_opcode_info * op;
-  int                 status;
+  unsigned char ibytes[4];
+  fprintf_ftype fprintf = info->fprintf_func;
+  void *stream = info->stream;
+  unsigned short inst;
+  const mcore_opcode_info *op;
+  int status;
 
   info->bytes_per_chunk = 2;
 
@@ -128,19 +128,48 @@ print_insn_mcore (memaddr, info)
 
       switch (op->opclass)
 	{
-	case O0: break;
-	case OT: fprintf (stream, "\t%d", inst & 0x3); break;
+	case O0:
+	  break;
+
+	case OT:
+	  fprintf (stream, "\t%d", inst & 0x3);
+	  break;
+
 	case O1:
 	case JMP:
-	case JSR: fprintf (stream, "\t%s", name); break;
-	case OC:  fprintf (stream, "\t%s, %s", name, crname[(inst >> 4) & 0x1F]); break;
-	case O1R1: fprintf (stream, "\t%s, r1", name); break;
+	case JSR:
+	  fprintf (stream, "\t%s", name);
+	  break;
+
+	case OC:
+	  fprintf (stream, "\t%s, %s", name, crname[(inst >> 4) & 0x1F]);
+	  break;
+
+	case O1R1:
+	  fprintf (stream, "\t%s, r1", name);
+	  break;
+
 	case MULSH:
-	case O2: fprintf (stream, "\t%s, %s", name, grname[(inst >> 4) & 0xF]); break;
-	case X1: fprintf (stream, "\tr1, %s", name); break;
-	case OI: fprintf (stream, "\t%s, %d", name, ((inst >> 4) & 0x1F) + 1); break;
-	case RM: fprintf (stream, "\t%s-r15, (r0)", name); break;
-	case RQ: fprintf (stream, "\tr4-r7, (%s)", name); break;
+	case O2:
+	  fprintf (stream, "\t%s, %s", name, grname[(inst >> 4) & 0xF]);
+	  break;
+
+	case X1:
+	  fprintf (stream, "\tr1, %s", name);
+	  break;
+
+	case OI:
+	  fprintf (stream, "\t%s, %d", name, ((inst >> 4) & 0x1F) + 1);
+	  break;
+
+	case RM:
+	  fprintf (stream, "\t%s-r15, (r0)", name);
+	  break;
+
+	case RQ:
+	  fprintf (stream, "\tr4-r7, (%s)", name);
+	  break;
+
 	case OB:
 	case OBRa:
 	case OBRb:
@@ -149,10 +178,17 @@ print_insn_mcore (memaddr, info)
 	case SIa:
 	case OMa:
 	case OMb:
-	case OMc: fprintf (stream, "\t%s, %d", name, (inst >> 4) & 0x1F); break;
-	case I7: fprintf (stream, "\t%s, %d", name, (inst >> 4) & 0x7F); break;
-	case LS: fprintf (stream, "\t%s, (%s, %d)", grname[(inst >> 8) & 0xF],
-			  name, ((inst >> 4) & 0xF) << isiz[(inst >> 13) & 3]);
+	case OMc:
+	  fprintf (stream, "\t%s, %d", name, (inst >> 4) & 0x1F);
+	  break;
+
+	case I7:
+	  fprintf (stream, "\t%s, %d", name, (inst >> 4) & 0x7F);
+	  break;
+
+	case LS:
+	  fprintf (stream, "\t%s, (%s, %d)", grname[(inst >> 8) & 0xF],
+		   name, ((inst >> 4) & 0xF) << isiz[(inst >> 13) & 3]);
 	  break;
 
 	case BR:
Index: opcodes/ns32k-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/ns32k-dis.c,v
retrieving revision 1.4
diff -u -p -r1.4 ns32k-dis.c
--- opcodes/ns32k-dis.c	20 Sep 2001 15:28:25 -0000	1.4
+++ opcodes/ns32k-dis.c	2 Dec 2002 12:58:03 -0000
@@ -556,10 +556,13 @@ print_insn_arg (d, ioffset, aoffsetp, bu
      char *result;
      int index_offset;
 {
-  int addr_mode;
-  float Fvalue;
-  double Lvalue;
+  union {
+    float f;
+    double d;
+    int i[2];
+  } value;
   int Ivalue;
+  int addr_mode;
   int disp1, disp2;
   int index;
   int size;
@@ -647,23 +650,23 @@ print_insn_arg (d, ioffset, aoffsetp, bu
 	      sprintf (result, "$%d", Ivalue);
 	      break;
 	    case 'F':
-	      bit_copy (buffer, *aoffsetp, 32, (char *) &Fvalue);
-	      flip_bytes ((char *) & Fvalue, 4);
+	      bit_copy (buffer, *aoffsetp, 32, (char *) &value.f);
+	      flip_bytes ((char *) &value.f, 4);
 	      *aoffsetp += 32;
-	      if (INVALID_FLOAT (&Fvalue, 4))
-		sprintf (result, "<<invalid float 0x%.8x>>", *(int *) &Fvalue);
+	      if (INVALID_FLOAT (&value.f, 4))
+		sprintf (result, "<<invalid float 0x%.8x>>", value.i[0]);
 	      else /* assume host has ieee float */
-		sprintf (result, "$%g", Fvalue);
+		sprintf (result, "$%g", value.f);
 	      break;
 	    case 'L':
-	      bit_copy (buffer, *aoffsetp, 64, (char *) &Lvalue);
-	      flip_bytes ((char *) & Lvalue, 8);
+	      bit_copy (buffer, *aoffsetp, 64, (char *) &value.d);
+	      flip_bytes ((char *) &value.d, 8);
 	      *aoffsetp += 64;
-	      if (INVALID_FLOAT (&Lvalue, 8))
-		sprintf (result, "<<invalid long 0x%.8x%.8x>>",
-			 *(((int *) &Lvalue) + 1), *(int *) &Lvalue);
+	      if (INVALID_FLOAT (&value.d, 8))
+		sprintf (result, "<<invalid double 0x%.8x%.8x>>",
+			 value.i[1], value.i[0]);
 	      else /* assume host has ieee float */
-		sprintf (result, "$%g", Lvalue);
+		sprintf (result, "$%g", value.d);
 	      break;
 	    }
 	  break;
Index: opcodes/pdp11-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/pdp11-dis.c,v
retrieving revision 1.4
diff -u -p -r1.4 pdp11-dis.c
--- opcodes/pdp11-dis.c	5 Mar 2002 03:09:53 -0000	1.4
+++ opcodes/pdp11-dis.c	2 Dec 2002 12:58:05 -0000
@@ -84,7 +84,7 @@ print_reg (reg, info)
 		FPRINTF (F, "r%d", reg); break;
     case 6:	FPRINTF (F, "sp"); break;
     case 7:	FPRINTF (F, "pc"); break;
-    default:	/* error */
+    default: ;	/* error */
     }
 }
 
Index: opcodes/sh-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/sh-dis.c,v
retrieving revision 1.14
diff -u -p -r1.14 sh-dis.c
--- opcodes/sh-dis.c	30 Nov 2002 08:39:46 -0000	1.14
+++ opcodes/sh-dis.c	2 Dec 2002 12:58:05 -0000
@@ -29,14 +29,14 @@ Foundation, Inc., 59 Temple Place - Suit
 #endif
 
 static void print_movxy
-  PARAMS ((sh_opcode_info *, int, int, fprintf_ftype, void *));
+  PARAMS ((const sh_opcode_info *, int, int, fprintf_ftype, void *));
 static void print_insn_ddt PARAMS ((int, struct disassemble_info *));
 static void print_dsp_reg PARAMS ((int, fprintf_ftype, void *));
 static void print_insn_ppi PARAMS ((int, struct disassemble_info *));
 
 static void
 print_movxy (op, rn, rm, fprintf_fn, stream)
-     sh_opcode_info *op;
+     const sh_opcode_info *op;
      int rn, rm;
      fprintf_ftype fprintf_fn;
      void *stream;
@@ -105,8 +105,8 @@ print_insn_ddt (insn, info)
     fprintf_fn (stream, ".word 0x%x", insn);
   else
     {
-      static sh_opcode_info *first_movx, *first_movy;
-      sh_opcode_info *opx, *opy;
+      static const sh_opcode_info *first_movx, *first_movy;
+      const sh_opcode_info *opx, *opy;
       unsigned int insn_x, insn_y;
 
       if (! first_movx)
@@ -192,7 +192,7 @@ print_insn_ppi (field_b, info)
   void *stream = info->stream;
   unsigned int nib1, nib2, nib3;
   char *dc = NULL;
-  sh_opcode_info *op;
+  const sh_opcode_info *op;
 
   if ((field_b & 0xe800) == 0)
     {
@@ -298,7 +298,7 @@ print_insn_sh (memaddr, info)
   unsigned char nibs[4];
   int status;
   bfd_vma relmask = ~(bfd_vma) 0;
-  sh_opcode_info *op;
+  const sh_opcode_info *op;
   int target_arch;
 
   switch (info->mach)
Index: opcodes/tic30-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/tic30-dis.c,v
retrieving revision 1.4
diff -u -p -r1.4 tic30-dis.c
--- opcodes/tic30-dis.c	13 Mar 2001 22:58:37 -0000	1.4
+++ opcodes/tic30-dis.c	2 Dec 2002 12:58:05 -0000
@@ -663,6 +663,10 @@ cnvt_tmsfloat_ieee (tmsfloat, size, ieee
      float *ieeefloat;
 {
   unsigned long exp, sign, mant;
+  union {
+    unsigned long l;
+    float f;
+  } val;
 
   if (size == 2)
     {
@@ -705,6 +709,7 @@ cnvt_tmsfloat_ieee (tmsfloat, size, ieee
   if (tmsfloat == 0x80000000)
     sign = mant = exp = 0;
   tmsfloat = sign | exp | mant;
-  *ieeefloat = *((float *) &tmsfloat);
+  val.l = tmsfloat;
+  *ieeefloat = val.f;
   return 1;
 }
Index: opcodes/w65-dis.c
===================================================================
RCS file: /cvs/src/src/opcodes/w65-dis.c,v
retrieving revision 1.5
diff -u -p -r1.5 w65-dis.c
--- opcodes/w65-dis.c	26 Aug 2001 11:47:39 -0000	1.5
+++ opcodes/w65-dis.c	2 Dec 2002 12:58:07 -0000
@@ -84,7 +84,7 @@ print_insn_w65 (memaddr, info)
 {
   int status = 0;
   unsigned char insn[4];
-  register struct opinfo *op;
+  const struct opinfo *op;
   int i;
   int X = 0;
   int M = 0;

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]