diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-03-06 18:11:47 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-03-06 18:11:47 +0100 |
commit | e1b1b7926975c3cd4313be0019212b1cf68fa529 (patch) | |
tree | 31f9227004013462e899d383c1e7a0910f7157aa /runit/svlogd.c | |
parent | 33f7c8f200b6c3f7163dc89723ab67462688dccd (diff) | |
download | busybox-w32-e1b1b7926975c3cd4313be0019212b1cf68fa529.tar.gz busybox-w32-e1b1b7926975c3cd4313be0019212b1cf68fa529.tar.bz2 busybox-w32-e1b1b7926975c3cd4313be0019212b1cf68fa529.zip |
use gmtime_r() instead of gmtime()
This avoids pulling in gmtime's static buffer:
function old new delta
svlogd_main 1401 1412 +11
send_headers 668 678 +10
gmtime 21 - -21
------------------------------------------------------------------------------
(add/remove: 0/2 grow/shrink: 2/0 up/down: 21/-21) Total: 0 bytes
text data bss dec hex filename
920221 555 5804 926580 e2374 busybox_old
920221 555 5740 926516 e2334 busybox_unstripped
^^^^
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'runit/svlogd.c')
-rw-r--r-- | runit/svlogd.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/runit/svlogd.c b/runit/svlogd.c index 412290ca9..13de2570f 100644 --- a/runit/svlogd.c +++ b/runit/svlogd.c | |||
@@ -347,11 +347,13 @@ static unsigned pmatch(const char *p, const char *s, unsigned len) | |||
347 | /* NUL terminated */ | 347 | /* NUL terminated */ |
348 | static void fmt_time_human_30nul(char *s, char dt_delim) | 348 | static void fmt_time_human_30nul(char *s, char dt_delim) |
349 | { | 349 | { |
350 | struct tm tm; | ||
350 | struct tm *ptm; | 351 | struct tm *ptm; |
351 | struct timeval tv; | 352 | struct timeval tv; |
352 | 353 | ||
353 | gettimeofday(&tv, NULL); | 354 | gettimeofday(&tv, NULL); |
354 | ptm = gmtime(&tv.tv_sec); | 355 | ptm = gmtime_r(&tv.tv_sec, &tm); |
356 | /* ^^^ using gmtime_r() instead of gmtime() to not use static data */ | ||
355 | sprintf(s, "%04u-%02u-%02u%c%02u:%02u:%02u.%06u000", | 357 | sprintf(s, "%04u-%02u-%02u%c%02u:%02u:%02u.%06u000", |
356 | (unsigned)(1900 + ptm->tm_year), | 358 | (unsigned)(1900 + ptm->tm_year), |
357 | (unsigned)(ptm->tm_mon + 1), | 359 | (unsigned)(ptm->tm_mon + 1), |