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

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

Merged
merged 2 commits into from
Dec 2, 2024

Conversation

alejandro-colomar
Copy link
Collaborator

@alejandro-colomar alejandro-colomar commented Nov 17, 2024

Except for the added (and sorted) includes, and the removal of redundant parentheses, this patch can be approximated with the following semantic patch:

$ cat ~/tmp/spatch/streq.sp;
@@
expression a, b;
@@

- strcmp(a, b) == 0
+ streq(a, b)

@@
expression a, b;
@@

- 0 == strcmp(a, b)
+ streq(a, b)

@@
expression a, b;
@@

- !strcmp(a, b)
+ streq(a, b)

$ find contrib/ lib* src/ -type f \
| xargs spatch --sp-file ~/tmp/spatch/streq.sp --in-place;
$ git restore lib/string/strcmp/streq.h;

Revisions:

v2
  • Use !streq() instead of its pattern.
$ git range-diff shadow/master gh/streq streq 
1:  10fea159 = 1:  10fea159 contrib/, lib/, src/: Use streq() instead of its pattern
-:  -------- > 2:  985ac5e5 lib/, src/: Use !streq() instead of its pattern

Except for the added (and sorted) includes, and the removal of redundant
parentheses, this patch can be approximated with the following semantic
patch:

	$ cat ~/tmp/spatch/streq.sp;
	@@
	expression a, b;
	@@

	- strcmp(a, b) == 0
	+ streq(a, b)

	@@
	expression a, b;
	@@

	- 0 == strcmp(a, b)
	+ streq(a, b)

	@@
	expression a, b;
	@@

	- !strcmp(a, b)
	+ streq(a, b)

	$ find contrib/ lib* src/ -type f \
	| xargs spatch --sp-file ~/tmp/spatch/streq.sp --in-place;
	$ git restore lib/string/strcmp/streq.h;

Signed-off-by: Alejandro Colomar <alx@kernel.org>
Except for the added (and sorted) includes, and the removal of redundant
parentheses, and one special case, this patch can be approximated with
the following semantic patch:

	$ cat ~/tmp/spatch/strneq.sp;
	@@
	expression a, b;
	@@

	- strcmp(a, b) != 0
	+ !streq(a, b)

	@@
	expression a, b;
	@@

	- 0 != strcmp(a, b)
	+ !streq(a, b)

	$ find contrib/ lib* src/ -type f \
	| xargs spatch --sp-file ~/tmp/spatch/strneq.sp --in-place;

Signed-off-by: Alejandro Colomar <alx@kernel.org>
@alejandro-colomar alejandro-colomar added the Simpler A good issue for a new beginner label Nov 26, 2024
@hallyn hallyn merged commit 9f12914 into shadow-maint:master Dec 2, 2024
9 checks passed
@alejandro-colomar alejandro-colomar deleted the streq branch December 2, 2024 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Simpler A good issue for a new beginner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants