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
-2
@@ -28,6 +28,7 @@
|
||||
#include "shadowlog.h"
|
||||
#include "string/sprintf/xasprintf.h"
|
||||
#include "string/strchr/stpspn.h"
|
||||
#include "string/strcmp/streq.h"
|
||||
#include "string/strdup/xstrdup.h"
|
||||
#include "string/strtok/stpsep.h"
|
||||
|
||||
@@ -60,7 +61,7 @@ static void read_env_file (const char *filename)
|
||||
cp = buf;
|
||||
/* ignore whitespace and comments */
|
||||
cp = stpspn(cp, " \t");
|
||||
if (('\0' == *cp) || ('#' == *cp)) {
|
||||
if (streq(cp, "") || ('#' == *cp)) {
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
@@ -209,7 +210,7 @@ void setup_env (struct passwd *info)
|
||||
* Create the SHELL environmental variable and export it.
|
||||
*/
|
||||
|
||||
if ((NULL == info->pw_shell) || ('\0' == *info->pw_shell)) {
|
||||
if ((NULL == info->pw_shell) || streq(info->pw_shell, "")) {
|
||||
free (info->pw_shell);
|
||||
info->pw_shell = xstrdup (SHELL);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user