[tz] [PROPOSED] Pacify GCC 7.2.1 x86-64 -Wmaybe-uninitialized
Paul Eggert
eggert at cs.ucla.edu
Mon Dec 4 18:53:46 UTC 2017
* zdump.c (main): Add an INITIALIZE to pacify gcc 7.2.1 20170915
(Red Hat 7.2.1-2) on x86-64 with -Wmaybe-uninitialized, which
otherwise incorrectly warns that ‘ab’ might be used uninitialized.
Clarify the expression that confused GCC (though the clarification
is evidently not enough).
---
zdump.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/zdump.c b/zdump.c
index 3cd4f42..60a027e 100644
--- a/zdump.c
+++ b/zdump.c
@@ -552,6 +552,7 @@ main(int argc, char *argv[])
}
if (t < cutlotime)
t = cutlotime;
+ INITIALIZE (ab);
tm_ok = my_localtime_rz(tz, &t, &tm) != NULL;
if (tm_ok) {
ab = saveabbr(&abbrev, &abbrevsize, &tm);
@@ -567,11 +568,10 @@ main(int argc, char *argv[])
: cuthitime);
struct tm *newtmp = localtime_rz(tz, &newt, &newtm);
bool newtm_ok = newtmp != NULL;
- if (! (tm_ok & newtm_ok
- ? (delta(&newtm, &tm) == newt - t
- && newtm.tm_isdst == tm.tm_isdst
- && strcmp(abbr(&newtm), ab) == 0)
- : tm_ok == newtm_ok)) {
+ if (tm_ok != newtm_ok
+ || (tm_ok && (delta(&newtm, &tm) != newt - t
+ || newtm.tm_isdst != tm.tm_isdst
+ || strcmp(abbr(&newtm), ab) != 0))) {
newt = hunt(tz, argv[i], t, newt);
newtmp = localtime_rz(tz, &newt, &newtm);
newtm_ok = newtmp != NULL;
--
2.14.3
More information about the tz
mailing list