]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/chkname.c: is_valid_user_name(): Avoid a cast
authorAlejandro Colomar <alx@kernel.org>
Mon, 5 Feb 2024 11:40:51 +0000 (12:40 +0100)
committerSerge Hallyn <serge@hallyn.com>
Tue, 13 Feb 2024 22:13:05 +0000 (16:13 -0600)
By using a temporary vairable, we can remove a cast.

Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
Cc: Tobias Stoeckmann <tobias@stoeckmann.org>
Cc: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/chkname.c

index 79fa29c36ab7df1e908ca98e1a86b20a68c6999b..fbd6ba8899d0b783671f5dbab633bbefec26ae8f 100644 (file)
@@ -76,17 +76,21 @@ static bool is_valid_name (const char *name)
 bool
 is_valid_user_name(const char *name)
 {
-       long  maxsize;
+       long    conf;
+       size_t  maxsize;
 
        errno = 0;
-       maxsize = sysconf(_SC_LOGIN_NAME_MAX);
-       if (maxsize == -1 && errno != 0)
+       conf = sysconf(_SC_LOGIN_NAME_MAX);
+
+       if (conf == -1 && errno != 0)
                maxsize = LOGIN_NAME_MAX;
+       else
+               maxsize = conf;
 
-       if (strlen(name) >= (size_t)maxsize)
+       if (strlen(name) >= maxsize)
                return false;
 
-       return is_valid_name (name);
+       return is_valid_name(name);
 }