aboutsummaryrefslogtreecommitdiff
blob: 0297468e447db60084c66d2fdeaf5188c8fa3bbb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
From bb37062f41610518ad294049736488e122906ea6 Mon Sep 17 00:00:00 2001
From: ghazi <ghazi@138bc75d-0d04-0410-961f-82ee72b054a4>
Date: Fri, 21 Jul 2000 20:08:36 +0000
Subject: [PATCH] Warning fixes:

	* cp-demangle.c (cp_demangle_type): Wrap in IN_LIBGCC2.

	* setenv.c (setenv): Initialize variable `ep'.

	* sigsetmask.c (abort): Prototype.

	* vasprintf.c: Include config.h.  Check ANSI_PROTOTYPES, not
	__STDC__ for stdarg.h include.
	(int_vasprintf): Prototype.
	(checkit): Prototype.  Use VPARAMS/ANSI_PROTOTYPES/VA_START in
	definition.  Cast `global_total_width' in comparison.
	(main): Prototype.  Return a value.

	* vfork.c (fork): Prototype.

	* xexit.c: Include config.h.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@35178 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libiberty/ChangeLog     | 19 +++++++++++++++++
 libiberty/cp-demangle.c |  6 +++---
 libiberty/setenv.c      |  2 +-
 libiberty/sigsetmask.c  |  2 ++
 libiberty/vasprintf.c   | 54 ++++++++++++++++++++++++++++++-------------------
 libiberty/vfork.c       |  4 ++++
 libiberty/xexit.c       |  8 +++++---
 7 files changed, 67 insertions(+), 28 deletions(-)

2000-07-21  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* cp-demangle.c (cp_demangle_type): Wrap in IN_LIBGCC2.

	* setenv.c (setenv): Initialize variable `ep'.

	* sigsetmask.c (abort): Prototype.

	* vasprintf.c: Include config.h.  Check ANSI_PROTOTYPES, not
	__STDC__ for stdarg.h include.
	(int_vasprintf): Prototype.
	(checkit): Prototype.  Use VPARAMS/ANSI_PROTOTYPES/VA_START in
	definition.  Cast `global_total_width' in comparison.
	(main): Prototype.  Return a value.

	* vfork.c (fork): Prototype.

	* xexit.c: Include config.h.

diff --git a/libiberty/setenv.c b/libiberty/setenv.c
index a90c83a..f025716 100644
--- a/libiberty/setenv.c
+++ b/libiberty/setenv.c
@@ -63,7 +63,7 @@ setenv (name, value, replace)
      const char *value;
      int replace;
 {
-  register char **ep;
+  register char **ep = 0;
   register size_t size;
   const size_t namelen = strlen (name);
   const size_t vallen = strlen (value) + 1;
diff --git a/libiberty/sigsetmask.c b/libiberty/sigsetmask.c
index 2a09e6a..db6408d 100644
--- a/libiberty/sigsetmask.c
+++ b/libiberty/sigsetmask.c
@@ -12,6 +12,8 @@
 #include <sys/types.h>
 #include <signal.h>
 
+extern void abort PARAMS ((void)) ATTRIBUTE_NORETURN;
+
 #ifdef SIG_SETMASK
 int
 DEFUN(sigsetmask,(set),
diff --git a/libiberty/vasprintf.c b/libiberty/vasprintf.c
index b959f5f..c34585d 100644
--- a/libiberty/vasprintf.c
+++ b/libiberty/vasprintf.c
@@ -18,21 +18,31 @@ License along with libiberty; see the file COPYING.LIB.  If
 not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-#ifdef __STDC__
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <ansidecl.h>
+#ifdef ANSI_PROTOTYPES
 #include <stdarg.h>
 #else
 #include <varargs.h>
 #endif
 #include <stdio.h>
 #include <string.h>
-#include <ansidecl.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#else
+extern unsigned long strtoul ();
+extern PTR malloc ();
+#endif
+#include "libiberty.h"
 
 #ifdef TEST
 int global_total_width;
 #endif
 
-unsigned long strtoul ();
-char *malloc ();
+
+static int int_vasprintf PARAMS ((char **, const char *, va_list *));
 
 static int
 int_vasprintf (result, format, args)
@@ -60,7 +70,7 @@ int_vasprintf (result, format, args)
 	      total_width += abs (va_arg (ap, int));
 	    }
 	  else
-	    total_width += strtoul (p, &p, 10);
+	    total_width += strtoul (p, (char **) &p, 10);
 	  if (*p == '.')
 	    {
 	      ++p;
@@ -70,7 +80,7 @@ int_vasprintf (result, format, args)
 		  total_width += abs (va_arg (ap, int));
 		}
 	      else
-	      total_width += strtoul (p, &p, 10);
+	      total_width += strtoul (p, (char **) &p, 10);
 	    }
 	  while (strchr ("hlL", *p))
 	    ++p;
@@ -132,33 +142,33 @@ vasprintf (result, format, args)
 }
 
 #ifdef TEST
-void
-checkit
-#ifdef __STDC__
-     (const char* format, ...)
-#else
-     (va_alist)
-     va_dcl
-#endif
+static void checkit PARAMS ((const char *, ...));
+
+static void
+checkit VPARAMS ((const char* format, ...))
 {
   va_list args;
   char *result;
+#ifndef ANSI_PROTOTYPES
+  const char *format;
+#endif
 
-#ifdef __STDC__
-  va_start (args, format);
-#else
-  char *format;
-  va_start (args);
-  format = va_arg (args, char *);
+  VA_START (args, format);
+
+#ifndef ANSI_PROTOTYPES
+  format = va_arg (args, const char *);
 #endif
+
   vasprintf (&result, format, args);
-  if (strlen (result) < global_total_width)
+  if (strlen (result) < (size_t) global_total_width)
     printf ("PASS: ");
   else
     printf ("FAIL: ");
   printf ("%d %s\n", global_total_width, result);
 }
 
+extern int main PARAMS ((void));
+
 int
 main ()
 {
@@ -169,5 +179,7 @@ main ()
   checkit ("%s", "jjjjjjjjjiiiiiiiiiiiiiiioooooooooooooooooppppppppppppaa\n\
 777777777777777777333333333333366666666666622222222222777777777777733333");
   checkit ("%f%s%d%s", 1.0, "foo", 77, "asdjffffffffffffffiiiiiiiiiiixxxxx");
+
+  return 0;
 }
 #endif /* TEST */
diff --git a/libiberty/vfork.c b/libiberty/vfork.c
index 86c4591..5e877210 100644
--- a/libiberty/vfork.c
+++ b/libiberty/vfork.c
@@ -1,6 +1,10 @@
 /* Emulate vfork using just plain fork, for systems without a real vfork.
    This function is in the public domain. */
 
+#include "ansidecl.h"
+
+extern int fork PARAMS ((void));
+
 int
 vfork ()
 {
diff --git a/libiberty/xexit.c b/libiberty/xexit.c
index 7aa52ac..e8b1ed1 100644
--- a/libiberty/xexit.c
+++ b/libiberty/xexit.c
@@ -17,13 +17,15 @@ License along with libiberty; see the file COPYING.LIB.  If not, write
 to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  */
 
-#include "ansidecl.h"
-#include "libiberty.h"
-
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #include <stdio.h>
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
+#include "libiberty.h"
+
 
 /* This variable is set by xatexit if it is called.  This way, xmalloc
    doesn't drag xatexit into the link.  */
-- 
1.8.0