chore: Fix cippy errors

reviewable/pr1119/r1
Michal Rostecki 3 weeks ago
parent aea3efecd5
commit 4f0559f2af

@ -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;

@ -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!(),

@ -63,7 +63,7 @@ pub struct LpmTrie<T, K, V> {
/// 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<K: Pod> {
prefix_len: u32,
data: K,

@ -93,6 +93,10 @@ fn syscall(call: Syscall<'_>) -> SysResult<i64> {
#[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<i64> {
} => 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()
}
}

@ -18,7 +18,7 @@ pub struct LpmTrie<K, V> {
unsafe impl<K: Sync, V: Sync> Sync for LpmTrie<K, V> {}
#[repr(packed)]
#[repr(C, packed)]
pub struct Key<K> {
/// Represents the number of bits matched against.
pub prefix_len: u32,

@ -51,7 +51,7 @@ impl<T> PerfEventArray<T> {
}
pub fn output_at_index<C: EbpfContext>(&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(),

@ -48,7 +48,7 @@ impl PerfEventByteArray {
}
pub fn output_at_index<C: EbpfContext>(&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(),

@ -263,7 +263,7 @@ pub fn aya_ebpf::maps::hash_map::PerCpuHashMap<K, V>::borrow_mut(&mut self) -> &
impl<T> core::convert::From<T> for aya_ebpf::maps::hash_map::PerCpuHashMap<K, V>
pub fn aya_ebpf::maps::hash_map::PerCpuHashMap<K, V>::from(t: T) -> T
pub mod aya_ebpf::maps::lpm_trie
#[repr(packed)] pub struct aya_ebpf::maps::lpm_trie::Key<K>
#[repr(C, packed)] pub struct aya_ebpf::maps::lpm_trie::Key<K>
pub aya_ebpf::maps::lpm_trie::Key::data: K
pub aya_ebpf::maps::lpm_trie::Key::prefix_len: u32
impl<K> aya_ebpf::maps::lpm_trie::Key<K>

@ -264,7 +264,7 @@ pub fn aya::maps::hash_map::PerCpuHashMap<T, K, V>::borrow_mut(&mut self) -> &mu
impl<T> core::convert::From<T> for aya::maps::hash_map::PerCpuHashMap<T, K, V>
pub fn aya::maps::hash_map::PerCpuHashMap<T, K, V>::from(t: T) -> T
pub mod aya::maps::lpm_trie
#[repr(packed)] pub struct aya::maps::lpm_trie::Key<K: aya::Pod>
#[repr(C, packed)] pub struct aya::maps::lpm_trie::Key<K: aya::Pod>
impl<K: aya::Pod> aya::maps::lpm_trie::Key<K>
pub fn aya::maps::lpm_trie::Key<K>::data(&self) -> K
pub fn aya::maps::lpm_trie::Key<K>::new(prefix_len: u32, data: K) -> Self

Loading…
Cancel
Save