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:
Alejandro Colomar
2024-12-02 13:16:56 +01:00
committed by Serge Hallyn
parent 8424d7c494
commit 7182d6402f
28 changed files with 88 additions and 69 deletions
+2 -2
View File
@@ -227,7 +227,7 @@ static int get_groups (char *list)
*/
user_groups[0] = NULL;
if ('\0' == *list) {
if (streq(list, "")) {
return 0;
}
@@ -2186,7 +2186,7 @@ int main (int argc, char **argv)
* be changed while the user is logged in.
* Note: no need to check if a prefix is specified...
*/
if ( (prefix[0] == '\0') && (uflg || lflg || dflg
if (streq(prefix, "") && (uflg || lflg || dflg
#ifdef ENABLE_SUBIDS
|| Vflg || Wflg
#endif /* ENABLE_SUBIDS */