summaryrefslogtreecommitdiff
path: root/src/who.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-09-24 16:18:11 +0000
committerJim Meyering <jim@meyering.net>1994-09-24 16:18:11 +0000
commitcbee99cebe871e263cef6ecd677ccdaa8a31c458 (patch)
tree3408f0bd4fe81ee4310cb28aa19d7f88642a9919 /src/who.c
parent3d74506f216067002e57098310809b4f948d828d (diff)
downloadcoreutils-cbee99cebe871e263cef6ecd677ccdaa8a31c458.tar.xz
(read_utmp): New variable: size to avoid type warnings.
Diffstat (limited to 'src/who.c')
-rw-r--r--src/who.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/who.c b/src/who.c
index c2f6e20ab..50eaa378c 100644
--- a/src/who.c
+++ b/src/who.c
@@ -288,14 +288,16 @@ read_utmp (filename)
FILE *utmp;
struct stat file_stats;
int n_read;
+ size_t size;
utmp = fopen (filename, "r");
if (utmp == NULL)
error (1, errno, "%s", filename);
fstat (fileno (utmp), &file_stats);
- if (file_stats.st_size > 0)
- utmp_contents = (STRUCT_UTMP *) xmalloc ((unsigned) file_stats.st_size);
+ size = file_stats.st_size;
+ if (size > 0)
+ utmp_contents = (STRUCT_UTMP *) xmalloc (size);
else
{
fclose (utmp);
@@ -303,12 +305,12 @@ read_utmp (filename)
}
/* Use < instead of != in case the utmp just grew. */
- n_read = fread (utmp_contents, 1, file_stats.st_size, utmp);
+ n_read = fread (utmp_contents, 1, size, utmp);
if (ferror (utmp) || fclose (utmp) == EOF
- || n_read < file_stats.st_size)
+ || n_read < size)
error (1, errno, "%s", filename);
- return file_stats.st_size / sizeof (STRUCT_UTMP);
+ return size / sizeof (STRUCT_UTMP);
}
#ifdef WHO