[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
new warnings in mktime.c
From: |
Jim Meyering |
Subject: |
new warnings in mktime.c |
Date: |
Wed, 22 Jun 2005 11:46:18 +0200 |
With gcc-4.0 -O -Wall, I get these new warnings:
mktime.c: In function 'ranged_convert':
mktime.c:244: warning: 'tm.tm_zone' may be used uninitialized in this function
mktime.c:244: warning: 'tm.tm_gmtoff' may be used uninitialized in this
function
mktime.c:244: warning: 'tm.tm_isdst' may be used uninitialized in this
function
mktime.c:244: warning: 'tm.tm_yday' may be used uninitialized in this function
mktime.c:244: warning: 'tm.tm_wday' may be used uninitialized in this function
mktime.c:244: warning: 'tm.tm_year' may be used uninitialized in this function
mktime.c:244: warning: 'tm.tm_mon' may be used uninitialized in this function
mktime.c:244: warning: 'tm.tm_mday' may be used uninitialized in this function
mktime.c:244: warning: 'tm.tm_hour' may be used uninitialized in this function
mktime.c:244: warning: 'tm.tm_min' may be used uninitialized in this function
mktime.c:244: warning: 'tm.tm_sec' may be used uninitialized in this function
make[1]: *** [mktime.o] Error 1
There is no real problem, but it's best to provide a way
to suppress such warnings. So here's one approach,
but I'm hoping there's a better way...
2005-06-22 Jim Meyering <address@hidden>
* mktime.c (IF_LINT) [lint]: Define.
(ranged_convert) [lint]: Define `tm', to avoid `may be used
uninitialized' warnings from gcc -O -Wall.
Index: lib/mktime.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/mktime.c,v
retrieving revision 1.51
diff -u -p -r1.51 mktime.c
--- lib/mktime.c 14 May 2005 06:03:58 -0000 1.51
+++ lib/mktime.c 22 Jun 2005 09:43:50 -0000
@@ -46,6 +46,12 @@
# define mktime my_mktime
#endif /* DEBUG */
+#ifdef lint
+# define IF_LINT(Code) Code
+#else
+# define IF_LINT(Code) /* empty */
+#endif
+
/* Shift A right by B bits portably, by dividing A by 2**B and
truncating towards minus infinity. A and B should be free of side
effects, and B should be in the range 0 <= B <= INT_BITS - 2, where
@@ -234,7 +240,8 @@ ranged_convert (struct tm *(*convert) (c
{
time_t bad = *t;
time_t ok = 0;
- struct tm tm;
+ IF_LINT (static struct tm z);
+ struct tm tm IF_LINT (= z);
/* BAD is a known unconvertible time_t, and OK is a known good one.
Use binary search to narrow the range between BAD and OK until
- new warnings in mktime.c,
Jim Meyering <=