summaryrefslogtreecommitdiffstats
path: root/usr.bin/users
diff options
context:
space:
mode:
authorgahr <gahr@FreeBSD.org>2014-06-03 20:59:26 +0000
committergahr <gahr@FreeBSD.org>2014-06-03 20:59:26 +0000
commitcc4220acff46378c0cfca6a4d0cdcbfa83c984a0 (patch)
treec677597a9b89c0425bfc25a4f648ad188003ca46 /usr.bin/users
parent36bd9e40302da682c1d9ae6c3afa38171912ff6a (diff)
downloadFreeBSD-src-cc4220acff46378c0cfca6a4d0cdcbfa83c984a0.zip
FreeBSD-src-cc4220acff46378c0cfca6a4d0cdcbfa83c984a0.tar.gz
- Avoid calling a wrapper function around strcmp
- Use sizeof(*array) instead of sizeof(element) everywhere CR: D161 Approved by: cognet, bapt
Diffstat (limited to 'usr.bin/users')
-rw-r--r--usr.bin/users/users.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/usr.bin/users/users.c b/usr.bin/users/users.c
index 6be7e03..e0d04e7 100644
--- a/usr.bin/users/users.c
+++ b/usr.bin/users/users.c
@@ -50,9 +50,9 @@ static const char rcsid[] =
#include <unistd.h>
#include <utmpx.h>
-typedef char namebuf[sizeof(((struct utmpx *)0)->ut_user) + 1];
+typedef char namebuf[sizeof(((struct utmpx *)0)->ut_user) + 1];
+typedef int (*scmp)(const void *, const void *);
-int scmp(const void *, const void *);
static void usage(void);
int
@@ -91,7 +91,7 @@ main(int argc, char **argv)
}
endutxent();
if (ncnt > 0) {
- qsort(names, ncnt, sizeof(namebuf), scmp);
+ qsort(names, ncnt, sizeof(*names), (scmp)strcmp);
printf("%s", names[0]);
for (cnt = 1; cnt < ncnt; ++cnt)
if (strcmp(names[cnt], names[cnt - 1]) != 0)
@@ -107,10 +107,3 @@ usage(void)
fprintf(stderr, "usage: users\n");
exit(1);
}
-
-int
-scmp(const void *p, const void *q)
-{
-
- return (strcmp(p, q));
-}
OpenPOWER on IntegriCloud