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
[v1.13] cocci: fix warnings related to const qualifiers and DROP_MISSED_TAIL_CALL #28279
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
maintainer-s-little-helper
bot
added
backport/1.13
This PR represents a backport for Cilium 1.13.x of a PR that was merged to main.
kind/backports
This PR provides functionality previously merged into master.
labels
Sep 26, 2023
giorio94
force-pushed
the
pr/giorio94/v1.13/coccicheck-fixes
branch
from
September 26, 2023 09:59
d787723
to
65ecc5b
Compare
[ upstream commit 89dd226 ] Trying to create a new coccinelle check, we realised that some patterns that we expected to match in the bpf/ were in fact never caught. Here is a minimal reproducer. foo.cocci: @@ @@ ( - foo = bar; + foo = baz; ) foo.c (not working): int main (void) { int foo, bar, baz = 0, coccibreaker __maybe_unused; foo = bar; return foo; } Invocation: $ docker run --rm --user 1000 \ --workdir /workspace -v `pwd`:/workspace -it docker.io/cilium/coccicheck:2.4@sha256:24abe3fbb8e829fa41a68a3b76cb4df84fd5a87a7d1d6254c1c1fe5effb5bd1b \ spatch --include-headers --very-quiet --in-place \ --sp-file contrib/coccinelle/foo.cocci bpf/foo.c This does not catch the "foo = bar;" statement in the C file. However, the pattern is caught in the following file instead: foo.c (working): int main (void) { int foo, bar, baz = 0; int coccifine __maybe_unused; foo = bar; return foo; } The __maybe_unused attribute seems to prevent spatch to parse correctly the function. This happens independently of whether __maybe_unused is defined in the C code. The behaviour remains the same if we replace __maybe_unused with some other random word (although replacing it with "__attribute__((unused))" works as expected). Running from coccinelle's "master" branch works fine, and when running spatch locally (no Docker image) we can also observe the following warnings: warning: Can't find macro file: /usr/local/bin/lib/coccinelle/standard.h warning: Can't find default iso file: /usr/local/bin/lib/coccinelle/standard.iso This error was fixed with commit coccinelle/coccinelle@540888ff426e ("Fix 263: wrong default path for COCCINELLE_HOME") [0], which is not part of a release yet. Until it is, we still want to have our code covered by coccinelle. As a workaround to the issue, we could pass manually the paths to the files containing the definitions for the isomorphisms and built-in macros for coccinelle, with spatch options "--macro-file-builtin" and "--iso-file". Even simpler, we can set $(COCCINELLE_HOME) to the correct path so that both files are found. No camels were harmed during this investigation. [0] https://gitlab.inria.fr/coccinelle/coccinelle/-/commit/540888ff426e Signed-off-by: Quentin Monnet <quentin@isovalent.com> Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
The coccicheck has been silently failing for a while [1], and the CI was recently fixed for the v1.13 branch bumping the related docker image in 100b580. Hence, let's fix the const qualifier errors reported by coccinelle, leveraging the spatch tool. In one case, the automatic fix failed with: EXN: Failure("bpf/lib/proxy.h: 155: try to delete an expanded token: struct") in bpf/lib/proxy.h but after manually adding the const qualifier to CT_TUPLE_TYPE the error was resolved. [1]: 0dad157 ("cocci: Fix Python path for coccilib") Related: 72fece4 ("bpf: Add some missing const qualifiers") Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
The coccicheck has been silently failing for a while [1], and the CI was recently fixed for the v1.13 branch bumping the related docker image in 100b580. The check currently complains about two missing DROP_MISSED_TAIL_CALL occurrences in bpf/lib/nodeport.h, although we do actually return it (but indirectly). Let's make it more explicit, so that the check no longer emits a warning. [1]: 0dad157 ("cocci: Fix Python path for coccilib") Related: 279bbdc ("bpf: Return DROP_MISSED_TAIL_CALL when missing some tail calls") Signed-off-by: Marco Iorio <marco.iorio@isovalent.com>
giorio94
force-pushed
the
pr/giorio94/v1.13/coccicheck-fixes
branch
from
September 26, 2023 13:19
65ecc5b
to
c26dda1
Compare
/test-backport-1.13 |
/test-1.26-net-next Failed due to |
giorio94
changed the title
cocci: fix warnings related to const qualifiers and DROP_MISSED_TAIL_CALL
[v1.13] cocci: fix warnings related to const qualifiers and DROP_MISSED_TAIL_CALL
Sep 26, 2023
qmonnet
approved these changes
Sep 26, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK looks good, thank you!
aanm
approved these changes
Sep 26, 2023
tklauser
approved these changes
Sep 27, 2023
lmb
approved these changes
Sep 27, 2023
maintainer-s-little-helper
bot
added
the
ready-to-merge
This PR has passed all tests and received consensus from code owners to merge.
label
Sep 27, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
backport/1.13
This PR represents a backport for Cilium 1.13.x of a PR that was merged to main.
kind/backports
This PR provides functionality previously merged into master.
ready-to-merge
This PR has passed all tests and received consensus from code owners to merge.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The coccicheck has been silently failing for a while [1], and the CI was recently fixed for the v1.13 branch bumping the related docker image in 100b580. Yet, the given check was not run in that PR (fixed by #28122, currently being backported), hence the warnings are only popping up in newer PRs. Hence, let's fix them.
[1]: 0dad157 ("cocci: Fix Python path for coccilib")