bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] avoid gcc warnings about unused macro definitions


From: Jim Meyering
Subject: [PATCH] avoid gcc warnings about unused macro definitions
Date: Thu, 12 Mar 2009 14:58:07 +0100

FYI, I'll push the patch below shortly:

Now that I'm enabling more gcc warnings, and since I've just
started experimenting with Ralf's new "automake --silent-rules",
these new warnings stand out more than before, so I've addressed
some of them.  Here's sample output:

   CC  modechange.o
   CC  mountlist.o
   CC  mpsort.o
   CC  nanosleep.o
   CC  offtostr.o
   CC  open-safer.o
   CC  openat-proc.o
  mountlist.c:137:1: warning: macro "SIZE_MAX" is not used
  mountlist.c:129:1: warning: macro "MNT_IGNORE" is not used
   CC  physmem.o
   CC  posixtm.o
   CC  pipe-safer.o
   CC  posixver.o
  physmem.c:78:1: warning: macro "ARRAY_SIZE" is not used
   CC  printf-args.o
   CC  printf-parse.o
   CC  quote.o
   CC  quotearg.o
   CC  readtokens.o
   CC  readutmp.o
   CC  regex.o
   CC  root-dev-ino.o
  readtokens.c:39:1: warning: macro "STREQ" is not used
   CC  safe-read.o
   CC  safe-write.o
  readutmp.c:42:1: warning: macro "SIZE_MAX" is not used
   CC  same.o
   CC  save-cwd.o
   ...

Some of those macros *are* used, but only in inactive #ifdef'd code.
Of course, we can't remove those, and I'm not inclined to move
definitions "down" into the #if blocks where they're used or even
to add #if directives around the definition at the top.
We may well just have to live with some of these.


>From f93bd98a9570a4455f16eafc49c6227e5caa5a53 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 12 Mar 2009 13:09:42 +0100
Subject: [PATCH] avoid gcc warnings about unused macro definitions

* lib/readtokens.c (STREQ): Remove unused definition.
* lib/xmalloc.c (SIZE_MAX): Likewise.
* lib/openat-die.c (N_): Likewise.
* lib/mountlist.c (SIZE_MAX): Remove definition.
Instead, include <stdint.h>.
* lib/readutmp.c: Likewise.
* modules/readutmp (Depends-on): Add stdint.
* modules/mountlist (Depends-on): Add stdint.
* lib/userspec.c (ISDIGIT): Move definition into #if block where used.
---
 ChangeLog         |   13 +++++++++++++
 lib/mountlist.c   |    5 +----
 lib/openat-die.c  |    3 +--
 lib/readtokens.c  |    5 +----
 lib/readutmp.c    |    5 +----
 lib/userspec.c    |    4 ++--
 lib/xmalloc.c     |    6 +-----
 modules/mountlist |    1 +
 modules/readutmp  |    1 +
 9 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 3754d34..2d4236a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2009-03-12  Jim Meyering  <address@hidden>
+
+       avoid gcc warnings about unused macro definitions
+       * lib/readtokens.c (STREQ): Remove unused definition.
+       * lib/xmalloc.c (SIZE_MAX): Likewise.
+       * lib/openat-die.c (N_): Likewise.
+       * lib/mountlist.c (SIZE_MAX): Remove definition.
+       Instead, include <stdint.h>.
+       * lib/readutmp.c: Likewise.
+       * modules/readutmp (Depends-on): Add stdint.
+       * modules/mountlist (Depends-on): Add stdint.
+       * lib/userspec.c (ISDIGIT): Move definition into #if block where used.
+
 2009-03-10  Bruno Haible  <address@hidden>

        Tests for module 'mbmemcasecoll'.
diff --git a/lib/mountlist.c b/lib/mountlist.c
index 6010e27..50e90ee 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <stdint.h>

 #include "xalloc.h"

@@ -133,10 +134,6 @@
 # include "unlocked-io.h"
 #endif

-#ifndef SIZE_MAX
-# define SIZE_MAX ((size_t) -1)
-#endif
-
 /* The results of open() in this file are not used with fchdir,
    therefore save some unnecessary work in fchdir.c.  */
 #undef open
