Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Jan 2011 02:18:55 -0500
From:      Eitan Adler <lists@eitanadler.com>
To:        hackers@freebsd.org
Subject:   [patch] rtprio/idprio should use basename(3) instead of acting on its own
Message-ID:  <AANLkTinKh8L7XccRoBtBC7vEwMYQiY0L=u4tJYm8a%2BD=@mail.gmail.com>

next in thread | raw e-mail | index | archive | help

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;


-- 
Eitan Adler



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinKh8L7XccRoBtBC7vEwMYQiY0L=u4tJYm8a%2BD=>