From 6f9b34883c95c762dd68269dba28b9fcad3e27a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20M=C3=BCller?= Date: Tue, 21 Jan 2025 09:39:26 -0800 Subject: [PATCH] Use #[expect(...)] instead of #[allow(...)] in some places MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use the #[expect(...)] attribute instead of #[allow(...)] in a bunch of places where we only have the attribute to silence a lint. The former makes sure that the silenced issue is actually flagged, or prints a warning otherwise. Signed-off-by: Daniel Müller --- examples/capable/src/main.rs | 2 +- libbpf-rs/src/perf_buffer.rs | 2 +- libbpf-rs/src/print.rs | 2 +- libbpf-rs/src/program.rs | 10 +++++----- libbpf-rs/src/ringbuf.rs | 2 +- libbpf-rs/src/skeleton.rs | 6 +++--- libbpf-rs/src/tc.rs | 8 ++++---- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/examples/capable/src/main.rs b/examples/capable/src/main.rs index 99688c9f..eb12fbc2 100644 --- a/examples/capable/src/main.rs +++ b/examples/capable/src/main.rs @@ -113,7 +113,7 @@ struct Command { unsafe impl Plain for capable::types::event {} fn print_banner(extra_fields: bool) { - #[allow(clippy::print_literal)] + #[expect(clippy::print_literal)] if extra_fields { println!( "{:9} {:6} {:6} {:6} {:16} {:4} {:20} {:6} {}", diff --git a/libbpf-rs/src/perf_buffer.rs b/libbpf-rs/src/perf_buffer.rs index 1935d85d..4e5900b6 100644 --- a/libbpf-rs/src/perf_buffer.rs +++ b/libbpf-rs/src/perf_buffer.rs @@ -202,7 +202,7 @@ pub struct PerfBuffer<'b> { } // TODO: Document methods. -#[allow(missing_docs)] +#[expect(missing_docs)] impl PerfBuffer<'_> { pub fn epoll_fd(&self) -> i32 { unsafe { libbpf_sys::perf_buffer__epoll_fd(self.ptr.as_ptr()) } diff --git a/libbpf-rs/src/print.rs b/libbpf-rs/src/print.rs index bc568665..8187d600 100644 --- a/libbpf-rs/src/print.rs +++ b/libbpf-rs/src/print.rs @@ -123,7 +123,7 @@ pub fn set_print( ) -> Option<(PrintLevel, PrintCallback)> { // # Safety // outer_print_cb has the same function signature as libbpf_print_fn_t - #[allow(clippy::missing_transmute_annotations)] + #[expect(clippy::missing_transmute_annotations)] let real_cb: libbpf_sys::libbpf_print_fn_t = unsafe { Some(mem::transmute(outer_print_cb as *const ())) }; let real_cb: libbpf_sys::libbpf_print_fn_t = callback.as_ref().and(real_cb); diff --git a/libbpf-rs/src/program.rs b/libbpf-rs/src/program.rs index fdee7cd3..092b989a 100644 --- a/libbpf-rs/src/program.rs +++ b/libbpf-rs/src/program.rs @@ -290,7 +290,7 @@ impl<'obj> OpenProgramMut<'obj> { unsafe { libbpf_sys::bpf_program__set_autoattach(self.ptr.as_ptr(), autoattach) }; } - #[allow(missing_docs)] + #[expect(missing_docs)] pub fn set_attach_target( &mut self, attach_prog_fd: i32, @@ -339,7 +339,7 @@ impl AsRawLibbpf for OpenProgramImpl<'_, T> { #[repr(u32)] #[derive(Copy, Clone, Debug)] // TODO: Document variants. -#[allow(missing_docs)] +#[expect(missing_docs)] pub enum ProgramType { Unspec = 0, SocketFilter = libbpf_sys::BPF_PROG_TYPE_SOCKET_FILTER, @@ -454,7 +454,7 @@ impl From for ProgramType { #[repr(u32)] #[derive(Clone, Debug)] // TODO: Document variants. -#[allow(missing_docs)] +#[expect(missing_docs)] pub enum ProgramAttachType { CgroupInetIngress = libbpf_sys::BPF_CGROUP_INET_INGRESS, CgroupInetEgress = libbpf_sys::BPF_CGROUP_INET_EGRESS, @@ -687,7 +687,7 @@ impl<'obj> Program<'obj> { } #[deprecated = "renamed to Program::fd_from_id"] - #[allow(missing_docs)] + #[expect(missing_docs)] #[inline] pub fn get_fd_by_id(id: u32) -> Result { Self::fd_from_id(id) @@ -705,7 +705,7 @@ impl<'obj> Program<'obj> { // TODO: Remove once 0.25 is cut. #[deprecated = "renamed to Program::id_from_fd"] - #[allow(missing_docs)] + #[expect(missing_docs)] #[inline] pub fn get_id_by_fd(fd: BorrowedFd<'_>) -> Result { Self::id_from_fd(fd) diff --git a/libbpf-rs/src/ringbuf.rs b/libbpf-rs/src/ringbuf.rs index b6ae61f1..6c026693 100644 --- a/libbpf-rs/src/ringbuf.rs +++ b/libbpf-rs/src/ringbuf.rs @@ -160,7 +160,7 @@ impl<'slf, 'cb: 'slf> RingBufferBuilder<'slf, 'cb> { #[derive(Debug)] pub struct RingBuffer<'cb> { ptr: NonNull, - #[allow(clippy::vec_box)] + #[expect(clippy::vec_box)] _cbs: Vec>>, } diff --git a/libbpf-rs/src/skeleton.rs b/libbpf-rs/src/skeleton.rs index db289c5a..1640ba8c 100644 --- a/libbpf-rs/src/skeleton.rs +++ b/libbpf-rs/src/skeleton.rs @@ -42,7 +42,7 @@ struct ProgSkelConfig { link: Box<*mut bpf_link>, } -#[allow(missing_docs)] +#[expect(missing_docs)] #[derive(Debug)] pub struct ObjectSkeletonConfigBuilder<'dat> { data: &'dat [u8], @@ -77,7 +77,7 @@ impl<'dat> ObjectSkeletonConfigBuilder<'dat> { } } - #[allow(missing_docs)] + #[expect(missing_docs)] pub fn name>(&mut self, name: T) -> &mut Self { self.name = Some(name.as_ref().to_string()); self @@ -180,7 +180,7 @@ impl<'dat> ObjectSkeletonConfigBuilder<'dat> { Some(layout) } - #[allow(missing_docs)] + #[expect(missing_docs)] pub fn build(mut self) -> Result> { // Holds `CString`s alive so pointers to them stay valid let mut string_pool = Vec::new(); diff --git a/libbpf-rs/src/tc.rs b/libbpf-rs/src/tc.rs index 980ce7da..d9d293ff 100644 --- a/libbpf-rs/src/tc.rs +++ b/libbpf-rs/src/tc.rs @@ -20,13 +20,13 @@ pub type TcFlags = libbpf_sys::bpf_tc_flags; pub const BPF_TC_F_REPLACE: TcFlags = libbpf_sys::BPF_TC_F_REPLACE; // from kernel @ include/uapi/linux/pkt_sched.h -#[allow(missing_docs)] +#[expect(missing_docs)] pub const TC_H_INGRESS: u32 = 0xFFFFFFF1; -#[allow(missing_docs)] +#[expect(missing_docs)] pub const TC_H_CLSACT: u32 = TC_H_INGRESS; -#[allow(missing_docs)] +#[expect(missing_docs)] pub const TC_H_MIN_INGRESS: u32 = 0xFFF2; -#[allow(missing_docs)] +#[expect(missing_docs)] pub const TC_H_MIN_EGRESS: u32 = 0xFFF3; #[allow(missing_docs)] pub const TC_H_MAJ_MASK: u32 = 0xFFFF0000;