From owner-svn-src-all@freebsd.org Sun May 1 08:22:12 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id C88FBB288E3; Sun, 1 May 2016 08:22:12 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 89E9F1F54; Sun, 1 May 2016 08:22:12 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u418MBKb073548; Sun, 1 May 2016 08:22:11 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u418MBaa073545; Sun, 1 May 2016 08:22:11 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201605010822.u418MBaa073545@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Sun, 1 May 2016 08:22:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298876 - in head: lib/libutil sbin/hastd usr.bin/newgrp X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 May 2016 08:22:12 -0000 Author: ed Date: Sun May 1 08:22:11 2016 New Revision: 298876 URL: https://svnweb.freebsd.org/changeset/base/298876 Log: 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 Modified: head/lib/libutil/pw_util.c head/sbin/hastd/hooks.c head/usr.bin/newgrp/newgrp.c Modified: head/lib/libutil/pw_util.c ============================================================================== --- head/lib/libutil/pw_util.c Sun May 1 05:01:10 2016 (r298875) +++ head/lib/libutil/pw_util.c Sun May 1 08:22:11 2016 (r298876) @@ -58,7 +58,6 @@ static const char rcsid[] = #include #include #include -#include #include #include #include @@ -315,7 +314,7 @@ pw_edit(int notsetuid) (void)setuid(getuid()); } errno = 0; - execlp(editor, basename(editor), tempname, (char *)NULL); + execlp(editor, editor, tempname, (char *)NULL); _exit(errno); default: /* parent */ Modified: head/sbin/hastd/hooks.c ============================================================================== --- head/sbin/hastd/hooks.c Sun May 1 05:01:10 2016 (r298875) +++ head/sbin/hastd/hooks.c Sun May 1 08:22:11 2016 (r298876) @@ -37,7 +37,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include @@ -352,7 +351,7 @@ hook_execv(const char *path, va_list ap) return; memset(args, 0, sizeof(args)); - args[0] = basename(path); + args[0] = __DECONST(char *, path); for (ii = 1; ii < sizeof(args) / sizeof(args[0]); ii++) { args[ii] = va_arg(ap, char *); if (args[ii] == NULL) Modified: head/usr.bin/newgrp/newgrp.c ============================================================================== --- head/usr.bin/newgrp/newgrp.c Sun May 1 05:01:10 2016 (r298875) +++ head/usr.bin/newgrp/newgrp.c Sun May 1 08:22:11 2016 (r298876) @@ -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); }