diff options
author | Sami Kerola | 2013-08-29 08:46:46 +0200 |
---|---|---|
committer | Sami Kerola | 2013-08-29 19:14:10 +0200 |
commit | cfa7fe890b09693ed503da7516977402cbbe13ed (patch) | |
tree | 209ef3d4676d62c36b59b62a33b06b37c9a5b8bf /login-utils/utmpdump.c | |
parent | last: tell verbally system is still running (diff) | |
download | kernel-qcow2-util-linux-cfa7fe890b09693ed503da7516977402cbbe13ed.tar.gz kernel-qcow2-util-linux-cfa7fe890b09693ed503da7516977402cbbe13ed.tar.xz kernel-qcow2-util-linux-cfa7fe890b09693ed503da7516977402cbbe13ed.zip |
last, utmpdump, agetty, wall, write: avoid compatibility hacks
In include/bits/utmp.h the ut_user and ut_time macros are marked with
comment they are backwards compatibility hacks. It is probably best to
avoid use of these macros where ever possible.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'login-utils/utmpdump.c')
-rw-r--r-- | login-utils/utmpdump.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/login-utils/utmpdump.c b/login-utils/utmpdump.c index baf9f5c55..acc10db16 100644 --- a/login-utils/utmpdump.c +++ b/login-utils/utmpdump.c @@ -90,7 +90,11 @@ static void print_utline(struct utmp ut, FILE *out) in.s_addr = ut.ut_addr; addr_string = inet_ntoa(in); - time_string = timetostr(ut.ut_time); +#if defined(_HAVE_UT_TV) + time_string = timetostr(ut.ut_tv.tv_sec); +#else + time_string = timetostr((time_t)ut.ut_time); /* ut_time is not always a time_t */ +#endif cleanse(ut.ut_id); cleanse(ut.ut_user); cleanse(ut.ut_line); @@ -268,8 +272,11 @@ static void undump(FILE *in, FILE *out) gettok(line, s_time, sizeof(s_time) - 1, 0); ut.ut_addr = inet_addr(s_addr); +#if defined(_HAVE_UT_TV) + ut.ut_tv.tv_sec = strtotime(s_time); +#else ut.ut_time = strtotime(s_time); - +#endif ignore_result( fwrite(&ut, sizeof(ut), 1, out) ); ++count; |