]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
build: add configure-time --enable-gcc-warnings option; avoid warnings
authorJim Meyering <meyering@redhat.com>
Wed, 12 Nov 2008 10:11:54 +0000 (11:11 +0100)
committerJim Meyering <meyering@redhat.com>
Sun, 21 Dec 2008 16:49:58 +0000 (17:49 +0100)
* bootstrap.conf (gnulib_modules): Add "warnings" module.
* configure.ac: Add --enable-gcc-warnings, derived from code in bison.
* src/Makefile.am (AM_CFLAGS): Set to $(WARN_CFLAGS) # $(WERROR_CFLAGS)
* lib/Makefile.am (AM_CFLAGS): Change spelling to $(WARN_CFLAGS)
Don't use $(WERROR_CFLAGS), yet.
* src/system.h (usage): Declare.
* src/base64.c (usage): Declare to be global, for consistency.
* src/timeout.c (usage): Likewise.
* src/truncate.c (usage): Likewise.
* src/getlimits.c (usage): Likewise.
* src/pinky.c (ttyname): Declare with prototype, rather than an
empty argument list.
* src/who.c (ttyname): Likewise.
* src/su.c (crypt, getusershell, setusershell, endusershell): Likewise.

12 files changed:
bootstrap.conf
configure.ac
lib/Makefile.am
src/Makefile.am
src/base64.c
src/getlimits.c
src/pinky.c
src/su.c
src/system.h
src/timeout.c
src/truncate.c
src/who.c

index a3687d00f14562cbe27fc476d5a8112c3960d1df..2fa7f0d307fc5ce8eb9d95d437e98d339c816633 100644 (file)
@@ -100,6 +100,7 @@ gnulib_modules="
        vasprintf-posix
        vc-list-files
        verify version-etc-fsf
+       warnings
        wcwidth winsz-ioctl winsz-termios write-any-file
        xalloc
        xfreopen
index 549c7ee2c5ebe399bfd6b2bda446162d005c7443..f165893a065de392c8df750d612a4f68f12b0a38 100644 (file)
@@ -44,6 +44,39 @@ gl_EARLY
 gl_INIT
 coreutils_MACROS
 
+AC_ARG_ENABLE([gcc-warnings],
+  [AS_HELP_STRING([--enable-gcc-warnings],
+                 [turn on lots of GCC warnings (not recommended)])],
+  [case $enableval in
+     yes|no) ;;
+     *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
+   esac
+   gl_gcc_warnings=$enableval],
+  [gl_gcc_warnings=no]
+)
+
+if test "$gl_gcc_warnings" = yes; then
+  gl_WARN_ADD([-Werror], [WERROR_CFLAGS])
+  AC_SUBST([WERROR_CFLAGS])
+  gl_WARN_ADD([-Wall])
+  gl_WARN_ADD([-Wextra])
+  gl_WARN_ADD([-Wshadow])
+  gl_WARN_ADD([-Wno-sign-compare])
+  gl_WARN_ADD([-Wformat])
+  gl_WARN_ADD([-Wformat-security])
+  gl_WARN_ADD([-Wcast-align])
+  gl_WARN_ADD([-Wpointer-arith])
+  gl_WARN_ADD([-Wwrite-strings])
+  gl_WARN_ADD([-Wbad-function-cast])
+  gl_WARN_ADD([-Wmissing-declarations])
+  gl_WARN_ADD([-Wmissing-prototypes])
+  gl_WARN_ADD([-Wstrict-prototypes])
+  AC_SUBST([WARN_CFLAGS])
+  AC_DEFINE([lint], 1, [Define to 1 if the compiler is checking for lint.])
+  AC_DEFINE([_FORTIFY_SOURCE], 2,
+    [enable compile-time and run-time bounds-checking, and some warnings])
+fi
+
 AC_FUNC_FORK
 
 optional_bin_progs=
index 6b9a6b0977aab86666de015f71e038f93b0595c0..15ec0ea3323e3d669338ad21dbb092902eb6a487 100644 (file)
@@ -17,7 +17,7 @@
 
 include gnulib.mk
 
