From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 18 Oct 2015 17:24:37 +0000 (-0700)
Subject: time_rz: return NULL if localtime_r fails
X-Git-Tag: v1.0~6920
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=b0ac02e82a6a1ef9d6285bbb8bef917d4736ac9b;p=gnulib.git

time_rz: return NULL if localtime_r fails

* lib/time_rz.c (localtime_rz): Return NULL if localtime_r fails,
while still attempting to pacify bleeding-edge GCC.
---

diff --git a/ChangeLog b/ChangeLog
index 01a05363a3..3a9768e843 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2015-10-18  Paul Eggert  <eggert@cs.ucla.edu>
 
+	time_rz: return NULL if localtime_r fails
+	* lib/time_rz.c (localtime_rz): Return NULL if localtime_r fails,
+	while still attempting to pacify bleeding-edge GCC.
+
 	fts: port to C11 alignof
 	* doc/posix-headers/stdalign.texi (stdalign.h):
 	Document the C11 restriction.
diff --git a/lib/time_rz.c b/lib/time_rz.c
index 396cdd2020..8a0cbb207d 100644
--- a/lib/time_rz.c
+++ b/lib/time_rz.c
@@ -288,9 +288,8 @@ localtime_rz (timezone_t tz, time_t const *t, struct tm *tm)
       timezone_t old_tz = set_tz (tz);
       if (old_tz)
         {
-          if (localtime_r (t, tm) && !save_abbr (tz, tm))
-            tm = NULL;
-          if (revert_tz (old_tz))
+          bool abbr_saved = localtime_r (t, tm) && save_abbr (tz, tm);
+          if (revert_tz (old_tz) && abbr_saved)
             return tm;
         }
       return NULL;