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
--GpIToxGFjxEkdZJB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Jan 02, 2011 at 02:18:55AM -0500, Eitan Adler wrote: > Index: rtprio.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- rtprio.c (revision 216884) > +++ rtprio.c (working copy) > @@ -41,6 +41,7 @@ >=20 > #include <ctype.h> > #include <err.h> > +#include <libgen.h> > #include <stdio.h> > #include <stdlib.h> > #include <string.h> > @@ -57,11 +58,7 @@ > int proc =3D 0; > struct rtprio rtp; >=20 > - /* find basename */ > - if ((p =3D rindex(argv[0], '/')) =3D=3D NULL) > - p =3D argv[0]; > - else > - ++p; > + p =3D basename(argv[0]); >=20 > if (!strcmp(p, "rtprio")) > rtp.type =3D RTP_PRIO_REALTIME; >=20 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. --GpIToxGFjxEkdZJB Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (FreeBSD) iEYEARECAAYFAk0gUVIACgkQC3+MBN1Mb4jJWwCgkP18+ttTxJfLXewB4QCrRWHy G2QAn1f1pKPHpSIUQpKv4JUUo9MIojcN =a9kw -----END PGP SIGNATURE----- --GpIToxGFjxEkdZJB--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110102102003.GD90883>