diff --git a/lib/openat-die.c b/lib/openat-die.c
index 81498ae..677f3e0 100644
--- a/lib/openat-die.c
+++ b/lib/openat-die.c
@@ -1,6 +1,6 @@
 /* Report a save- or restore-cwd failure in our openat replacement and then 
exit.

-   Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc.
+   Copyright (C) 2005, 2006, 2008-2009 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
@@ -26,7 +26,6 @@

 #include "gettext.h"
 #define _(msgid) gettext (msgid)
-#define N_(msgid) msgid

 void
 openat_save_fail (int errnum)
diff --git a/lib/readtokens.c b/lib/readtokens.c
index bead600..0175098 100644
--- a/lib/readtokens.c
+++ b/lib/readtokens.c
@@ -1,6 +1,6 @@
 /* readtokens.c  -- Functions for reading tokens from an input stream.

-   Copyright (C) 1990-1991, 1999-2004, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1990-1991, 1999-2004, 2006, 2009 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
@@ -36,9 +36,6 @@
 # include "unlocked-io.h"
 #endif

-#define STREQ(a,b) ((a) == (b) || ((a) && (b) && *(a) == *(b) \
-                                  && strcmp(a, b) == 0))
-
 /* Initialize a tokenbuffer. */

 void
diff --git a/lib/readutmp.c b/lib/readutmp.c
index 88aed38..aeec205 100644
--- a/lib/readutmp.c
+++ b/lib/readutmp.c
@@ -31,6 +31,7 @@
 #include <stdbool.h>
 #include <string.h>
 #include <stdlib.h>
+#include <stdint.h>

 #include "xalloc.h"

@@ -38,10 +39,6 @@
 # include "unlocked-io.h"
 #endif

-#ifndef SIZE_MAX
-# define SIZE_MAX ((size_t) -1)
-#endif
-
 /* Copy UT->ut_name into storage obtained from malloc.  Then remove any
    trailing spaces from the copy, NUL terminate it, and return the copy.  */

diff --git a/lib/userspec.c b/lib/userspec.c
index 501fa34..17f9326 100644
--- a/lib/userspec.c
+++ b/lib/userspec.c
@@ -71,6 +71,8 @@
 # define MAXGID GID_T_MAX
 #endif

+#ifdef __DJGPP__
+
 /* ISDIGIT differs from isdigit, as follows:
    - Its arg may be any int or unsigned int; it need not be an unsigned char
      or EOF.
@@ -80,8 +82,6 @@
    of `digit' even when the host does not conform to POSIX.  */
 #define ISDIGIT(c) ((unsigned int) (c) - '0' <= 9)

-#ifdef __DJGPP__
-
 /* Return true if STR represents an unsigned decimal integer.  */

 static bool
diff --git a/lib/xmalloc.c b/lib/xmalloc.c
index 89ecf17..585fb4b 100644
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -1,7 +1,7 @@
 /* xmalloc.c -- malloc with out of memory checking

    Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000, 2002, 2003, 2004, 2005, 2006, 2008 Free Software Foundation,
+   1999, 2000, 2002, 2003, 2004, 2005, 2006, 2008-2009 Free Software 
Foundation,
    Inc.

    This program is free software: you can redistribute it and/or modify
@@ -28,10 +28,6 @@
 #include <stdlib.h>
 #include <string.h>

-#ifndef SIZE_MAX
-# define SIZE_MAX ((size_t) -1)
-#endif
-
 /* 1 if calloc is known to be compatible with GNU calloc.  This
    matters if we are not also using the calloc module, which defines
    HAVE_CALLOC and supports the GNU API even on non-GNU platforms.  */
diff --git a/modules/mountlist b/modules/mountlist
index ce5342c..526022c 100644
--- a/modules/mountlist
+++ b/modules/mountlist
@@ -10,6 +10,7 @@ m4/mountlist.m4

 Depends-on:
 stdbool
+stdint
 xalloc

 configure.ac:
diff --git a/modules/readutmp b/modules/readutmp
index 4a778b8..f0fe398 100644
--- a/modules/readutmp
+++ b/modules/readutmp
@@ -10,6 +10,7 @@ Depends-on:
 extensions
 xalloc
 stdbool
+stdint

 configure.ac:
 gl_READUTMP
--
1.6.2.rc1.285.gc5f54




reply via email to

[Prev in Thread] Current Thread [Next in Thread]