summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2005-07-03 21:10:31 +0000
committerJim Meyering <jim@meyering.net>2005-07-03 21:10:31 +0000
commit035abbb7c6fb7f5a600aef0d2e4ce6f43ea754de (patch)
tree2c026e72cdd05995880129d79a8c84a102c22ab8
parent052190e99c1a8b29a1cbb1369159e41de99eff3d (diff)
downloadcoreutils-035abbb7c6fb7f5a600aef0d2e4ce6f43ea754de.tar.xz
(posixtime) [lint]: Initialize *all* of tm0, not just
the .tm_year member, since otherwise gcc-4.0 would now warn about tm_zone, tm_gmtoff, tm_isdst, tm_yday, tm_wday.
-rw-r--r--lib/posixtm.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/posixtm.c b/lib/posixtm.c
index 5273a71f4..397f63f46 100644
--- a/lib/posixtm.c
+++ b/lib/posixtm.c
@@ -43,6 +43,13 @@
# include "unlocked-io.h"
#endif
+/* 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
+
/* ISDIGIT differs from isdigit, as follows:
- Its arg may be any int or unsigned int; it need not be an unsigned char.
- It's guaranteed to evaluate its argument exactly once.
@@ -193,18 +200,18 @@ posix_time_parse (struct tm *tm, const char *s, unsigned int syntax_bits)
bool
posixtime (time_t *p, const char *s, unsigned int syntax_bits)
{
- struct tm tm0;
- struct tm tm1;
- struct tm const *tm;
- time_t t;
-
+ struct tm tm0
#ifdef lint
/* Placate gcc-4's -Wuninitialized.
- posix_time_parse fails to set tm0.tm_year only when it returns
+ posix_time_parse fails to set all of tm0 only when it returns
nonzero (due to year() returning nonzero), and in that case,
this code doesn't use the tm0 at all. */
- tm0.tm_year = 0;
+ = { 0, }
#endif
+ ;
+ struct tm tm1;
+ struct tm const *tm;
+ time_t t;
if (posix_time_parse (&tm0, s, syntax_bits))
return false;