summaryrefslogtreecommitdiff
path: root/coreutils/who.c
diff options
context:
space:
mode:
authorRob Landley2006-06-19 03:20:03 +0000
committerRob Landley2006-06-19 03:20:03 +0000
commit7a260f01ce6841658810dc9f0ff0706558a10d7f (patch)
treef98b6d5bf4c3d48dd54db386c29d39ab26e1463e /coreutils/who.c
parent290fcb4213ae5ab9ec6cb228dd64ef2c9f02d26d (diff)
downloadbusybox-7a260f01ce6841658810dc9f0ff0706558a10d7f.zip
busybox-7a260f01ce6841658810dc9f0ff0706558a10d7f.tar.gz
Make some 64 bit warnings go away on x86-64.
Diffstat (limited to 'coreutils/who.c')
-rw-r--r--coreutils/who.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/coreutils/who.c b/coreutils/who.c
index 0cb7431..5cff651 100644
--- a/coreutils/who.c
+++ b/coreutils/who.c
@@ -14,12 +14,9 @@
*----------------------------------------------------------------------
*/
-#include <stdio.h>
-#include <stdlib.h>
+#include "busybox.h"
#include <utmp.h>
-#include <sys/stat.h>
#include <time.h>
-#include "busybox.h"
static const char * idle_string (time_t t)
{
@@ -33,7 +30,7 @@ static const char * idle_string (time_t t)
sprintf (str, "%02d:%02d",
(int) (s / (60 * 60)),
(int) ((s % (60 * 60)) / 60));
- return (const char *) str;
+ return str;
}
return "old";
}
@@ -52,14 +49,16 @@ int who_main(int argc, char **argv)
printf("USER TTY IDLE TIME HOST\n");
while ((ut = getutent()) != NULL) {
if (ut->ut_user[0] && ut->ut_type == USER_PROCESS) {
+ time_t thyme = ut->ut_tv.tv_sec;
+
/* ut->ut_line is device name of tty - "/dev/" */
name = concat_path_file("/dev", ut->ut_line);
printf("%-10s %-8s %-8s %-12.12s %s\n", ut->ut_user, ut->ut_line,
(stat(name, &st)) ? "?" : idle_string(st.st_atime),
- ctime((time_t*)&(ut->ut_tv.tv_sec)) + 4, ut->ut_host);
- free(name);
+ ctime(&thyme) + 4, ut->ut_host);
+ if (ENABLE_FEATURE_CLEAN_UP) free(name);
}
}
- endutent();
+ if (ENABLE_FEATURE_CLEAN_UP) endutent();
return 0;
}