From: Alejandro Colomar Date: Tue, 31 Dec 2024 22:37:39 +0000 (+0100) Subject: src/: Simplify, using strpbrk(3) X-Git-Tag: 4.18.0-rc1~73 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d1aec10e2c26a3dbaa6055ab8c1d15292f59e14b;p=thirdparty%2Fshadow.git src/: Simplify, using strpbrk(3) Checking a boolean (actually, a boolean-like pointer) is more readable than comparing against a length. This removes the only uses of strcspn(3) in this project. strpbrk(3) is a simpler call, even though it has a weird name. It's just like strchr(3) but searches for several characters. I'd have named it strchrs(). Signed-off-by: Alejandro Colomar --- diff --git a/src/useradd.c b/src/useradd.c index 258a6cbbb..9180d2429 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -111,7 +111,7 @@ static const char *def_log_init = "yes"; static long def_inactive = -1; static const char *def_expire = ""; -#define VALID(s) (strcspn (s, ":\n") == strlen (s)) +#define VALID(s) (!strpbrk(s, ":\n")) static const char *user_name = ""; static const char *user_pass = "!"; diff --git a/src/usermod.c b/src/usermod.c index b4cf2e705..e886a1531 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -94,7 +94,7 @@ #define E_SUB_GID_UPDATE 18 /* can't update the subordinate gid file */ #endif /* ENABLE_SUBIDS */ -#define VALID(s) (strcspn (s, ":\n") == strlen (s)) +#define VALID(s) (!strpbrk(s, ":\n")) /* * Global variables