This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Warning fixes for libiberty


I got:
In file included from /cvs/gcc/libiberty/getopt1.c:27:
/cvs/gcc/include/getopt.h:116: warning: function declaration isn't a prototype

The warning comes from the wrong order of includes - we only declare
getopt.h if __GNU_LIBRARY__ is not defined and that one only gets
defined after inclusion of another header.

Two more warnings:
/cvs/gcc/libiberty/getpwd.c:43: warning: function declaration isn't a prototype
/cvs/gcc/libiberty/getpwd.c:44: warning: function declaration isn't a prototype

include/libiberty has already:
extern char * getpwd (void);

So, the first can be removed completly - and if we move the second so
that it's only declared if needed, we get rid of both.

Initially tested on Linux/x86-64, complete bootstrap/regtest in
progress.  Ok to commit if it passes?

Btw. this leaves the following warnings in libiberty on my system:
/cvs/gcc/include/xregex2.h:538: warning: ISO C90 does not support `static' or type qualifiers in parameter array declarators
/cvs/gcc/libiberty/regex.c:4485: warning: signed and unsigned type in conditional expression
/cvs/gcc/libiberty/regex.c:4495: warning: signed and unsigned type in conditional expression
/cvs/gcc/libiberty/regex.c:4495: warning: signed and unsigned type in conditional expression
/cvs/gcc/libiberty/regex.c:7817: warning: return discards qualifiers from pointer target type
/cvs/gcc/libiberty/pexecute.c:50: warning: assignment discards qualifiers from pointer target type
/cvs/gcc/libiberty/pexecute.c:61: warning: assignment discards qualifiers from pointer target type

The pexecute ones can be fixed with changing the pexecute interface -
and I'm not sure whether we want that one.  The change would be
something like:
extern int pexecute (const char *, char * const *, const char *,
-                     const char *, char **, char **, int);
+                     const char *, char * const *, char * const *, int);

I could prepare a patch if wanted.

For the regex warnings I see no direct solution - somebody else might
want to look into it,

Andreas

2005-05-16  Andreas Jaeger  <aj@suse.de>

	* getpwd.c: Remove unneeded prototype getcwd and move getwd so
	that it's only declared if needed.

	* getopt1.c: Change order of includes so that __GNU_LIBRARY__ is
	defined.

============================================================
Index: libiberty/getpwd.c
--- libiberty/getpwd.c	27 Mar 2005 15:31:12 -0000	1.6
+++ libiberty/getpwd.c	16 May 2005 07:34:08 -0000
@@ -39,10 +39,6 @@ extern int errno;
 #include <limits.h>
 #endif
 
-/* Prototype these in case the system headers don't provide them. */
-extern char *getpwd ();
-extern char *getwd ();
-
 #include "libiberty.h"
 
 /* Virtually every UN*X system now in common use (except for pre-4.3-tahoe
@@ -50,6 +46,8 @@ extern char *getwd ();
    the few exceptions to the general rule here.  */
 
 #if !defined(HAVE_GETCWD) && defined(HAVE_GETWD)
+/* Prototype in case the system headers doesn't provide it. */
+extern char *getwd ();
 #define getcwd(buf,len) getwd(buf)
 #endif
 
============================================================
Index: libiberty/getopt1.c
--- libiberty/getopt1.c	10 May 2005 15:33:17 -0000	1.8
+++ libiberty/getopt1.c	16 May 2005 07:34:08 -0000
@@ -1,5 +1,5 @@
 /* getopt_long and getopt_long_only entry points for GNU getopt.
-   Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98
+   Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2005
      Free Software Foundation, Inc.
 
    NOTE: This source is derived from an old version taken from the GNU C
@@ -24,8 +24,6 @@
 #include <config.h>
 #endif
 
-#include "getopt.h"
-
 #if !defined __STDC__ || !__STDC__
 /* This is a separate conditional since some stdc systems
    reject `defined (const)'.  */
@@ -36,6 +34,8 @@
 
 #include <stdio.h>
 
+#include "getopt.h"
+
 /* Comment out all this code if we are using the GNU C Library, and are not
    actually compiling the library itself.  This code is part of the GNU C
    Library, but also included in many other GNU distributions.  Compiling

-- 
 Andreas Jaeger, aj@suse.de, http://www.suse.de/~aj
  SUSE Linux Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
   GPG fingerprint = 93A3 365E CE47 B889 DF7F  FED1 389A 563C C272 A126

Attachment: pgp00000.pgp
Description: PGP signature


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