avoid a warning from gcc
authorJim Meyering <meyering@redhat.com>
Mon, 19 May 2008 16:10:38 +0000 (18:10 +0200)
committerJim Meyering <meyering@redhat.com>
Mon, 19 May 2008 16:10:38 +0000 (18:10 +0200)
* lib/trim.c (IF_LINT): Define.
(trim2): Use it to void a "may be used uninitialized" warning.

ChangeLog
lib/trim.c

index 91d6421..230a150 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2008-05-19  Jim Meyering  <meyering@redhat.com>
 
+       avoid a warning from gcc
+       * lib/trim.c (IF_LINT): Define.
+       (trim2): Use it to void a "may be used uninitialized" warning.
+
        Fix doc typo.
        * doc/glibc-functions/getpass.texi (getpass): s/PATH_MAX/PASS_MAX/.
 
index 3813ca8..3802301 100644 (file)
 
 #include "xalloc.h"
 
+/* Use this to suppress gcc's `...may be used before initialized' warnings. */
+#ifdef lint
+# define IF_LINT(Code) Code
+#else
+# define IF_LINT(Code) /* empty */
+#endif
+
 char *
 trim2(const char *s, int how)
 {
@@ -63,7 +70,7 @@ trim2(const char *s, int how)
       if (how != TRIM_LEADING) 
        {
          int state = 0;
-         char *r; /* used only while state = 2 */
+         char *r IF_LINT (= NULL); /* used only while state = 2 */
          
          mbi_init (i, d, strlen (d));