Skip to content

Make use of streq/strstartswith and strlen(string-literal) #354

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

Closed
wants to merge 7 commits into from

Conversation

evelikov
Copy link
Collaborator

@evelikov evelikov commented May 24, 2025

Does exactly what it says on the tin.

Any strncmp() and memcmp() instances using a non-literal have not be converted to strstartswith() to avoid introducing (albeit negligible) perf changes.

evelikov added 2 commits May 23, 2025 14:15
Use our handy macro(s) for clarity and consistency sake.

Signed-off-by: Emil Velikov <[email protected]>
Use our handy macro(s) for clarity and consistency sake.

Signed-off-by: Emil Velikov <[email protected]>
evelikov added 5 commits May 24, 2025 18:32
Use our handy macro(s) for clarity and consistency sake.

Signed-off-by: Emil Velikov <[email protected]>
Older compilers had struggles expanding strlen(string-literal) to a
constant compile time expression. Thus our code-base used sizeof() - 1
instead.

This has been resolved for years, so let's use the correct function. As
a bonus point, we can remove a few variable making the code tad easier
to follow.

Signed-off-by: Emil Velikov <[email protected]>
Older compilers had struggles expanding strlen(string-literal) to a
constant compile time expression. Thus our code-base used sizeof() - 1
instead.

This has been resolved for years, so let's use the correct function.

Signed-off-by: Emil Velikov <[email protected]>
Older compilers had struggles expanding strlen(string-literal) to a
constant compile time expression. Thus our code-base used sizeof() - 1
instead.

This has been resolved for years, so let's use the correct function.

Signed-off-by: Emil Velikov <[email protected]>
In the cases where we have a string literal, we can use our helper
without adding performance overhead.

Signed-off-by: Emil Velikov <[email protected]>
Copy link

codecov bot commented May 24, 2025

Codecov Report

Attention: Patch coverage is 29.62963% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
libkmod/libkmod-config.c 0.00% 6 Missing and 5 partials ⚠️
libkmod/libkmod.c 0.00% 3 Missing ⚠️
tools/depmod.c 0.00% 2 Missing ⚠️
libkmod/libkmod-elf.c 75.00% 0 Missing and 1 partial ⚠️
libkmod/libkmod-module.c 66.66% 0 Missing and 1 partial ⚠️
tools/modprobe.c 50.00% 1 Missing ⚠️
Files with missing lines Coverage Δ
libkmod/libkmod-signature.c 71.97% <100.00%> (ø)
shared/util.c 65.95% <ø> (ø)
testsuite/delete_module.c 70.58% <100.00%> (ø)
libkmod/libkmod-elf.c 51.16% <75.00%> (ø)
libkmod/libkmod-module.c 54.02% <66.66%> (ø)
tools/modprobe.c 28.22% <50.00%> (ø)
tools/depmod.c 56.99% <0.00%> (ø)
libkmod/libkmod.c 50.36% <0.00%> (ø)
libkmod/libkmod-config.c 68.80% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

lucasdemarchi pushed a commit that referenced this pull request May 29, 2025
Use our handy macro(s) for clarity and consistency sake.

Signed-off-by: Emil Velikov <[email protected]>
Link: #354
Signed-off-by: Lucas De Marchi <[email protected]>
lucasdemarchi pushed a commit that referenced this pull request May 29, 2025
Use our handy macro(s) for clarity and consistency sake.

Signed-off-by: Emil Velikov <[email protected]>
Link: #354
Signed-off-by: Lucas De Marchi <[email protected]>
lucasdemarchi pushed a commit that referenced this pull request May 29, 2025
Use our handy macro(s) for clarity and consistency sake.

Signed-off-by: Emil Velikov <[email protected]>
Link: #354
Signed-off-by: Lucas De Marchi <[email protected]>
lucasdemarchi pushed a commit that referenced this pull request May 29, 2025
Older compilers had struggles expanding strlen(string-literal) to a
constant compile time expression. Thus our code-base used sizeof() - 1
instead.

This has been resolved for years, so let's use the correct function. As
a bonus point, we can remove a few variable making the code tad easier
to follow.

Signed-off-by: Emil Velikov <[email protected]>
Link: #354
Signed-off-by: Lucas De Marchi <[email protected]>
lucasdemarchi pushed a commit that referenced this pull request May 29, 2025
Older compilers had struggles expanding strlen(string-literal) to a
constant compile time expression. Thus our code-base used sizeof() - 1
instead.

This has been resolved for years, so let's use the correct function.

Signed-off-by: Emil Velikov <[email protected]>
Link: #354
Signed-off-by: Lucas De Marchi <[email protected]>
lucasdemarchi pushed a commit that referenced this pull request May 29, 2025
Older compilers had struggles expanding strlen(string-literal) to a
constant compile time expression. Thus our code-base used sizeof() - 1
instead.

This has been resolved for years, so let's use the correct function.

Signed-off-by: Emil Velikov <[email protected]>
Link: #354
Signed-off-by: Lucas De Marchi <[email protected]>
lucasdemarchi pushed a commit that referenced this pull request May 29, 2025
In the cases where we have a string literal, we can use our helper
without adding performance overhead.

Signed-off-by: Emil Velikov <[email protected]>
Link: #354
Signed-off-by: Lucas De Marchi <[email protected]>
@lucasdemarchi
Copy link
Contributor

Applied, thanks.

@evelikov evelikov deleted the moar-streq branch May 30, 2025 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants