Avoid calling strlen() where we can use the strspn() return value.
This commit is contained in:
parent
1e4d5cf1d6
commit
fc6ab77011
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=286259
@ -297,7 +297,7 @@ pw_group_show(int argc, char **argv, char *arg1)
|
||||
};
|
||||
|
||||
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 *arg1)
|
||||
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 *arg1)
|
||||
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 *arg1)
|
||||
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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user