Use #[expect(...)] rather than #[allow(...)]

This is stricter, and revealed a few unused allowances.
reviewable/pr1201/r1
Tamir Duberstein 2 weeks ago
parent 015443776c
commit 4101a5a55d

@ -104,7 +104,7 @@ pub fn build_ebpf(packages: impl IntoIterator<Item = Package>) -> Result<()> {
let stdout = BufReader::new(stdout); let stdout = BufReader::new(stdout);
let mut executables = Vec::new(); let mut executables = Vec::new();
for message in Message::parse_stream(stdout) { for message in Message::parse_stream(stdout) {
#[allow(clippy::collapsible_match)] #[expect(clippy::collapsible_match)]
match message.expect("valid JSON") { match message.expect("valid JSON") {
Message::CompilerArtifact(Artifact { Message::CompilerArtifact(Artifact {
executable, executable,

@ -7,7 +7,6 @@ use syn::{spanned::Spanned as _, ItemFn};
use crate::args::{err_on_unknown_args, pop_string_arg}; use crate::args::{err_on_unknown_args, pop_string_arg};
#[allow(clippy::enum_variant_names)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub(crate) enum KProbeKind { pub(crate) enum KProbeKind {
KProbe, KProbe,

@ -471,7 +471,7 @@ pub fn socket_filter(attrs: TokenStream, item: TokenStream) -> TokenStream {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(non_camel_case_types)] /// # #![expect(non_camel_case_types)]
/// use aya_ebpf::{macros::fentry, programs::FEntryContext}; /// use aya_ebpf::{macros::fentry, programs::FEntryContext};
/// # type filename = u32; /// # type filename = u32;
/// # type path = u32; /// # type path = u32;
@ -513,7 +513,7 @@ pub fn fentry(attrs: TokenStream, item: TokenStream) -> TokenStream {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(non_camel_case_types)] /// # #![expect(non_camel_case_types)]
/// use aya_ebpf::{macros::fexit, programs::FExitContext}; /// use aya_ebpf::{macros::fexit, programs::FExitContext};
/// # type filename = u32; /// # type filename = u32;
/// # type path = u32; /// # type path = u32;

@ -5,7 +5,6 @@ use proc_macro2_diagnostics::{Diagnostic, SpanDiagnosticExt as _};
use quote::quote; use quote::quote;
use syn::{spanned::Spanned as _, ItemFn}; use syn::{spanned::Spanned as _, ItemFn};
#[allow(clippy::enum_variant_names)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub(crate) enum SkSkbKind { pub(crate) enum SkSkbKind {
StreamVerdict, StreamVerdict,

@ -7,7 +7,6 @@ use syn::{spanned::Spanned as _, ItemFn};
use crate::args::{err_on_unknown_args, pop_bool_arg, pop_string_arg}; use crate::args::{err_on_unknown_args, pop_bool_arg, pop_string_arg};
#[allow(clippy::enum_variant_names)]
#[derive(Debug, Copy, Clone)] #[derive(Debug, Copy, Clone)]
pub(crate) enum UProbeKind { pub(crate) enum UProbeKind {
UProbe, UProbe,

@ -167,7 +167,7 @@ pub enum DisplayHint {
pub(crate) fn write(tag: u8, value: &[u8], buf: &mut [u8]) -> Option<NonZeroUsize> { pub(crate) fn write(tag: u8, value: &[u8], buf: &mut [u8]) -> Option<NonZeroUsize> {
// TODO(https://github.com/rust-lang/rust-clippy/issues/14112): Remove this allowance when the // TODO(https://github.com/rust-lang/rust-clippy/issues/14112): Remove this allowance when the
// lint behaves more sensibly. // lint behaves more sensibly.
#[allow(clippy::manual_ok_err)] #[expect(clippy::manual_ok_err)]
let wire_len: LogValueLength = match value.len().try_into() { let wire_len: LogValueLength = match value.len().try_into() {
Ok(wire_len) => Some(wire_len), Ok(wire_len) => Some(wire_len),
Err(TryFromIntError { .. }) => None, Err(TryFromIntError { .. }) => None,

@ -75,11 +75,11 @@ use bytes::BytesMut;
use log::{error, Log, Record}; use log::{error, Log, Record};
use thiserror::Error; use thiserror::Error;
#[allow(dead_code)] // TODO(https://github.com/rust-lang/rust/issues/120770): Remove when false positive is fixed. #[expect(dead_code)] // TODO(https://github.com/rust-lang/rust/issues/120770): Remove when false positive is fixed.
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
#[repr(transparent)] #[repr(transparent)]
struct RecordFieldWrapper(RecordField); struct RecordFieldWrapper(RecordField);
#[allow(dead_code)] // TODO(https://github.com/rust-lang/rust/issues/120770): Remove when false positive is fixed. #[expect(dead_code)] // TODO(https://github.com/rust-lang/rust/issues/120770): Remove when false positive is fixed.
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
#[repr(transparent)] #[repr(transparent)]
struct ArgumentWrapper(Argument); struct ArgumentWrapper(Argument);

@ -159,7 +159,6 @@ pub enum BtfError {
/// Available BTF features /// Available BTF features
#[derive(Default, Debug)] #[derive(Default, Debug)]
#[allow(missing_docs)]
pub struct BtfFeatures { pub struct BtfFeatures {
btf_func: bool, btf_func: bool,
btf_func_global: bool, btf_func_global: bool,

@ -1,6 +1,6 @@
//! BTF loading, parsing and relocation. //! BTF loading, parsing and relocation.
#[allow(clippy::module_inception)] #[expect(clippy::module_inception)]
mod btf; mod btf;
mod info; mod info;
mod relocation; mod relocation;

@ -194,7 +194,6 @@ pub(crate) struct Relocation {
} }
impl Relocation { impl Relocation {
#[allow(unused_unsafe)]
pub(crate) unsafe fn parse(data: &[u8], number: usize) -> Result<Relocation, BtfError> { pub(crate) unsafe fn parse(data: &[u8], number: usize) -> Result<Relocation, BtfError> {
if mem::size_of::<bpf_core_relo>() > data.len() { if mem::size_of::<bpf_core_relo>() > data.len() {
return Err(BtfError::InvalidRelocationInfo); return Err(BtfError::InvalidRelocationInfo);
@ -1189,7 +1188,6 @@ impl ComputedRelocation {
type_id: None, type_id: None,
}; };
#[allow(clippy::wildcard_in_or_patterns)]
match rel.kind { match rel.kind {
FieldByteOffset => { FieldByteOffset => {
value.value = byte_off as u64; value.value = byte_off as u64;

@ -1,4 +1,4 @@
#![allow(missing_docs)] #![expect(missing_docs)]
use alloc::{string::ToString, vec, vec::Vec}; use alloc::{string::ToString, vec, vec::Vec};
use core::{fmt::Display, mem, ptr}; use core::{fmt::Display, mem, ptr};
@ -1133,7 +1133,6 @@ unsafe fn read_array<T>(data: &[u8], len: usize) -> Result<Vec<T>, BtfError> {
} }
impl BtfType { impl BtfType {
#[allow(unused_unsafe)]
pub(crate) unsafe fn read(data: &[u8], endianness: Endianness) -> Result<BtfType, BtfError> { pub(crate) unsafe fn read(data: &[u8], endianness: Endianness) -> Result<BtfType, BtfError> {
let ty = unsafe { read_array::<u32>(data, 3)? }; let ty = unsafe { read_array::<u32>(data, 3)? };
let data = &data[mem::size_of::<u32>() * 3..]; let data = &data[mem::size_of::<u32>() * 3..];

@ -1,13 +1,5 @@
//! eBPF bindings generated by rust-bindgen //! eBPF bindings generated by rust-bindgen
#![allow(
dead_code,
non_camel_case_types,
non_snake_case,
clippy::all,
missing_docs
)]
mod btf_internal_bindings; mod btf_internal_bindings;
#[cfg(target_arch = "aarch64")] #[cfg(target_arch = "aarch64")]
mod linux_bindings_aarch64; mod linux_bindings_aarch64;

@ -66,13 +66,14 @@
)] )]
#![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(clippy::all, missing_docs)] #![deny(clippy::all, missing_docs)]
#![allow(clippy::missing_safety_doc, clippy::len_without_is_empty)] #![expect(clippy::len_without_is_empty)]
extern crate alloc; extern crate alloc;
#[cfg(feature = "std")] #[cfg(feature = "std")]
extern crate std; extern crate std;
pub mod btf; pub mod btf;
#[expect(clippy::all, missing_docs, non_camel_case_types, non_snake_case)]
pub mod generated; pub mod generated;
pub mod links; pub mod links;
pub mod maps; pub mod maps;

@ -107,7 +107,6 @@ impl TryFrom<u32> for PinningType {
} }
/// Map definition in legacy BPF map declaration style /// Map definition in legacy BPF map declaration style
#[allow(non_camel_case_types)]
#[repr(C)] #[repr(C)]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)] #[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
pub struct bpf_map_def { pub struct bpf_map_def {

@ -37,7 +37,6 @@ const KERNEL_VERSION_ANY: u32 = 0xFFFF_FFFE;
/// Features implements BPF and BTF feature detection /// Features implements BPF and BTF feature detection
#[derive(Default, Debug)] #[derive(Default, Debug)]
#[allow(missing_docs)]
pub struct Features { pub struct Features {
bpf_name: bool, bpf_name: bool,
bpf_probe_read_kernel: bool, bpf_probe_read_kernel: bool,
@ -53,7 +52,7 @@ pub struct Features {
impl Features { impl Features {
#[doc(hidden)] #[doc(hidden)]
#[allow(clippy::too_many_arguments)] #[expect(clippy::too_many_arguments)]
pub fn new( pub fn new(
bpf_name: bool, bpf_name: bool,
bpf_probe_read_kernel: bool, bpf_probe_read_kernel: bool,
@ -238,7 +237,7 @@ pub struct Function {
/// - `fmod_ret+`, `fmod_ret.s+` /// - `fmod_ret+`, `fmod_ret.s+`
/// - `iter+`, `iter.s+` /// - `iter+`, `iter.s+`
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[allow(missing_docs)] #[expect(missing_docs)]
pub enum ProgramSection { pub enum ProgramSection {
KRetProbe, KRetProbe,
KProbe, KProbe,
@ -939,7 +938,7 @@ impl Function {
/// Errors caught during parsing the object file /// Errors caught during parsing the object file
#[derive(Debug, thiserror::Error)] #[derive(Debug, thiserror::Error)]
#[allow(missing_docs)] #[expect(missing_docs)]
pub enum ParseError { pub enum ParseError {
#[error("error parsing ELF data")] #[error("error parsing ELF data")]
ElfError(object::read::Error), ElfError(object::read::Error),

@ -71,10 +71,10 @@
//unused_qualifications, https://github.com/rust-lang/rust/commit/9ccc7b7 added size_of to the prelude, but we need to continue to qualify it so that we build on older compilers. //unused_qualifications, https://github.com/rust-lang/rust/commit/9ccc7b7 added size_of to the prelude, but we need to continue to qualify it so that we build on older compilers.
//unused_results, //unused_results,
)] )]
#![allow(clippy::missing_safety_doc, clippy::len_without_is_empty)] #![expect(clippy::missing_safety_doc, clippy::len_without_is_empty)]
#![cfg_attr( #![cfg_attr(
all(feature = "async_tokio", feature = "async_std"), all(feature = "async_tokio", feature = "async_std"),
allow(unused_crate_dependencies) expect(unused_crate_dependencies)
)] )]
mod bpf; mod bpf;

@ -1,5 +1,5 @@
//! Array types. //! Array types.
#[allow(clippy::module_inception)] #[expect(clippy::module_inception)]
mod array; mod array;
mod per_cpu_array; mod per_cpu_array;
mod program_array; mod program_array;

@ -7,7 +7,7 @@ use crate::{
Pod, Pod,
}; };
#[allow(clippy::module_inception)] #[expect(clippy::module_inception)]
mod hash_map; mod hash_map;
mod per_cpu_hash_map; mod per_cpu_hash_map;

@ -121,7 +121,7 @@ impl<T> RingBuf<T> {
// lifetime of the iterator in the returned `RingBufItem`. If the Iterator::Item leveraged GATs, // lifetime of the iterator in the returned `RingBufItem`. If the Iterator::Item leveraged GATs,
// one could imagine an implementation of `Iterator` that would work. GATs are stabilized in // one could imagine an implementation of `Iterator` that would work. GATs are stabilized in
// Rust 1.65, but there's not yet a trait that the community seems to have standardized around. // Rust 1.65, but there's not yet a trait that the community seems to have standardized around.
#[allow(clippy::should_implement_trait)] #[expect(clippy::should_implement_trait)]
pub fn next(&mut self) -> Option<RingBufItem<'_>> { pub fn next(&mut self) -> Option<RingBufItem<'_>> {
let Self { let Self {
consumer, producer, .. consumer, producer, ..

@ -53,7 +53,6 @@ pub enum SamplePolicy {
/// The scope of a PerfEvent /// The scope of a PerfEvent
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
#[allow(clippy::enum_variant_names)]
pub enum PerfEventScope { pub enum PerfEventScope {
/// Calling process, any cpu /// Calling process, any cpu
CallingProcessAnyCpu, CallingProcessAnyCpu,

@ -62,7 +62,7 @@ pub(crate) fn lines(bytes: &[u8]) -> impl Iterator<Item = &OsStr> {
pub(crate) trait OsStringExt { pub(crate) trait OsStringExt {
fn starts_with(&self, needle: &OsStr) -> bool; fn starts_with(&self, needle: &OsStr) -> bool;
#[allow(dead_code)] // Would be odd to have the others without this one. #[expect(dead_code)] // Would be odd to have the others without this one.
fn ends_with(&self, needle: &OsStr) -> bool; fn ends_with(&self, needle: &OsStr) -> bool;
fn strip_prefix(&self, prefix: &OsStr) -> Option<&OsStr>; fn strip_prefix(&self, prefix: &OsStr) -> Option<&OsStr>;
fn strip_suffix(&self, suffix: &OsStr) -> Option<&OsStr>; fn strip_suffix(&self, suffix: &OsStr) -> Option<&OsStr>;

@ -147,7 +147,7 @@ fn syscall(call: Syscall<'_>) -> SysResult {
} }
} }
#[cfg_attr(test, allow(unused_variables))] #[cfg_attr(test, expect(unused_variables))]
pub(crate) unsafe fn mmap( pub(crate) unsafe fn mmap(
addr: *mut c_void, addr: *mut c_void,
len: usize, len: usize,
@ -169,7 +169,7 @@ pub(crate) unsafe fn mmap(
} }
} }
#[cfg_attr(test, allow(unused_variables))] #[cfg_attr(test, expect(unused_variables))]
pub(crate) unsafe fn munmap(addr: *mut c_void, len: usize) -> c_int { pub(crate) unsafe fn munmap(addr: *mut c_void, len: usize) -> c_int {
#[cfg(not(test))] #[cfg(not(test))]
return libc::munmap(addr, len); return libc::munmap(addr, len);

@ -15,7 +15,7 @@ use libc::pid_t;
use super::{syscall, PerfEventIoctlRequest, Syscall}; use super::{syscall, PerfEventIoctlRequest, Syscall};
#[allow(clippy::too_many_arguments)] #[expect(clippy::too_many_arguments)]
pub(crate) fn perf_event_open( pub(crate) fn perf_event_open(
perf_type: u32, perf_type: u32,
config: u64, config: u64,

@ -298,7 +298,7 @@ fn parse_kernel_symbols(reader: impl BufRead) -> Result<BTreeMap<u64, String>, i
let name = parts.next()?; let name = parts.next()?;
// TODO(https://github.com/rust-lang/rust-clippy/issues/14112): Remove this // TODO(https://github.com/rust-lang/rust-clippy/issues/14112): Remove this
// allowance when the lint behaves more sensibly. // allowance when the lint behaves more sensibly.
#[allow(clippy::manual_ok_err)] #[expect(clippy::manual_ok_err)]
let addr = match u64::from_str_radix(addr, 16) { let addr = match u64::from_str_radix(addr, 16) {
Ok(addr) => Some(addr), Ok(addr) => Some(addr),
Err(ParseIntError { .. }) => None, Err(ParseIntError { .. }) => None,

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

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

@ -1,4 +1,10 @@
#![allow(non_camel_case_types, non_upper_case_globals, non_snake_case)] #![expect(
clippy::all,
dead_code,
non_camel_case_types,
non_snake_case,
non_upper_case_globals
)]
#![deny(warnings)] #![deny(warnings)]
#![no_std] #![no_std]

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

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

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

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

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

@ -5,7 +5,7 @@
//! This crate is guaranteed to compile on stable Rust 1.30.0 and up. It *might* compile with older //! This crate is guaranteed to compile on stable Rust 1.30.0 and up. It *might* compile with older
//! versions but that may change in any new patch release. //! versions but that may change in any new patch release.
#![no_std] #![no_std]
#![allow(non_camel_case_types)] #![expect(non_camel_case_types)]
#![deny(warnings)] #![deny(warnings)]
// AD = Architecture dependent // AD = Architecture dependent

@ -35,7 +35,7 @@ use crate::{
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read}; /// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read};
/// # fn try_test() -> Result<(), c_long> { /// # fn try_test() -> Result<(), c_long> {
/// # let kernel_ptr: *const c_int = 0 as _; /// # let kernel_ptr: *const c_int = 0 as _;
@ -72,7 +72,7 @@ pub unsafe fn bpf_probe_read<T>(src: *const T) -> Result<T, c_long> {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_buf}; /// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_buf};
/// # fn try_test() -> Result<(), c_long> { /// # fn try_test() -> Result<(), c_long> {
/// # let ptr: *const u8 = 0 as _; /// # let ptr: *const u8 = 0 as _;
@ -108,7 +108,7 @@ pub unsafe fn bpf_probe_read_buf(src: *const u8, dst: &mut [u8]) -> Result<(), c
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_user}; /// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_user};
/// # fn try_test() -> Result<(), c_long> { /// # fn try_test() -> Result<(), c_long> {
/// # let user_ptr: *const c_int = 0 as _; /// # let user_ptr: *const c_int = 0 as _;
@ -143,7 +143,7 @@ pub unsafe fn bpf_probe_read_user<T>(src: *const T) -> Result<T, c_long> {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_user_buf}; /// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_user_buf};
/// # fn try_test() -> Result<(), c_long> { /// # fn try_test() -> Result<(), c_long> {
/// # let user_ptr: *const u8 = 0 as _; /// # let user_ptr: *const u8 = 0 as _;
@ -179,7 +179,7 @@ pub unsafe fn bpf_probe_read_user_buf(src: *const u8, dst: &mut [u8]) -> Result<
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_kernel}; /// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_kernel};
/// # fn try_test() -> Result<(), c_long> { /// # fn try_test() -> Result<(), c_long> {
/// # let kernel_ptr: *const c_int = 0 as _; /// # let kernel_ptr: *const c_int = 0 as _;
@ -214,7 +214,7 @@ pub unsafe fn bpf_probe_read_kernel<T>(src: *const T) -> Result<T, c_long> {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_kernel_buf}; /// # use aya_ebpf::{cty::{c_int, c_long}, helpers::bpf_probe_read_kernel_buf};
/// # fn try_test() -> Result<(), c_long> { /// # fn try_test() -> Result<(), c_long> {
/// # let kernel_ptr: *const u8 = 0 as _; /// # let kernel_ptr: *const u8 = 0 as _;
@ -253,7 +253,7 @@ pub unsafe fn bpf_probe_read_kernel_buf(src: *const u8, dst: &mut [u8]) -> Resul
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_str}; /// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_str};
/// # fn try_test() -> Result<(), c_long> { /// # fn try_test() -> Result<(), c_long> {
/// # let kernel_ptr: *const u8 = 0 as _; /// # let kernel_ptr: *const u8 = 0 as _;
@ -291,7 +291,7 @@ pub unsafe fn bpf_probe_read_str(src: *const u8, dest: &mut [u8]) -> Result<usiz
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_user_str}; /// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_user_str};
/// # fn try_test() -> Result<(), c_long> { /// # fn try_test() -> Result<(), c_long> {
/// # let user_ptr: *const u8 = 0 as _; /// # let user_ptr: *const u8 = 0 as _;
@ -332,7 +332,7 @@ pub unsafe fn bpf_probe_read_user_str(src: *const u8, dest: &mut [u8]) -> Result
/// eBPF stack limit is 512 bytes): /// eBPF stack limit is 512 bytes):
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_user_str_bytes}; /// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_user_str_bytes};
/// # fn try_test() -> Result<(), c_long> { /// # fn try_test() -> Result<(), c_long> {
/// # let user_ptr: *const u8 = 0 as _; /// # let user_ptr: *const u8 = 0 as _;
@ -375,7 +375,7 @@ pub unsafe fn bpf_probe_read_user_str(src: *const u8, dest: &mut [u8]) -> Result
/// [core::str::from_utf8_unchecked]: /// [core::str::from_utf8_unchecked]:
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_user_str_bytes}; /// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_user_str_bytes};
/// # use aya_ebpf::{macros::map, maps::PerCpuArray}; /// # use aya_ebpf::{macros::map, maps::PerCpuArray};
/// # #[repr(C)] /// # #[repr(C)]
@ -441,7 +441,7 @@ fn read_str_bytes(len: i64, dest: &[u8]) -> Result<&[u8], c_long> {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_kernel_str}; /// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_kernel_str};
/// # fn try_test() -> Result<(), c_long> { /// # fn try_test() -> Result<(), c_long> {
/// # let kernel_ptr: *const u8 = 0 as _; /// # let kernel_ptr: *const u8 = 0 as _;
@ -482,7 +482,7 @@ pub unsafe fn bpf_probe_read_kernel_str(src: *const u8, dest: &mut [u8]) -> Resu
/// eBPF stack limit is 512 bytes): /// eBPF stack limit is 512 bytes):
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_kernel_str_bytes}; /// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_kernel_str_bytes};
/// # fn try_test() -> Result<(), c_long> { /// # fn try_test() -> Result<(), c_long> {
/// # let kernel_ptr: *const u8 = 0 as _; /// # let kernel_ptr: *const u8 = 0 as _;
@ -497,7 +497,7 @@ pub unsafe fn bpf_probe_read_kernel_str(src: *const u8, dest: &mut [u8]) -> Resu
/// With a `PerCpuArray` (with size defined by us): /// With a `PerCpuArray` (with size defined by us):
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_kernel_str_bytes}; /// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_kernel_str_bytes};
/// use aya_ebpf::{macros::map, maps::PerCpuArray}; /// use aya_ebpf::{macros::map, maps::PerCpuArray};
/// ///
@ -526,7 +526,7 @@ pub unsafe fn bpf_probe_read_kernel_str(src: *const u8, dest: &mut [u8]) -> Resu
/// [core::str::from_utf8_unchecked]: /// [core::str::from_utf8_unchecked]:
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_kernel_str_bytes}; /// # use aya_ebpf::{cty::c_long, helpers::bpf_probe_read_kernel_str_bytes};
/// # use aya_ebpf::{macros::map, maps::PerCpuArray}; /// # use aya_ebpf::{macros::map, maps::PerCpuArray};
/// # #[repr(C)] /// # #[repr(C)]
@ -572,7 +572,7 @@ pub unsafe fn bpf_probe_read_kernel_str_bytes(
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{ /// # use aya_ebpf::{
/// # cty::{c_int, c_long}, /// # cty::{c_int, c_long},
/// # helpers::bpf_probe_write_user, /// # helpers::bpf_probe_write_user,
@ -611,7 +611,7 @@ pub unsafe fn bpf_probe_write_user<T>(dst: *mut T, src: *const T) -> Result<(),
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::helpers::bpf_get_current_comm; /// # use aya_ebpf::helpers::bpf_get_current_comm;
/// let comm = bpf_get_current_comm(); /// let comm = bpf_get_current_comm();
/// ///
@ -648,7 +648,7 @@ pub fn bpf_get_current_comm() -> Result<[u8; 16], c_long> {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::helpers::bpf_get_current_pid_tgid; /// # use aya_ebpf::helpers::bpf_get_current_pid_tgid;
/// let tgid = (bpf_get_current_pid_tgid() >> 32) as u32; /// let tgid = (bpf_get_current_pid_tgid() >> 32) as u32;
/// let pid = bpf_get_current_pid_tgid() as u32; /// let pid = bpf_get_current_pid_tgid() as u32;
@ -671,7 +671,7 @@ pub fn bpf_get_current_pid_tgid() -> u64 {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::helpers::bpf_get_current_uid_gid; /// # use aya_ebpf::helpers::bpf_get_current_uid_gid;
/// let gid = (bpf_get_current_uid_gid() >> 32) as u32; /// let gid = (bpf_get_current_uid_gid() >> 32) as u32;
/// let uid = bpf_get_current_uid_gid() as u32; /// let uid = bpf_get_current_uid_gid() as u32;

@ -8,10 +8,10 @@
html_logo_url = "https://aya-rs.dev/assets/images/crabby.svg", html_logo_url = "https://aya-rs.dev/assets/images/crabby.svg",
html_favicon_url = "https://aya-rs.dev/assets/images/crabby.svg" html_favicon_url = "https://aya-rs.dev/assets/images/crabby.svg"
)] )]
#![cfg_attr(unstable, allow(incomplete_features), feature(generic_const_exprs))] #![cfg_attr(unstable, expect(incomplete_features), feature(generic_const_exprs))]
#![cfg_attr(unstable, feature(never_type))] #![cfg_attr(unstable, feature(never_type))]
#![cfg_attr(target_arch = "bpf", feature(asm_experimental_arch))] #![cfg_attr(target_arch = "bpf", feature(asm_experimental_arch))]
#![allow(clippy::missing_safety_doc)] #![expect(clippy::missing_safety_doc)]
#![deny(warnings)] #![deny(warnings)]
#![warn(clippy::cast_lossless, clippy::cast_sign_loss)] #![warn(clippy::cast_lossless, clippy::cast_sign_loss)]
#![no_std] #![no_std]
@ -63,7 +63,7 @@ pub trait EbpfContext {
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn memset(s: *mut u8, c: c_int, n: usize) { pub unsafe extern "C" fn memset(s: *mut u8, c: c_int, n: usize) {
#[allow(clippy::cast_sign_loss)] #[expect(clippy::cast_sign_loss)]
let b = c as u8; let b = c as u8;
for i in 0..n { for i in 0..n {
*s.add(i) = b; *s.add(i) = b;

@ -14,7 +14,7 @@ use crate::{
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// use aya_ebpf::{macros::map, maps::ProgramArray, cty::c_long}; /// use aya_ebpf::{macros::map, maps::ProgramArray, cty::c_long};
/// # use aya_ebpf::{programs::LsmContext}; /// # use aya_ebpf::{programs::LsmContext};
/// ///

@ -16,8 +16,8 @@ impl FEntryContext {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(non_camel_case_types)] /// # #![expect(non_camel_case_types)]
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::c_int, programs::FEntryContext}; /// # use aya_ebpf::{cty::c_int, programs::FEntryContext};
/// # type pid_t = c_int; /// # type pid_t = c_int;
/// # struct task_struct { /// # struct task_struct {

@ -16,8 +16,8 @@ impl FExitContext {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(non_camel_case_types)] /// # #![expect(non_camel_case_types)]
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{cty::c_int, programs::FExitContext}; /// # use aya_ebpf::{cty::c_int, programs::FExitContext};
/// # type pid_t = c_int; /// # type pid_t = c_int;
/// # struct task_struct { /// # struct task_struct {

@ -29,7 +29,7 @@ impl LsmContext {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{programs::LsmContext, cty::{c_int, c_ulong}}; /// # use aya_ebpf::{programs::LsmContext, cty::{c_int, c_ulong}};
/// unsafe fn try_lsm_mmap_addr(ctx: LsmContext) -> Result<i32, i32> { /// unsafe fn try_lsm_mmap_addr(ctx: LsmContext) -> Result<i32, i32> {
/// // In the kernel, this hook is defined as: /// // In the kernel, this hook is defined as:

@ -31,8 +31,8 @@ impl ProbeContext {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(non_camel_case_types)] /// # #![expect(non_camel_case_types)]
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{programs::ProbeContext, cty::c_int, helpers::bpf_probe_read}; /// # use aya_ebpf::{programs::ProbeContext, cty::c_int, helpers::bpf_probe_read};
/// # type pid_t = c_int; /// # type pid_t = c_int;
/// # struct task_struct { /// # struct task_struct {

@ -31,7 +31,7 @@ impl RetProbeContext {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{programs::RetProbeContext, cty::c_int}; /// # use aya_ebpf::{programs::RetProbeContext, cty::c_int};
/// unsafe fn try_kretprobe_try_to_wake_up(ctx: RetProbeContext) -> Result<u32, u32> { /// unsafe fn try_kretprobe_try_to_wake_up(ctx: RetProbeContext) -> Result<u32, u32> {
/// let retval: c_int = ctx.ret().ok_or(1u32)?; /// let retval: c_int = ctx.ret().ok_or(1u32)?;

@ -21,7 +21,7 @@ impl SkBuff {
SkBuff { skb } SkBuff { skb }
} }
#[allow(clippy::len_without_is_empty)] #[expect(clippy::len_without_is_empty)]
#[inline] #[inline]
pub fn len(&self) -> u32 { pub fn len(&self) -> u32 {
unsafe { (*self.skb).len } unsafe { (*self.skb).len }
@ -270,7 +270,7 @@ impl SkBuffContext {
SkBuffContext { skb } SkBuffContext { skb }
} }
#[allow(clippy::len_without_is_empty)] #[expect(clippy::len_without_is_empty)]
#[inline] #[inline]
pub fn len(&self) -> u32 { pub fn len(&self) -> u32 {
self.skb.len() self.skb.len()
@ -316,11 +316,11 @@ impl SkBuffContext {
/// use core::mem; /// use core::mem;
/// ///
/// use aya_ebpf::{bindings::TC_ACT_PIPE, macros::map, maps::PerCpuArray, programs::SkBuffContext}; /// use aya_ebpf::{bindings::TC_ACT_PIPE, macros::map, maps::PerCpuArray, programs::SkBuffContext};
/// # #[allow(non_camel_case_types)] /// # #[expect(non_camel_case_types)]
/// # struct ethhdr {}; /// # struct ethhdr {};
/// # #[allow(non_camel_case_types)] /// # #[expect(non_camel_case_types)]
/// # struct iphdr {}; /// # struct iphdr {};
/// # #[allow(non_camel_case_types)] /// # #[expect(non_camel_case_types)]
/// # struct tcphdr {}; /// # struct tcphdr {};
/// ///
/// const ETH_HDR_LEN: usize = mem::size_of::<ethhdr>(); /// const ETH_HDR_LEN: usize = mem::size_of::<ethhdr>();
@ -405,11 +405,11 @@ impl SkBuffContext {
/// ///
/// ```no_run /// ```no_run
/// use aya_ebpf::programs::SkBuffContext; /// use aya_ebpf::programs::SkBuffContext;
/// # #[allow(non_camel_case_types)] /// # #[expect(non_camel_case_types)]
/// # struct ethhdr {}; /// # struct ethhdr {};
/// # #[allow(non_camel_case_types)] /// # #[expect(non_camel_case_types)]
/// # struct iphdr {}; /// # struct iphdr {};
/// # #[allow(non_camel_case_types)] /// # #[expect(non_camel_case_types)]
/// # struct udphdr {}; /// # struct udphdr {};
/// ///
/// const ETH_HLEN: usize = core::mem::size_of::<ethhdr>(); /// const ETH_HLEN: usize = core::mem::size_of::<ethhdr>();

@ -12,7 +12,7 @@ impl TcContext {
TcContext { skb } TcContext { skb }
} }
#[allow(clippy::len_without_is_empty)] #[expect(clippy::len_without_is_empty)]
#[inline] #[inline]
pub fn len(&self) -> u32 { pub fn len(&self) -> u32 {
self.skb.len() self.skb.len()
@ -68,11 +68,11 @@ impl TcContext {
/// use core::mem; /// use core::mem;
/// ///
/// use aya_ebpf::{bindings::TC_ACT_PIPE, macros::map, maps::PerCpuArray, programs::TcContext}; /// use aya_ebpf::{bindings::TC_ACT_PIPE, macros::map, maps::PerCpuArray, programs::TcContext};
/// # #[allow(non_camel_case_types)] /// # #[expect(non_camel_case_types)]
/// # struct ethhdr {}; /// # struct ethhdr {};
/// # #[allow(non_camel_case_types)] /// # #[expect(non_camel_case_types)]
/// # struct iphdr {}; /// # struct iphdr {};
/// # #[allow(non_camel_case_types)] /// # #[expect(non_camel_case_types)]
/// # struct tcphdr {}; /// # struct tcphdr {};
/// ///
/// const ETH_HDR_LEN: usize = mem::size_of::<ethhdr>(); /// const ETH_HDR_LEN: usize = mem::size_of::<ethhdr>();
@ -162,11 +162,11 @@ impl TcContext {
/// ///
/// ```no_run /// ```no_run
/// use aya_ebpf::programs::TcContext; /// use aya_ebpf::programs::TcContext;
/// # #[allow(non_camel_case_types)] /// # #[expect(non_camel_case_types)]
/// # struct ethhdr {}; /// # struct ethhdr {};
/// # #[allow(non_camel_case_types)] /// # #[expect(non_camel_case_types)]
/// # struct iphdr {}; /// # struct iphdr {};
/// # #[allow(non_camel_case_types)] /// # #[expect(non_camel_case_types)]
/// # struct udphdr {}; /// # struct udphdr {};
/// ///
/// const ETH_HLEN: usize = core::mem::size_of::<ethhdr>(); /// const ETH_HLEN: usize = core::mem::size_of::<ethhdr>();

@ -23,7 +23,7 @@ impl BtfTracePointContext {
/// # Examples /// # Examples
/// ///
/// ```no_run /// ```no_run
/// # #![allow(dead_code)] /// # #![expect(dead_code)]
/// # use aya_ebpf::{programs::BtfTracePointContext, cty::{c_int, c_ulong, c_char}}; /// # use aya_ebpf::{programs::BtfTracePointContext, cty::{c_int, c_ulong, c_char}};
/// unsafe fn try_tp_btf_sched_process_fork(ctx: BtfTracePointContext) -> Result<u32, u32> { /// unsafe fn try_tp_btf_sched_process_fork(ctx: BtfTracePointContext) -> Result<u32, u32> {
/// // Grab arguments /// // Grab arguments

@ -141,7 +141,7 @@ fn run() -> anyhow::Result<()> {
.filter_map(|result| { .filter_map(|result| {
// TODO(https://github.com/rust-lang/rust-clippy/issues/14112): Remove this allowance // TODO(https://github.com/rust-lang/rust-clippy/issues/14112): Remove this allowance
// when the lint behaves more sensibly. // when the lint behaves more sensibly.
#[allow(clippy::manual_ok_err)] #[expect(clippy::manual_ok_err)]
match result { match result {
Ok(()) => None, Ok(()) => None,
Err(err) => Some(err), Err(err) => Some(err),

@ -80,7 +80,7 @@ pub fn public_api(options: Options, metadata: Metadata) -> Result<()> {
.filter_map(|result| { .filter_map(|result| {
// TODO(https://github.com/rust-lang/rust-clippy/issues/14112): Remove this allowance // TODO(https://github.com/rust-lang/rust-clippy/issues/14112): Remove this allowance
// when the lint behaves more sensibly. // when the lint behaves more sensibly.
#[allow(clippy::manual_ok_err)] #[expect(clippy::manual_ok_err)]
match result { match result {
Ok(()) => None, Ok(()) => None,
Err(err) => Some(err), Err(err) => Some(err),

@ -84,7 +84,7 @@ where
let stdout = BufReader::new(stdout); let stdout = BufReader::new(stdout);
let mut executables = Vec::new(); let mut executables = Vec::new();
for message in Message::parse_stream(stdout) { for message in Message::parse_stream(stdout) {
#[allow(clippy::collapsible_match)] #[expect(clippy::collapsible_match)]
match message.context("valid JSON")? { match message.context("valid JSON")? {
Message::CompilerArtifact(Artifact { Message::CompilerArtifact(Artifact {
executable, executable,

Loading…
Cancel
Save