Date: Sun, 2 Jan 2011 12:20:03 +0200 From: Kostik Belousov <kostikbel@gmail.com> To: Eitan Adler <lists@eitanadler.com> Cc: hackers@freebsd.org Subject: Re: [patch] rtprio/idprio should use basename(3) instead of acting on its own Message-ID: <20110102102003.GD90883@deviant.kiev.zoral.com.ua> In-Reply-To: <AANLkTinKh8L7XccRoBtBC7vEwMYQiY0L=u4tJYm8a%2BD=@mail.gmail.com> References: <AANLkTinKh8L7XccRoBtBC7vEwMYQiY0L=u4tJYm8a%2BD=@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --] 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. [-- Attachment #2 --] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk0gUVIACgkQC3+MBN1Mb4jJWwCgkP18+ttTxJfLXewB4QCrRWHy G2QAn1f1pKPHpSIUQpKv4JUUo9MIojcN =a9kw -----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110102102003.GD90883>
