summaryrefslogtreecommitdiff
path: root/src/uptime.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2004-08-02 20:56:10 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2004-08-02 20:56:10 +0000
commit67f5163d28c0862a9623897b1737620810b35cfc (patch)
tree2319c855448e352e807bab355302fc056d461b86 /src/uptime.c
parentea81db536909f096b144b1e7c28bcf4aff86784d (diff)
downloadcoreutils-67f5163d28c0862a9623897b1737620810b35cfc.tar.xz
(print_uptime, uptime): Use size_t for sizes.
(print_uptime): Remove unused local variable. (main): No need to pass a non-NULL last arg to getopt_long.
Diffstat (limited to 'src/uptime.c')
-rw-r--r--src/uptime.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/uptime.c b/src/uptime.c
index 90ffa32c6..cf27270ae 100644
--- a/src/uptime.c
+++ b/src/uptime.c
@@ -50,9 +50,9 @@ static struct option const longopts[] =
};
static void
-print_uptime (int n, const STRUCT_UTMP *this)
+print_uptime (size_t n, const STRUCT_UTMP *this)
{
- register int entries = 0;
+ size_t entries = 0;
time_t boot_time = 0;
time_t time_now;
time_t uptime = 0;
@@ -70,7 +70,6 @@ print_uptime (int n, const STRUCT_UTMP *this)
if (fp != NULL)
{
char buf[BUFSIZ];
- int res;
char *b = fgets (buf, BUFSIZ, fp);
if (b == buf)
{
@@ -149,7 +148,8 @@ print_uptime (int n, const STRUCT_UTMP *this)
printf (ngettext ("%ld day", "%ld days", updays), updays);
printf (" %2d:%02d, ", uphours, upmins);
}
- printf (ngettext ("%d user", "%d users", entries), entries);
+ printf (ngettext ("%lu user", "%lu users", entries),
+ (unsigned long int) entries);
#if defined (HAVE_GETLOADAVG) || defined (C_GETLOADAVG)
loads = getloadavg (avg, 3);
@@ -178,11 +178,10 @@ print_uptime (int n, const STRUCT_UTMP *this)
static void
uptime (const char *filename)
{
- int n_users;
+ size_t n_users;
STRUCT_UTMP *utmp_buf;
- int fail = read_utmp (filename, &n_users, &utmp_buf);
- if (fail)
+ if (read_utmp (filename, &n_users, &utmp_buf) != 0)
error (EXIT_FAILURE, errno, "%s", filename);
print_uptime (n_users, utmp_buf);
@@ -215,7 +214,7 @@ If FILE is not specified, use %s. %s as FILE is common.\n\
int
main (int argc, char **argv)
{
- int optc, longind;
+ int optc;
initialize_main (&argc, &argv);
program_name = argv[0];
setlocale (LC_ALL, "");
@@ -227,7 +226,7 @@ main (int argc, char **argv)
parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
usage, AUTHORS, (char const *) NULL);
- while ((optc = getopt_long (argc, argv, "", longopts, &longind)) != -1)
+ while ((optc = getopt_long (argc, argv, "", longopts, NULL)) != -1)
{
switch (optc)
{