]> Savannah Git Hosting - gnulib.git/commitdiff
time_rz: avoid warning from bleeding-edge gcc's -Wnonnull
authorJim Meyering <meyering@fb.com>
Sun, 18 Oct 2015 16:32:21 +0000 (09:32 -0700)
committerJim Meyering <meyering@fb.com>
Sun, 18 Oct 2015 16:35:52 +0000 (09:35 -0700)
Compiling with gcc version 6.0.0 20151017 (experimental) (GCC), I
would see this:

lib/time_rz.c: In function 'localtime_rz':
lib/time_rz.c:292:15: error: nonnull argument 'tm' compared to NULL \
  [-Werror=nonnull]
           if (tm && !save_abbr (tz, tm))
               ^

That was complaining about "tm" because it is a parameter that was
declared with the __nonnull__ attribute.
* lib/time_rz.c (localtime_rz): Don't bother setting "tm" to the
result of localtime_r.

ChangeLog
lib/time_rz.c

index 81f8cd2cc8b1013e0f507afaf1a1ebb12c15ade1..fcfab70aed899534a3056c29d1653f4aa5446ebf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2015-10-18  Jim Meyering  <meyering@fb.com>
+
+       time_rz: avoid warning from bleeding-edge gcc's -Wnonnull
+       Compiling with gcc version 6.0.0 20151017 (experimental) (GCC), I
+       would see this:
+
+       lib/time_rz.c: In function 'localtime_rz':
+       lib/time_rz.c:292:15: error: nonnull argument 'tm' compared to NULL \
+         [-Werror=nonnull]
+                  if (tm && !save_abbr (tz, tm))
+                      ^
+
+       That was complaining about "tm" because it is a parameter that was
+       declared with the __nonnull__ attribute.
+       * lib/time_rz.c (localtime_rz): Don't bother setting "tm" to the
+       result of localtime_r.
+
 2015-10-17  Jim Meyering  <meyering@fb.com>
 
        maint.mk: _gl_TS_function_match: fix "extern" name extracting regexp
index 5e9636f3a3d4458e12665c0af8b466c8893697f9..396cdd20206322b370f6c0e7fdde07705782087a 100644 (file)
@@ -288,8 +288,7 @@ localtime_rz (timezone_t tz, time_t const *t, struct tm *tm)
       timezone_t old_tz = set_tz (tz);
       if (old_tz)
         {
-          tm = localtime_r (t, tm);
-          if (tm && !save_abbr (tz, tm))
+          if (localtime_r (t, tm) && !save_abbr (tz, tm))
             tm = NULL;
           if (revert_tz (old_tz))
             return tm;