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]

Fix warnings and errors building libiberty with pcc on vax-dec-ultrix4.3


This is the first of a series of patch to fix the K&R compatibility of
binutils for building on vax-dec-ultrix4.3.  I have now a complete
set of patches that allow binutils to build with both pcc and gcc
with no regressions but they need documenting.

This patch enables building libiberty with pcc on vax-dec-ultrix4.3.  The
only show stoppers were the enum casts.  The other casts are just warning
fixes.

The patch has been tested with binutils builds with both pcc and gcc.

OK for main?

Dave
-- 
J. David Anglin                                  dave.anglin@nrc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6605)

2002-09-19  John David Anglin  <dave@hiuly1.hia.nrc.ca>

	* cp-demangle.c (demangling_new): Cast 0 to enum.
	(demangle_char): Cast return of strdup to char *.
	(is_gnu_v3_mangled_ctor): Cast 0 to enum.
	(is_gnu_v3_mangled_dtor): Likewise.
	* cplus-dem.c (grow_vect): Cast return of xrealloc to void *.
	(work_stuff_copy_to_from): Cast return of xmalloc to char **.
	* fibheap.c (fibnode_new): Cast return of xcalloc to fibnode_t.
	* md5.c (md5_process_bytes): Cast results back to const void *.
	(md5_process_block): Add cast to const md5_uint32 *.
	* regex.c (re_compile_fastmap): Cast enum to UCHAR_T.
	* safe-ctype.c (L, XL, U, XU, D, P, _, C, Z, M, V, T, S): Add cast to
	unsigned short.
	* splay-tree.c (splay_tree_xmalloc_allocate): Cast return of xmalloc
	to void *.
	* vasprintf.c (int_vasprintf): Cast return of malloc to char *.

Index: cp-demangle.c
===================================================================
RCS file: /cvs/src/src/libiberty/cp-demangle.c,v
retrieving revision 1.26
diff -u -3 -p -r1.26 cp-demangle.c
--- cp-demangle.c	10 Jul 2002 00:01:54 -0000	1.26
+++ cp-demangle.c	19 Sep 2002 21:59:56 -0000
@@ -835,8 +835,8 @@ demangling_new (name, style)
       return NULL;
     }
   dm->style = style;
-  dm->is_constructor = 0;
-  dm->is_destructor = 0;
+  dm->is_constructor = (enum gnu_v3_ctor_kinds) 0;
+  dm->is_destructor = (enum gnu_v3_dtor_kinds) 0;
 
   return dm;
 }
@@ -974,7 +974,7 @@ demangle_char (dm, c)
   else
     {
       if (error_message == NULL)
-	error_message = strdup ("Expected ?");
+	error_message = (char *) strdup ("Expected ?");
       error_message[9] = c;
       return error_message;
     }
@@ -3974,7 +3974,7 @@ is_gnu_v3_mangled_ctor (name)
       return result;
     }
   else
-    return 0;
+    return (enum gnu_v3_ctor_kinds) 0;
 }
 
 
@@ -3996,7 +3996,7 @@ is_gnu_v3_mangled_dtor (name)
       return result;
     }
   else
-    return 0;
+    return (enum gnu_v3_dtor_kinds) 0;
 }
 #endif /* IN_GLIBCPP_V3 */
 
Index: cplus-dem.c
===================================================================
RCS file: /cvs/src/src/libiberty/cplus-dem.c,v
retrieving revision 1.33
diff -u -3 -p -r1.33 cplus-dem.c
--- cplus-dem.c	12 Sep 2002 01:11:20 -0000	1.33
+++ cplus-dem.c	19 Sep 2002 22:00:03 -0000
@@ -946,7 +946,7 @@ grow_vect (old_vect, size, min_size, ele
       *size *= 2;
       if (*size < min_size)
 	*size = min_size;
-      *old_vect = xrealloc (*old_vect, *size * element_size);
+      *old_vect = (void *) xrealloc (*old_vect, *size * element_size);
     }
 }
 
@@ -1206,7 +1206,7 @@ work_stuff_copy_to_from (to, from)
 
   if (from->ntmpl_args)
     to->tmpl_argvec
-      = xmalloc (from->ntmpl_args * sizeof (to->tmpl_argvec[0]));
+      = (char **) xmalloc (from->ntmpl_args * sizeof (to->tmpl_argvec[0]));
 
   for (i = 0; i < from->ntmpl_args; i++)
     {
Index: fibheap.c
===================================================================
RCS file: /cvs/src/src/libiberty/fibheap.c,v
retrieving revision 1.3
diff -u -3 -p -r1.3 fibheap.c
--- fibheap.c	22 Aug 2001 22:55:38 -0000	1.3
+++ fibheap.c	19 Sep 2002 22:00:04 -0000
@@ -66,7 +66,7 @@ fibnode_new ()
 {
   fibnode_t node;
 
-  node = xcalloc (1, sizeof *node);
+  node = (fibnode_t) xcalloc (1, sizeof *node);
   node->left = node;
   node->right = node;
 
Index: md5.c
===================================================================
RCS file: /cvs/src/src/libiberty/md5.c,v
retrieving revision 1.4
diff -u -3 -p -r1.4 md5.c
--- md5.c	9 May 2001 20:08:48 -0000	1.4
+++ md5.c	19 Sep 2002 22:00:05 -0000
@@ -229,7 +229,7 @@ md5_process_bytes (buffer, len, ctx)
 	  ctx->buflen = (left_over + add) & 63;
 	}
 
-      buffer = (const char *) buffer + add;
+      buffer = (const void *) ((const char *) buffer + add);
       len -= add;
     }
 
