From e33d251e8e9949ef6cea8d7832e9171cbd814dd4 Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Sun, 1 May 2016 08:22:11 +0000 Subject: Remove useless calls to basename(). There are a couple of places in the source three where we call basename() on constant strings. This is bad, because the prototype standardized by POSIX allows the implementation to use its argument as a storage buffer. This change eliminates some of these unportable calls to basename() in cases where it was only added for cosmetical reasons, namely to trim argv[0]. There's nothing wrong with setting argv[0] to the full path. Reviewed by: jilles Differential Revision: https://reviews.freebsd.org/D6093 --- usr.bin/newgrp/newgrp.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'usr.bin/newgrp') diff --git a/usr.bin/newgrp/newgrp.c b/usr.bin/newgrp/newgrp.c index 9b3972e9eaf6..8fc90f3a60d0 100644 --- a/usr.bin/newgrp/newgrp.c +++ b/usr.bin/newgrp/newgrp.c @@ -36,7 +36,6 @@ __FBSDID("$FreeBSD$"); #include #include #include -#include #include #include #include @@ -290,7 +289,7 @@ loginshell(void) if (ticket != NULL) setenv("KRBTKFILE", ticket, 1); - if (asprintf(args, "-%s", basename(shell)) < 0) + if (asprintf(args, "-%s", shell) < 0) err(1, "asprintf"); args[1] = NULL; @@ -306,6 +305,6 @@ doshell(void) shell = pwd->pw_shell; if (*shell == '\0') shell = _PATH_BSHELL; - execl(shell, basename(shell), (char *)NULL); + execl(shell, shell, (char *)NULL); err(1, "%s", shell); } -- cgit v1.2.3