diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-02-18 15:47:27 +0300 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-02-18 15:47:46 +0300 |
commit | 54e9585e106348d6f0129376171fab305ddc0e27 (patch) | |
tree | d3849ff1bff39a41c648f20beb61a135331a6498 /miscutils/last_fancy.c | |
parent | 0cb981c5e2f1a955e72dd9d3d2fad075dc9d0da6 (diff) |
trivial code shrink
function old new delta
rdate_main 246 251 +5
show_entry 291 287 -4
daytime_stream 44 39 -5
packed_usage 30176 30168 -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/3 up/down: 5/-17) Total: -12 bytes
text data bss dec hex filename
929453 932 17684 948069 e7765 busybox_old
929411 932 17684 948027 e773b busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'miscutils/last_fancy.c')
-rw-r--r-- | miscutils/last_fancy.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/miscutils/last_fancy.c b/miscutils/last_fancy.c index f687d7e16..16ed9e920 100644 --- a/miscutils/last_fancy.c +++ b/miscutils/last_fancy.c @@ -42,7 +42,7 @@ enum { static void show_entry(struct utmp *ut, int state, time_t dur_secs) { unsigned days, hours, mins; - char duration[32]; + char duration[sizeof("(%u+02:02)") + sizeof(int)*3]; char login_time[17]; char logout_time[8]; const char *logout_str; @@ -53,7 +53,8 @@ static void show_entry(struct utmp *ut, int state, time_t dur_secs) * but some systems have it wrong */ tmp = ut->ut_tv.tv_sec; safe_strncpy(login_time, ctime(&tmp), 17); - snprintf(logout_time, 8, "- %s", ctime(&dur_secs) + 11); + tmp = dur_secs; + snprintf(logout_time, 8, "- %s", ctime(&tmp) + 11); dur_secs = MAX(dur_secs - (time_t)ut->ut_tv.tv_sec, (time_t)0); /* unsigned int is easier to divide than time_t (which may be signed long) */ |