@@ -237,7 +237,7 @@ md5_process_bytes (buffer, len, ctx)
   if (len > 64)
     {
       md5_process_block (buffer, len & ~63, ctx);
-      buffer = (const char *) buffer + (len & ~63);
+      buffer = (const void *) ((const char *) buffer + (len & ~63));
       len &= 63;
     }
 
@@ -269,7 +269,7 @@ md5_process_block (buffer, len, ctx)
      struct md5_ctx *ctx;
 {
   md5_uint32 correct_words[16];
-  const md5_uint32 *words = buffer;
+  const md5_uint32 *words = (const md5_uint32 *) buffer;
   size_t nwords = len / sizeof (md5_uint32);
   const md5_uint32 *endp = words + nwords;
   md5_uint32 A = ctx->A;
Index: regex.c
===================================================================
RCS file: /cvs/src/src/libiberty/regex.c,v
retrieving revision 1.10
diff -u -3 -p -r1.10 regex.c
--- regex.c	6 Sep 2002 00:03:11 -0000	1.10
+++ regex.c	19 Sep 2002 22:00:20 -0000
@@ -4648,7 +4648,7 @@ PREFIX(re_compile_fastmap) (bufp)
 
   while (1)
     {
-      if (p == pend || *p == succeed)
+      if (p == pend || *p == (UCHAR_T) succeed)
 	{
 	  /* We have reached the (effective) end of pattern.  */
 	  if (!FAIL_STACK_EMPTY ())
Index: safe-ctype.c
===================================================================
RCS file: /cvs/src/src/libiberty/safe-ctype.c,v
retrieving revision 1.2
diff -u -3 -p -r1.2 safe-ctype.c
--- safe-ctype.c	17 Dec 2000 03:07:49 -0000	1.2
+++ safe-ctype.c	19 Sep 2002 22:00:22 -0000
@@ -48,20 +48,20 @@ Boston, MA 02111-1307, USA.  */
 #define xd _sch_isxdigit
 
 /* Masks.  */
-#define L  lo|is   |pr	/* lower case letter */
-#define XL lo|is|xd|pr	/* lowercase hex digit */
-#define U  up|is   |pr	/* upper case letter */
-#define XU up|is|xd|pr	/* uppercase hex digit */
-#define D  di   |xd|pr	/* decimal digit */
-#define P  pn      |pr	/* punctuation */
-#define _  pn|is   |pr	/* underscore */
+#define L  (const unsigned short) (lo|is   |pr)	/* lower case letter */
+#define XL (const unsigned short) (lo|is|xd|pr)	/* lowercase hex digit */
+#define U  (const unsigned short) (up|is   |pr)	/* upper case letter */
+#define XU (const unsigned short) (up|is|xd|pr)	/* uppercase hex digit */
+#define D  (const unsigned short) (di   |xd|pr)	/* decimal digit */
+#define P  (const unsigned short) (pn      |pr)	/* punctuation */
+#define _  (const unsigned short) (pn|is   |pr)	/* underscore */
 
-#define C           cn	/* control character */
-#define Z  nv      |cn	/* NUL */
-#define M  nv|sp   |cn	/* cursor movement: \f \v */
-#define V  vs|sp   |cn	/* vertical space: \r \n */
-#define T  nv|sp|bl|cn	/* tab */
-#define S  nv|sp|bl|pr	/* space */
+#define C  (const unsigned short) (         cn)	/* control character */
+#define Z  (const unsigned short) (nv      |cn)	/* NUL */
+#define M  (const unsigned short) (nv|sp   |cn)	/* cursor movement: \f \v */
+#define V  (const unsigned short) (vs|sp   |cn)	/* vertical space: \r \n */
+#define T  (const unsigned short) (nv|sp|bl|cn)	/* tab */
+#define S  (const unsigned short) (nv|sp|bl|pr)	/* space */
 
 /* Are we ASCII? */
 #if '\n' == 0x0A && ' ' == 0x20 && '0' == 0x30 \
Index: splay-tree.c
===================================================================
RCS file: /cvs/src/src/libiberty/splay-tree.c,v
retrieving revision 1.10
diff -u -3 -p -r1.10 splay-tree.c
--- splay-tree.c	12 Sep 2002 01:11:20 -0000	1.10
+++ splay-tree.c	19 Sep 2002 22:00:23 -0000
@@ -234,7 +234,7 @@ splay_tree_xmalloc_allocate (size, data)
      int size;
      void *data ATTRIBUTE_UNUSED;
 {
-  return xmalloc (size);
+  return (void *) xmalloc (size);
 }
 
 static void
Index: vasprintf.c
===================================================================
RCS file: /cvs/src/src/libiberty/vasprintf.c,v
retrieving revision 1.6
diff -u -3 -p -r1.6 vasprintf.c
--- vasprintf.c	17 Oct 2001 22:35:28 -0000	1.6
+++ vasprintf.c	19 Sep 2002 22:00:23 -0000
@@ -138,7 +138,7 @@ int_vasprintf (result, format, args)
 #ifdef TEST
   global_total_width = total_width;
 #endif
-  *result = malloc (total_width);
+  *result = (char *) malloc (total_width);
   if (*result != NULL)
     return vsprintf (*result, format, *args);
   else


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