-AM_CFLAGS = $(WARNING_CFLAGS) $(WERROR_CFLAGS)
+AM_CFLAGS = $(WARN_CFLAGS) # $(WERROR_CFLAGS)
 
 libcoreutils_a_SOURCES += \
   buffer-lcm.c buffer-lcm.h \
index a6bc22925d16aa8b2be904ec126ed8b771074953..68c5f75f650dbb42f9e1ea3bd139d5959e5b46e4 100644 (file)
@@ -26,6 +26,8 @@ no_install__progs = \
 build_if_possible__progs = \
   chroot df hostid nice pinky stty su uname uptime users who
 
+AM_CFLAGS = $(WARN_CFLAGS) # $(WERROR_CFLAGS)
+
 EXTRA_PROGRAMS = \
   $(no_install__progs) \
   $(build_if_possible__progs) \
index bfbd9e051deccd4eebbbade644d3249399984da3..b5c0f71d2420a74644fe70e440cf557df7e398c0 100644 (file)
@@ -48,7 +48,7 @@ static struct option const long_options[] =
   {NULL, 0, NULL, 0}
 };
 
-static void
+void
 usage (int status)
 {
   if (status != EXIT_SUCCESS)
index 2b2bbfeeaf858d183b18a38eef4fc12e2f8ee36c..2fd6e39a8106711574d9884081e6309c1e6fc152 100644 (file)
@@ -55,7 +55,7 @@
 #define UID_T_MIN 0
 #define GID_T_MIN 0
 
-static void
+void
 usage (int status)
 {
   if (status != EXIT_SUCCESS)
index 136abc5c2d67f51222131fb8d72ae4a72039444e..9575923023ddfe55266ba161d8e5d7645bdef35d 100644 (file)
@@ -40,7 +40,7 @@
 # define MAXHOSTNAMELEN 64
 #endif
 
-char *ttyname ();
+char *ttyname (int);
 
 /* If true, display the hours:minutes since each user has touched
    the keyboard, or blank if within the last minute, or days followed
index f6b61f773557e45c97444025225e64c15377a586..9f99b78713a56582836560c78246d18b7e08a461 100644 (file)
--- a/src/su.c
+++ b/src/su.c
 /* The user to become if none is specified.  */
 #define DEFAULT_USER "root"
 
-char *crypt ();
-char *getusershell ();
-void endusershell ();
-void setusershell ();
+char *crypt (char const *key, char const *salt);
+char *getusershell (void);
+void endusershell (void);
+void setusershell (void);
 
 extern char **environ;
 
index 21182a47f0c7ad919c532307ceb7a43cbc787a17..020f83b4836699aaa0527665ddb088d203b1daef 100644 (file)
@@ -655,3 +655,5 @@ bad_cast (char const *s)
 {
   return (char *) s;
 }
+
+void usage (int status);
index 8b506f0c9a450ca614026e6bc4ea6f348c34dd7d..e8ecf627f087be3f3f786b84b6f4154d58fd44d7 100644 (file)
@@ -122,7 +122,7 @@ cleanup (int sig)
     _exit (128 + sig);
 }
 
-static void
+void
 usage (int status)
 {
   if (status != EXIT_SUCCESS)
index 3bc52ca144ca1f8f0be8171b096780e10aee2e38..c6f12b7a9e255d94dc8ec6f6331fea3cf00424fb 100644 (file)
@@ -91,7 +91,7 @@ parse_len (char const *str, off_t *size)
   return -1;
 }
 
-static void
+void
 usage (int status)
 {
   if (status != EXIT_SUCCESS)
index 3bc680bc0a63c56a539c35a7109758a5270ca39f..692b661b31dbea4049c750396cef0a2c0de2186d 100644 (file)
--- a/src/who.c
+++ b/src/who.c
@@ -95,7 +95,7 @@
 # define UT_ID(U) "??"
 #endif
 
-char *ttyname ();
+char *ttyname (int);
 
 /* If true, attempt to canonicalize hostnames via a DNS lookup. */
 static bool do_lookup;