Skip to content

Commit

Permalink
libbpf-cargo: Suppress some Clippy warnings
Browse files Browse the repository at this point in the history
With the changes to initialize maps inline during skeleton open/load, we
may end up with Clippy complaining that a loop never loops or a match
never matches, if there are no maps present.
Silence the warnings. Such patterns are to be expected in generated code
like this.

Closes: #921

Signed-off-by: Daniel Müller <[email protected]>
  • Loading branch information
d-e-s-o committed Aug 23, 2024
1 parent 658277e commit ddbb119
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libbpf-cargo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Unreleased
----------
- Silenced possible `clippy` reported warnings in generated skeleton
when BPF object file does not contain any maps


0.24.2
------
- Fixed panic on "open" of skeleton with `kconfig` map
Expand Down
2 changes: 2 additions & 0 deletions libbpf-cargo/src/gen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ fn gen_skel_map_defs(
let object = unsafe {{
std::mem::transmute::<&mut libbpf_rs::{prefix}Object, &'obj mut libbpf_rs::{prefix}Object>(object)
}};
#[allow(clippy::never_loop)]
for map in object.maps_mut() {{
let name = map
.name()
Expand All @@ -468,6 +469,7 @@ fn gen_skel_map_defs(
\"map has invalid name\",
))
}})?;
#[allow(clippy::match_single_binding)]
match name {{
",
)?;
Expand Down

0 comments on commit ddbb119

Please sign in to comment.