lib/, src/: Use streq() instead of its pattern
Except for the added (and sorted) includes, the removal of redundant parentheses, a few cases that have been refactored for readability, and a couple of non-string cases that I've left out of the change, this patch can be approximated with the following semantic patch: $ cat ~/tmp/spatch/streq.sp @@ expression s; @@ - '\0' == *s + streq(s, "") @@ expression s; @@ - '\0' == s[0] + streq(s, "") @@ expression s; @@ - *s == '\0' + streq(s, "") @@ expression s; @@ - s[0] == '\0' + streq(s, "") $ find contrib/ lib* src/ -type f \ | xargs spatch --in-place --sp-file ~/tmp/spatch/streq.sp; Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
committed by
Serge Hallyn
parent
8424d7c494
commit
7182d6402f
+3
-3
@@ -42,8 +42,8 @@ bool valid (const char *password, const struct passwd *ent)
|
||||
* routine is meant to waste CPU time.
|
||||
*/
|
||||
|
||||
if ((NULL != ent->pw_name) && ('\0' == ent->pw_passwd[0])) {
|
||||
if ('\0' == password[0]) {
|
||||
if ((NULL != ent->pw_name) && streq(ent->pw_passwd, "")) {
|
||||
if (streq(password, "")) {
|
||||
return true; /* user entered nothing */
|
||||
} else {
|
||||
return false; /* user entered something! */
|
||||
@@ -54,7 +54,7 @@ bool valid (const char *password, const struct passwd *ent)
|
||||
* If there is no entry then we need a salt to use.
|
||||
*/
|
||||
|
||||
if ((NULL == ent->pw_name) || ('\0' == ent->pw_passwd[0])) {
|
||||
if ((NULL == ent->pw_name) || streq(ent->pw_passwd, "")) {
|
||||
salt = "xx";
|
||||
} else {
|
||||
salt = ent->pw_passwd;
|
||||
|
||||
Reference in New Issue
Block a user