Skip to content

Commit

Permalink
lib/chkname.c: is_valid_user_name(): Avoid a cast
Browse files Browse the repository at this point in the history
By using a temporary vairable, we can remove a cast.

Reviewed-by: Iker Pedrosa <[email protected]>
Cc: Tobias Stoeckmann <[email protected]>
Cc: Serge Hallyn <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
  • Loading branch information
alejandro-colomar authored and hallyn committed Feb 13, 2024
1 parent ad307ee commit f22ca21
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/chkname.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down

0 comments on commit f22ca21

Please sign in to comment.