aya-bpf, aya-bpf-bindings: fix clippy lints

pull/42/head
Alessandro Decina 3 years ago
parent 81e07e9661
commit a68ff47246

@ -1,3 +1,4 @@
#![allow(clippy::all, dead_code)]
pub mod bindings;
pub mod getters;
pub mod helpers;

@ -1,3 +1,4 @@
#![allow(clippy::all, dead_code)]
pub mod bindings;
pub mod getters;
pub mod helpers;

@ -1,3 +1,4 @@
#![allow(clippy::all, dead_code)]
pub mod bindings;
pub mod getters;
pub mod helpers;

@ -274,6 +274,7 @@ fn name_arg(args: &mut Args) -> Result<Option<String>> {
Ok(name)
}
#[allow(clippy::enum_variant_names)]
#[derive(Debug, Copy, Clone)]
pub enum ProbeKind {
KProbe,

@ -21,12 +21,13 @@ pub unsafe fn bpf_probe_read<T>(src: *const T) -> Result<T, c_long> {
}
#[inline]
pub fn bpf_get_current_comm() -> Result<[c_char; 16], ()> {
pub fn bpf_get_current_comm() -> Result<[c_char; 16], c_long> {
let mut comm: [c_char; 16usize] = [0; 16];
if unsafe { gen::bpf_get_current_comm(&mut comm as *mut _ as *mut c_void, 16u32) } == 0 {
let ret = unsafe { gen::bpf_get_current_comm(&mut comm as *mut _ as *mut c_void, 16u32) };
if ret == 0 {
Ok(comm)
} else {
Err(())
Err(ret)
}
}

@ -1,3 +1,4 @@
#![allow(clippy::missing_safety_doc)]
#![no_std]
pub use aya_bpf_bindings::bindings;
@ -9,7 +10,7 @@ pub mod programs;
pub use aya_bpf_cty as cty;
use core::ffi::c_void;
use cty::c_char;
use cty::{c_char, c_long};
use helpers::{bpf_get_current_comm, bpf_get_current_pid_tgid};
pub use aya_bpf_macros as macros;
@ -20,7 +21,7 @@ pub trait BpfContext {
fn as_ptr(&self) -> *mut c_void;
#[inline]
fn command(&self) -> Result<[c_char; TASK_COMM_LEN], ()> {
fn command(&self) -> Result<[c_char; TASK_COMM_LEN], c_long> {
bpf_get_current_comm()
}

@ -51,12 +51,11 @@ impl<K> SockHash<K> {
}
pub unsafe fn redirect(&mut self, ctx: &SkMsgContext, key: &mut K, flags: u64) -> i64 {
let ret = bpf_msg_redirect_hash(
bpf_msg_redirect_hash(
ctx.as_ptr() as *mut _,
&mut self.def as *mut _ as *mut _,
key as *mut _ as *mut _,
flags,
);
ret
)
}
}

@ -49,12 +49,11 @@ impl SockMap {
}
pub unsafe fn redirect(&mut self, ctx: &SkMsgContext, index: u32, flags: u64) -> i64 {
let ret = bpf_msg_redirect_map(
bpf_msg_redirect_map(
ctx.as_ptr() as *mut _,
&mut self.def as *mut _ as *mut _,
index,
flags,
);
ret
)
}
}

@ -20,6 +20,7 @@ impl SkSkbContext {
SkSkbContext { skb }
}
#[allow(clippy::len_without_is_empty)]
#[inline]
pub fn len(&self) -> u32 {
unsafe { *self.skb }.len

Loading…
Cancel
Save