]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD/MINOR: tools: shut up the format truncation warning in get_gmt_offset()
authorWilly Tarreau <w@1wt.eu>
Tue, 29 Oct 2019 09:16:11 +0000 (10:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 29 Oct 2019 09:19:34 +0000 (10:19 +0100)
The gcc warning about format truncation in get_gmt_offset() is annoying
since we always call it with a valid time thus it cannot fail. However
it's true that nothing guarantees that future code reuses this function
incorrectly in the future, so better enforce the modulus on one day and
shut the warning.

src/standard.c

index 08a2c0d46e5e6e347e59f3fdf69f8e5c29e556dc..442348c4ae37792110136e82aa8a2ef554bedcf9 100644 (file)
@@ -3018,11 +3018,12 @@ const char *get_gmt_offset(time_t t, struct tm *tm)
                } else {
                        *gmt_offset = '+';
                }
+               diff %= 86400U;
                diff /= 60; /* Convert to minutes */
                snprintf(gmt_offset+1, 4+1, "%02d%02d", diff/60, diff%60);
        }
 
-    return gmt_offset;
+       return gmt_offset;
 }
 
 /* gmt2str_log: write a date in the format :