[patch] rtprio/idprio should use basename(3) instead of acting on its own

Eitan Adler lists at eitanadler.com
Sun Jan 2 07:19:17 UTC 2011


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


More information about the freebsd-hackers mailing list