diff --git a/aya-log-parser/src/lib.rs b/aya-log-parser/src/lib.rs index cdce04e0a..1bdf2abed 100644 --- a/aya-log-parser/src/lib.rs +++ b/aya-log-parser/src/lib.rs @@ -1,3 +1,6 @@ +// We implement our own formatter here and we pass literal strings on purpose. +#![allow(clippy::literal_string_with_formatting_args)] + use std::str; use aya_log_common::DisplayHint; diff --git a/aya-obj/src/btf/relocation.rs b/aya-obj/src/btf/relocation.rs index 87a1efc0e..eef300d07 100644 --- a/aya-obj/src/btf/relocation.rs +++ b/aya-obj/src/btf/relocation.rs @@ -1068,7 +1068,7 @@ impl ComputedRelocation { } BtfType::Enum64(en) => { let variant = &en.variants[accessor.index]; - (variant.value_high as u64) << 32 | variant.value_low as u64 + ((variant.value_high as u64) << 32) | variant.value_low as u64 } // candidate selection ensures that rel_kind == local_kind == target_kind _ => unreachable!(), diff --git a/aya/src/maps/lpm_trie.rs b/aya/src/maps/lpm_trie.rs index f7efd87fa..328758665 100644 --- a/aya/src/maps/lpm_trie.rs +++ b/aya/src/maps/lpm_trie.rs @@ -63,7 +63,7 @@ pub struct LpmTrie { /// let ipaddr = Ipv4Addr::new(8,8,8,8); /// let key = Key::new(16, u32::from(ipaddr).to_be()); /// ``` -#[repr(packed)] +#[repr(C, packed)] pub struct Key { prefix_len: u32, data: K, diff --git a/aya/src/sys/mod.rs b/aya/src/sys/mod.rs index 05f8b4dd7..f7b2cc25e 100644 --- a/aya/src/sys/mod.rs +++ b/aya/src/sys/mod.rs @@ -93,6 +93,10 @@ fn syscall(call: Syscall<'_>) -> SysResult { #[cfg(test)] return TEST_SYSCALL.with(|test_impl| unsafe { test_impl.borrow()(call) }); + // The type of integer taken by `ioctl` is different in glibc (i64) and + // musl (i32). musl builds would complain about useless conversion. + // `libc::ioctl` returns i32 on x86_64 while `libc::syscall` returns i64. + #[allow(clippy::useless_conversion)] #[cfg_attr(test, allow(unreachable_code))] { let ret = unsafe { @@ -109,8 +113,6 @@ fn syscall(call: Syscall<'_>) -> SysResult { } => libc::syscall(SYS_perf_event_open, &attr, pid, cpu, group, flags), Syscall::PerfEventIoctl { fd, request, arg } => { let ret = libc::ioctl(fd.as_raw_fd(), request.try_into().unwrap(), arg); - // `libc::ioctl` returns i32 on x86_64 while `libc::syscall` returns i64. - #[allow(clippy::useless_conversion)] ret.into() } } diff --git a/ebpf/aya-ebpf/src/maps/lpm_trie.rs b/ebpf/aya-ebpf/src/maps/lpm_trie.rs index 16f947263..cbbcd411e 100644 --- a/ebpf/aya-ebpf/src/maps/lpm_trie.rs +++ b/ebpf/aya-ebpf/src/maps/lpm_trie.rs @@ -18,7 +18,7 @@ pub struct LpmTrie { unsafe impl Sync for LpmTrie {} -#[repr(packed)] +#[repr(C, packed)] pub struct Key { /// Represents the number of bits matched against. pub prefix_len: u32, diff --git a/ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs b/ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs index 18f8c9958..e8caf0b5b 100644 --- a/ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs +++ b/ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs @@ -51,7 +51,7 @@ impl PerfEventArray { } pub fn output_at_index(&self, ctx: &C, index: u32, data: &T, flags: u32) { - let flags = u64::from(flags) << 32 | u64::from(index); + let flags = (u64::from(flags) << 32) | u64::from(index); unsafe { bpf_perf_event_output( ctx.as_ptr(), diff --git a/ebpf/aya-ebpf/src/maps/perf/perf_event_byte_array.rs b/ebpf/aya-ebpf/src/maps/perf/perf_event_byte_array.rs index 2e08ea9cb..8c8771394 100644 --- a/ebpf/aya-ebpf/src/maps/perf/perf_event_byte_array.rs +++ b/ebpf/aya-ebpf/src/maps/perf/perf_event_byte_array.rs @@ -48,7 +48,7 @@ impl PerfEventByteArray { } pub fn output_at_index(&self, ctx: &C, index: u32, data: &[u8], flags: u32) { - let flags = u64::from(flags) << 32 | u64::from(index); + let flags = (u64::from(flags) << 32) | u64::from(index); unsafe { bpf_perf_event_output( ctx.as_ptr(), diff --git a/xtask/public-api/aya-ebpf.txt b/xtask/public-api/aya-ebpf.txt index 1fbaf3ba7..2692cf5c5 100644 --- a/xtask/public-api/aya-ebpf.txt +++ b/xtask/public-api/aya-ebpf.txt @@ -263,7 +263,7 @@ pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::borrow_mut(&mut self) -> & impl core::convert::From for aya_ebpf::maps::hash_map::PerCpuHashMap pub fn aya_ebpf::maps::hash_map::PerCpuHashMap::from(t: T) -> T pub mod aya_ebpf::maps::lpm_trie -#[repr(packed)] pub struct aya_ebpf::maps::lpm_trie::Key +#[repr(C, packed)] pub struct aya_ebpf::maps::lpm_trie::Key pub aya_ebpf::maps::lpm_trie::Key::data: K pub aya_ebpf::maps::lpm_trie::Key::prefix_len: u32 impl aya_ebpf::maps::lpm_trie::Key diff --git a/xtask/public-api/aya.txt b/xtask/public-api/aya.txt index f208954cb..1d77394d4 100644 --- a/xtask/public-api/aya.txt +++ b/xtask/public-api/aya.txt @@ -264,7 +264,7 @@ pub fn aya::maps::hash_map::PerCpuHashMap::borrow_mut(&mut self) -> &mu impl core::convert::From for aya::maps::hash_map::PerCpuHashMap pub fn aya::maps::hash_map::PerCpuHashMap::from(t: T) -> T pub mod aya::maps::lpm_trie -#[repr(packed)] pub struct aya::maps::lpm_trie::Key +#[repr(C, packed)] pub struct aya::maps::lpm_trie::Key impl aya::maps::lpm_trie::Key pub fn aya::maps::lpm_trie::Key::data(&self) -> K pub fn aya::maps::lpm_trie::Key::new(prefix_len: u32, data: K) -> Self