Date: Tue, 3 Jun 2014 20:59:26 +0000 (UTC) From: Pietro Cerutti <gahr@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r267027 - head/usr.bin/users Message-ID: <201406032059.s53KxQAp081243@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: gahr (ports committer) Date: Tue Jun 3 20:59:26 2014 New Revision: 267027 URL: http://svnweb.freebsd.org/changeset/base/267027 Log: - Avoid calling a wrapper function around strcmp - Use sizeof(*array) instead of sizeof(element) everywhere CR: D161 Approved by: cognet, bapt Modified: head/usr.bin/users/users.c Modified: head/usr.bin/users/users.c ============================================================================== --- head/usr.bin/users/users.c Tue Jun 3 20:58:11 2014 (r267026) +++ head/usr.bin/users/users.c Tue Jun 3 20:59:26 2014 (r267027) @@ -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)); -}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201406032059.s53KxQAp081243>