Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/, src/: Use streq() instead of its pattern #1136

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/chkname.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ is_valid_name(const char *name)
*/
int numeric;

if ('\0' == *name ||
('.' == *name && (('.' == name[1] && '\0' == name[2]) ||
'\0' == name[1])) ||
if (streq(name, "") ||
streq(name, ".") ||
streq(name, "..") ||
!((*name >= 'a' && *name <= 'z') ||
(*name >= 'A' && *name <= 'Z') ||
(*name >= '0' && *name <= '9') ||
Expand All @@ -95,7 +95,7 @@ is_valid_name(const char *name)
*name == '_' ||
*name == '.' ||
*name == '-' ||
(*name == '$' && name[1] == '\0')
streq(name, "$")
))
{
errno = EINVAL;
Expand Down
4 changes: 2 additions & 2 deletions src/useradd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2259,9 +2259,9 @@ static void create_home (void)
*/
for (cp = strtok(bhome, "/"); cp != NULL; cp = strtok(NULL, "/")) {
/* Avoid turning a relative path into an absolute path. */
if (bhome[0] == '/' || strlen(path) != 0) {
if (bhome[0] == '/' || !streq(path, ""))
strcat(path, "/");
}

strcat(path, cp);
if (access(path, F_OK) == 0) {
continue;
Expand Down
Loading