[patch] rtprio/idprio should use basename(3) instead of acting
on its own
Kostik Belousov
kostikbel at gmail.com
Sun Jan 2 10:38:38 UTC 2011
On Sun, Jan 02, 2011 at 02:18:55AM -0500, Eitan Adler wrote:
> Index: rtprio.c
> ===================================================================
> --- rtprio.c (revision 216884)
> +++ rtprio.c (working copy)
> @@ -41,6 +41,7 @@
>
> #include <ctype.h>
> #include <err.h>
> +#include <libgen.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> @@ -57,11 +58,7 @@
> int proc = 0;
> struct rtprio rtp;
>
> - /* find basename */
> - if ((p = rindex(argv[0], '/')) == NULL)
> - p = argv[0];
> - else
> - ++p;
> + p = basename(argv[0]);
>
> if (!strcmp(p, "rtprio"))
> rtp.type = RTP_PRIO_REALTIME;
>
basename(3) does much more work that IMO not needed there.
rindex() use is a well-known pattern that is common for almost all
utilities that check the calling name.
I do not think it is worth the churn.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20110102/10ef8035/attachment.pgp
More information about the freebsd-hackers
mailing list