From owner-svn-src-head@freebsd.org Mon Aug 3 22:07:51 2015 Return-Path: Delivered-To: svn-src-head@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 7520D9B23E2; Mon, 3 Aug 2015 22:07:51 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::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 5968B1517; Mon, 3 Aug 2015 22:07:51 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.14.9/8.14.9) with ESMTP id t73M7pVs034881; Mon, 3 Aug 2015 22:07:51 GMT (envelope-from ed@FreeBSD.org) Received: (from ed@localhost) by repo.freebsd.org (8.14.9/8.14.9/Submit) id t73M7oUF034879; Mon, 3 Aug 2015 22:07:50 GMT (envelope-from ed@FreeBSD.org) Message-Id: <201508032207.t73M7oUF034879@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ed set sender to ed@FreeBSD.org using -f From: Ed Schouten Date: Mon, 3 Aug 2015 22:07:50 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286259 - head/usr.sbin/pw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 03 Aug 2015 22:07:51 -0000 Author: ed Date: Mon Aug 3 22:07:50 2015 New Revision: 286259 URL: https://svnweb.freebsd.org/changeset/base/286259 Log: Avoid calling strlen() where we can use the strspn() return value. Modified: head/usr.sbin/pw/pw_group.c head/usr.sbin/pw/pw_user.c Modified: head/usr.sbin/pw/pw_group.c ============================================================================== --- head/usr.sbin/pw/pw_group.c Mon Aug 3 21:19:31 2015 (r286258) +++ head/usr.sbin/pw/pw_group.c Mon Aug 3 22:07:50 2015 (r286259) @@ -297,7 +297,7 @@ pw_group_show(int argc, char **argv, cha }; if (arg1 != NULL) { - if (strspn(arg1, "0123456789") == strlen(arg1)) + if (arg1[strspn(arg1, "0123456789")] == '\0') id = pw_checkid(arg1, GID_MAX); else name = arg1; @@ -360,7 +360,7 @@ pw_group_del(int argc, char **argv, char bool nis = false; if (arg1 != NULL) { - if (strspn(arg1, "0123456789") == strlen(arg1)) + if (arg1[strspn(arg1, "0123456789")] == '\0') id = pw_checkid(arg1, GID_MAX); else name = arg1; @@ -491,7 +491,7 @@ pw_group_add(int argc, char **argv, char quiet = precrypted = dryrun = pretty = nis = false; if (arg1 != NULL) { - if (strspn(arg1, "0123456789") == strlen(arg1)) + if (arg1[strspn(arg1, "0123456789")] == '\0') id = pw_checkid(arg1, GID_MAX); else name = arg1; @@ -577,7 +577,7 @@ pw_group_mod(int argc, char **argv, char quiet = pretty = dryrun = nis = precrypted = false; if (arg1 != NULL) { - if (strspn(arg1, "0123456789") == strlen(arg1)) + if (arg1[strspn(arg1, "0123456789")] == '\0') id = pw_checkid(arg1, GID_MAX); else name = arg1; Modified: head/usr.sbin/pw/pw_user.c ============================================================================== --- head/usr.sbin/pw/pw_user.c Mon Aug 3 21:19:31 2015 (r286258) +++ head/usr.sbin/pw/pw_user.c Mon Aug 3 22:07:50 2015 (r286259) @@ -214,7 +214,7 @@ pw_userlock(char *arg1, int mode) if (arg1 == NULL) errx(EX_DATAERR, "username or id required"); - if (strspn(arg1, "0123456789") == strlen(arg1)) + if (arg1[strspn(arg1, "0123456789")] == '\0') id = pw_checkid(arg1, UID_MAX); else name = arg1; @@ -709,7 +709,7 @@ pw_user_show(int argc, char **argv, char bool quiet = false; if (arg1 != NULL) { - if (strspn(arg1, "0123456789") == strlen(arg1)) + if (arg1[strspn(arg1, "0123456789")] == '\0') id = pw_checkid(arg1, UID_MAX); else name = arg1; @@ -793,7 +793,7 @@ pw_user_del(int argc, char **argv, char bool quiet = false; if (arg1 != NULL) { - if (strspn(arg1, "0123456789") == strlen(arg1)) + if (arg1[strspn(arg1, "0123456789")] == '\0') id = pw_checkid(arg1, UID_MAX); else name = arg1; @@ -1124,7 +1124,7 @@ pw_user_add(int argc, char **argv, char err(EXIT_FAILURE, "calloc()"); if (arg1 != NULL) { - if (strspn(arg1, "0123456789") == strlen(arg1)) + if (arg1[strspn(arg1, "0123456789")] == '\0') id = pw_checkid(arg1, UID_MAX); else name = arg1; @@ -1435,7 +1435,7 @@ pw_user_mod(int argc, char **argv, char edited = docreatehome = false; if (arg1 != NULL) { - if (strspn(arg1, "0123456789") == strlen(arg1)) + if (arg1[strspn(arg1, "0123456789")] == '\0') id = pw_checkid(arg1, UID_MAX); else name = arg1;