Skip to content

[RFC] Introduce checkpatch action #474

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cargo_task_tempate: &cargo_task_template
- cat Cargo.lock
setup_script:
- apt-get update
- apt-get -y install llvm clang libelf-dev libpcap-dev python3-pip make jq
- apt-get -y install locales llvm clang libelf-dev libpcap-dev python3-pip make jq
- rustup component add rustfmt
- rustup component add clippy
before_cache_script: rm -rf $CARGO_HOME/registry/index
Expand All @@ -20,9 +20,25 @@ unittest_task:
image: rust:bookworm
build_script: make V=1 CARGO_OPTS=--verbose
test_script: make test V=1 CARGO_OPTS=--verbose
check_script:
rust_check_script:
- cargo fmt --check
- cargo clippy -- -D warnings
ebpf_style_script: |
# make perl happy.
locale-gen en_US.UTF-8
export LANGUAGE=en_US.UTF-8
git remote update origin
cirrus_base=$(git merge-base origin/$CIRRUS_BASE_BRANCH HEAD)
COMMIT_RANGE=$(git rev-list ${cirrus_base}..HEAD --reverse)
for commit in $COMMIT_RANGE; do
pretty_commit=$(git -P show -s --format="%h (\"%s\")" --abbrev=12 ${commit})
echo "Commit ${pretty_commit}"
printf -- '-%0.s' $(seq 1 ${#pretty_commit})
echo "-------"
git show --format=email ${commit} -- '*/bpf/*' | ./tools/checkpatch.pl --no-tree --ignore=SPDX_LICENSE_TAG,FILE_PATH_CHANGES,EMAIL_SUBJECT,VOLATILE -q || { restyle=1 ; true ; }
echo
done
[ -z "${restyle}" ]

benchmark_task:
<< : *cargo_task_template
Expand Down
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
vmlinux.h linguist-vendored
**/bpf_sys/include/linux/*.h linguist-vendored
*_uapi.rs linguist-vendored
tools/checkpatch.pl linguist-vendored
tools/spelling.txt linguist-vendored
tools/const_structs.checkpatch linguist-vendored
11 changes: 6 additions & 5 deletions docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,13 @@ and/or [help wanted](https://github.com/retis-org/retis/issues?q=is%3Aissue+is%3

### Coding style

We strictly follow the Rust coding style as enforced by `rustfmt` and have a
strong preference for the
[Linux kernel](https://www.kernel.org/doc/html/latest/process/coding-style.html)
and particularly its
We strictly follow the Rust coding style as enforced by `rustfmt` and we also adhere the
[Linux kernel](https://www.kernel.org/doc/html/latest/process/coding-style.html) coding style
as enforced by `checkpatch.pl` and particularly its
[networking](https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html#multi-line-comments)
flavor coding style for the BPF parts.
flavor for the BPF parts. `checkpatch.pl` can generate false
positives, and in such case the formerly described coding style rules
take precedence over its suggestions.

### Events and Rust bindings

Expand Down
9 changes: 5 additions & 4 deletions retis/src/core/filters/packets/bpf/include/packet_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ unsigned int packet_filter(struct retis_packet_filter_ctx *ctx, u32 placeholder)
u8 stack[STACK_SIZE] __attribute__ ((aligned (8)));
register u64 *fp asm("r9");

if (!ctx)
if (!ctx) {
return 0;
}

ctx_reg = ctx;
ctx_reg = ctx;
fp = (u64 *)((void *)stack + sizeof(stack));

asm volatile (
Expand All @@ -74,7 +75,7 @@ unsigned int packet_filter(struct retis_packet_filter_ctx *ctx, u32 placeholder)
"r4", "r5", "r6", "r7",
"r8", "r9");

return ctx->ret;
}
return ctx->ret;
}

#endif
2 changes: 1 addition & 1 deletion retis/src/core/probe/kernel/bpf/raw_tracepoint.bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* It is safe to have these values per-object as the loaded object won't be
* shared between attached programs for raw tracepoints.
*/
const volatile u64 ksym = 0;
const volatile u64 ksym = 0;
const volatile u32 nargs = 0;

/* We unroll the loop bellow as the verifier disallow arithmetic operations on
Expand Down
Loading