Skip to content

Commit

Permalink
chore: Fix cippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vadorovsky committed Dec 27, 2024
1 parent aea3efe commit 4f0559f
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 9 deletions.
3 changes: 3 additions & 0 deletions aya-log-parser/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion aya-obj/src/btf/relocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(),
Expand Down
2 changes: 1 addition & 1 deletion aya/src/maps/lpm_trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 4 additions & 2 deletions aya/src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
}
}
Expand Down
2 changes: 1 addition & 1 deletion ebpf/aya-ebpf/src/maps/lpm_trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ebpf/aya-ebpf/src/maps/perf/perf_event_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion ebpf/aya-ebpf/src/maps/perf/perf_event_byte_array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion xtask/public-api/aya-ebpf.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion xtask/public-api/aya.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4f0559f

Please sign in to comment.