- Avoid calling a wrapper function around strcmp
- Use sizeof(*array) instead of sizeof(element) everywhere CR: D161 Approved by: cognet, bapt
This commit is contained in:
parent
af99cef7e8
commit
bc31c88265
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=267027
@ -51,8 +51,8 @@ static const char rcsid[] =
|
||||
#include <utmpx.h>
|
||||
|
||||
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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user