From b0ac02e82a6a1ef9d6285bbb8bef917d4736ac9b Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sun, 18 Oct 2015 10:24:37 -0700 Subject: [PATCH] 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. --- ChangeLog | 4 ++++ lib/time_rz.c | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 01a05363a3..3a9768e843 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2015-10-18 Paul Eggert + 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; -- 2.39.5