summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pw/pw_user.c
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2015-08-03 22:07:50 +0000
committered <ed@FreeBSD.org>2015-08-03 22:07:50 +0000
commit08ce46330fa8d50c5d5057447bda3a7d42f34ab8 (patch)
treefc7c0c89d679539ad14316f217d8fa8b7f8d850a /usr.sbin/pw/pw_user.c
parentce892f66439051a34995d6255ac4703b336d6a9f (diff)
downloadFreeBSD-src-08ce46330fa8d50c5d5057447bda3a7d42f34ab8.zip
FreeBSD-src-08ce46330fa8d50c5d5057447bda3a7d42f34ab8.tar.gz
Avoid calling strlen() where we can use the strspn() return value.
Diffstat (limited to 'usr.sbin/pw/pw_user.c')
-rw-r--r--usr.sbin/pw/pw_user.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/usr.sbin/pw/pw_user.c b/usr.sbin/pw/pw_user.c
index b51a6cb..d9bce87 100644
--- a/usr.sbin/pw/pw_user.c
+++ b/usr.sbin/pw/pw_user.c
@@ -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 *arg1)
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 *arg1)
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 *arg1)
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 *arg1)
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;
OpenPOWER on IntegriCloud