Skip to content

Commit fe6fae5

Browse files
committed
Use #[expect(...)] instead of #[allow(...)] in some places
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 <[email protected]>
1 parent 7c22ef4 commit fe6fae5

File tree

10 files changed

+34
-34
lines changed

10 files changed

+34
-34
lines changed

examples/capable/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ fn bump_memlock_rlimit() -> Result<()> {
124124
}
125125

126126
fn print_banner(extra_fields: bool) {
127-
#[allow(clippy::print_literal)]
127+
#[expect(clippy::print_literal)]
128128
if extra_fields {
129129
println!(
130130
"{:9} {:6} {:6} {:6} {:16} {:4} {:20} {:6} {}",

libbpf-rs/src/map.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ impl<'obj> OpenMapMut<'obj> {
179179
}
180180

181181
// TODO: Document member.
182-
#[allow(missing_docs)]
182+
#[expect(missing_docs)]
183183
pub fn set_numa_node(&mut self, numa_node: u32) -> Result<()> {
184184
let ret = unsafe { libbpf_sys::bpf_map__set_numa_node(self.ptr.as_ptr(), numa_node) };
185185
util::parse_ret(ret)
186186
}
187187

188188
// TODO: Document member.
189-
#[allow(missing_docs)]
189+
#[expect(missing_docs)]
190190
pub fn set_inner_map_fd(&mut self, inner_map_fd: BorrowedFd<'_>) -> Result<()> {
191191
let ret = unsafe {
192192
libbpf_sys::bpf_map__set_inner_map_fd(self.ptr.as_ptr(), inner_map_fd.as_raw_fd())
@@ -195,7 +195,7 @@ impl<'obj> OpenMapMut<'obj> {
195195
}
196196

197197
// TODO: Document member.
198-
#[allow(missing_docs)]
198+
#[expect(missing_docs)]
199199
pub fn set_map_extra(&mut self, map_extra: u64) -> Result<()> {
200200
let ret = unsafe { libbpf_sys::bpf_map__set_map_extra(self.ptr.as_ptr(), map_extra) };
201201
util::parse_ret(ret)
@@ -377,7 +377,7 @@ fn lookup_batch_raw<M>(
377377
where
378378
M: MapCore + ?Sized,
379379
{
380-
#[allow(clippy::needless_update)]
380+
#[expect(clippy::needless_update)]
381381
let opts = libbpf_sys::bpf_map_batch_opts {
382382
sz: mem::size_of::<libbpf_sys::bpf_map_batch_opts>() as _,
383383
elem_flags: elem_flags.bits(),
@@ -586,7 +586,7 @@ pub trait MapCore: Debug + AsFd + private::Sealed {
586586
)));
587587
};
588588

589-
#[allow(clippy::needless_update)]
589+
#[expect(clippy::needless_update)]
590590
let opts = libbpf_sys::bpf_map_batch_opts {
591591
sz: mem::size_of::<libbpf_sys::bpf_map_batch_opts>() as _,
592592
elem_flags: elem_flags.bits(),
@@ -702,7 +702,7 @@ pub trait MapCore: Debug + AsFd + private::Sealed {
702702
)));
703703
}
704704

705-
#[allow(clippy::needless_update)]
705+
#[expect(clippy::needless_update)]
706706
let opts = libbpf_sys::bpf_map_batch_opts {
707707
sz: mem::size_of::<libbpf_sys::bpf_map_batch_opts>() as _,
708708
elem_flags: elem_flags.bits(),
@@ -1204,7 +1204,7 @@ bitflags! {
12041204
#[repr(u32)]
12051205
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
12061206
// TODO: Document members.
1207-
#[allow(missing_docs)]
1207+
#[expect(missing_docs)]
12081208
pub enum MapType {
12091209
Unspec = libbpf_sys::BPF_MAP_TYPE_UNSPEC,
12101210
Hash = libbpf_sys::BPF_MAP_TYPE_HASH,

libbpf-rs/src/netfilter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl From<NetfilterOpts> for libbpf_sys::bpf_netfilter_opts {
5555
_non_exhaustive,
5656
} = opts;
5757

58-
#[allow(clippy::needless_update)]
58+
#[expect(clippy::needless_update)]
5959
libbpf_sys::bpf_netfilter_opts {
6060
sz: size_of::<Self>() as _,
6161
pf: protocol_family as u32,

libbpf-rs/src/perf_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ pub struct PerfBuffer<'b> {
202202
}
203203

204204
// TODO: Document methods.
205-
#[allow(missing_docs)]
205+
#[expect(missing_docs)]
206206
impl PerfBuffer<'_> {
207207
pub fn epoll_fd(&self) -> i32 {
208208
unsafe { libbpf_sys::perf_buffer__epoll_fd(self.ptr.as_ptr()) }

libbpf-rs/src/print.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub fn set_print(
123123
) -> Option<(PrintLevel, PrintCallback)> {
124124
// # Safety
125125
// outer_print_cb has the same function signature as libbpf_print_fn_t
126-
#[allow(clippy::missing_transmute_annotations)]
126+
#[expect(clippy::missing_transmute_annotations)]
127127
let real_cb: libbpf_sys::libbpf_print_fn_t =
128128
unsafe { Some(mem::transmute(outer_print_cb as *const ())) };
129129
let real_cb: libbpf_sys::libbpf_print_fn_t = callback.as_ref().and(real_cb);

libbpf-rs/src/program.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl From<UsdtOpts> for libbpf_sys::bpf_usdt_opts {
7272
cookie,
7373
_non_exhaustive,
7474
} = opts;
75-
#[allow(clippy::needless_update)]
75+
#[expect(clippy::needless_update)]
7676
libbpf_sys::bpf_usdt_opts {
7777
sz: size_of::<Self>() as _,
7878
usdt_cookie: cookie,
@@ -98,7 +98,7 @@ impl From<TracepointOpts> for libbpf_sys::bpf_tracepoint_opts {
9898
_non_exhaustive,
9999
} = opts;
100100

101-
#[allow(clippy::needless_update)]
101+
#[expect(clippy::needless_update)]
102102
libbpf_sys::bpf_tracepoint_opts {
103103
sz: size_of::<Self>() as _,
104104
bpf_cookie: cookie,
@@ -234,7 +234,7 @@ impl<'obj> OpenProgramMut<'obj> {
234234
debug_assert!(util::parse_ret(rc).is_ok(), "{rc}");
235235
}
236236

237-
#[allow(missing_docs)]
237+
#[expect(missing_docs)]
238238
pub fn set_attach_target(
239239
&mut self,
240240
attach_prog_fd: i32,
@@ -293,7 +293,7 @@ impl<T> AsRawLibbpf for OpenProgramImpl<'_, T> {
293293
#[repr(u32)]
294294
#[derive(Copy, Clone, Debug)]
295295
// TODO: Document variants.
296-
#[allow(missing_docs)]
296+
#[expect(missing_docs)]
297297
pub enum ProgramType {
298298
Unspec = 0,
299299
SocketFilter = libbpf_sys::BPF_PROG_TYPE_SOCKET_FILTER,
@@ -408,7 +408,7 @@ impl From<u32> for ProgramType {
408408
#[repr(u32)]
409409
#[derive(Clone, Debug)]
410410
// TODO: Document variants.
411-
#[allow(missing_docs)]
411+
#[expect(missing_docs)]
412412
pub enum ProgramAttachType {
413413
CgroupInetIngress = libbpf_sys::BPF_CGROUP_INET_INGRESS,
414414
CgroupInetEgress = libbpf_sys::BPF_CGROUP_INET_EGRESS,
@@ -606,7 +606,7 @@ impl<'obj> Program<'obj> {
606606
}
607607

608608
#[deprecated = "renamed to Program::fd_from_id"]
609-
#[allow(missing_docs)]
609+
#[expect(missing_docs)]
610610
#[inline]
611611
pub fn get_fd_by_id(id: u32) -> Result<OwnedFd> {
612612
Self::fd_from_id(id)
@@ -624,7 +624,7 @@ impl<'obj> Program<'obj> {
624624

625625
// TODO: Remove once 0.25 is cut.
626626
#[deprecated = "renamed to Program::id_from_fd"]
627-
#[allow(missing_docs)]
627+
#[expect(missing_docs)]
628628
#[inline]
629629
pub fn get_id_by_fd(fd: BorrowedFd<'_>) -> Result<u32> {
630630
Self::id_from_fd(fd)

libbpf-rs/src/query.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub struct Tag(pub [u8; 8]);
125125
/// Information about a BPF program
126126
#[derive(Debug, Clone)]
127127
// TODO: Document members.
128-
#[allow(missing_docs)]
128+
#[expect(missing_docs)]
129129
pub struct ProgramInfo {
130130
pub name: CString,
131131
pub ty: ProgramType,
@@ -439,7 +439,7 @@ impl Iterator for ProgInfoIter {
439439
/// Information about a BPF map
440440
#[derive(Debug, Clone)]
441441
// TODO: Document members.
442-
#[allow(missing_docs)]
442+
#[expect(missing_docs)]
443443
pub struct MapInfo {
444444
pub name: CString,
445445
pub ty: MapType,
@@ -588,37 +588,37 @@ impl Iterator for BtfInfoIter {
588588

589589
#[derive(Debug, Clone)]
590590
// TODO: Document members.
591-
#[allow(missing_docs)]
591+
#[expect(missing_docs)]
592592
pub struct RawTracepointLinkInfo {
593593
pub name: String,
594594
}
595595

596596
#[derive(Debug, Clone)]
597597
// TODO: Document members.
598-
#[allow(missing_docs)]
598+
#[expect(missing_docs)]
599599
pub struct TracingLinkInfo {
600600
pub attach_type: ProgramAttachType,
601601
}
602602

603603
#[derive(Debug, Clone)]
604604
// TODO: Document members.
605-
#[allow(missing_docs)]
605+
#[expect(missing_docs)]
606606
pub struct CgroupLinkInfo {
607607
pub cgroup_id: u64,
608608
pub attach_type: ProgramAttachType,
609609
}
610610

611611
#[derive(Debug, Clone)]
612612
// TODO: Document members.
613-
#[allow(missing_docs)]
613+
#[expect(missing_docs)]
614614
pub struct NetNsLinkInfo {
615615
pub ino: u32,
616616
pub attach_type: ProgramAttachType,
617617
}
618618

619619
#[derive(Debug, Clone)]
620620
// TODO: Document variants.
621-
#[allow(missing_docs)]
621+
#[expect(missing_docs)]
622622
pub enum LinkTypeInfo {
623623
RawTracepoint(RawTracepointLinkInfo),
624624
Tracing(TracingLinkInfo),
@@ -631,7 +631,7 @@ pub enum LinkTypeInfo {
631631
/// Information about a BPF link
632632
#[derive(Debug, Clone)]
633633
// TODO: Document members.
634-
#[allow(missing_docs)]
634+
#[expect(missing_docs)]
635635
pub struct LinkInfo {
636636
pub info: LinkTypeInfo,
637637
pub id: u32,

libbpf-rs/src/ringbuf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl<'slf, 'cb: 'slf> RingBufferBuilder<'slf, 'cb> {
159159
#[derive(Debug)]
160160
pub struct RingBuffer<'cb> {
161161
ptr: NonNull<libbpf_sys::ring_buffer>,
162-
#[allow(clippy::vec_box)]
162+
#[expect(clippy::vec_box)]
163163
_cbs: Vec<Box<RingBufferCallback<'cb>>>,
164164
}
165165

libbpf-rs/src/skeleton.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ struct ProgSkelConfig {
4242
link: Box<*mut bpf_link>,
4343
}
4444

45-
#[allow(missing_docs)]
45+
#[expect(missing_docs)]
4646
#[derive(Debug)]
4747
pub struct ObjectSkeletonConfigBuilder<'dat> {
4848
data: &'dat [u8],
@@ -77,7 +77,7 @@ impl<'dat> ObjectSkeletonConfigBuilder<'dat> {
7777
}
7878
}
7979

80-
#[allow(missing_docs)]
80+
#[expect(missing_docs)]
8181
pub fn name<T: AsRef<str>>(&mut self, name: T) -> &mut Self {
8282
self.name = Some(name.as_ref().to_string());
8383
self
@@ -180,7 +180,7 @@ impl<'dat> ObjectSkeletonConfigBuilder<'dat> {
180180
Some(layout)
181181
}
182182

183-
#[allow(missing_docs)]
183+
#[expect(missing_docs)]
184184
pub fn build(mut self) -> Result<ObjectSkeletonConfig<'dat>> {
185185
// Holds `CString`s alive so pointers to them stay valid
186186
let mut string_pool = Vec::new();

libbpf-rs/src/tc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ pub type TcFlags = libbpf_sys::bpf_tc_flags;
2020
pub const BPF_TC_F_REPLACE: TcFlags = libbpf_sys::BPF_TC_F_REPLACE;
2121

2222
// from kernel @ include/uapi/linux/pkt_sched.h
23-
#[allow(missing_docs)]
23+
#[expect(missing_docs)]
2424
pub const TC_H_INGRESS: u32 = 0xFFFFFFF1;
25-
#[allow(missing_docs)]
25+
#[expect(missing_docs)]
2626
pub const TC_H_CLSACT: u32 = TC_H_INGRESS;
27-
#[allow(missing_docs)]
27+
#[expect(missing_docs)]
2828
pub const TC_H_MIN_INGRESS: u32 = 0xFFF2;
29-
#[allow(missing_docs)]
29+
#[expect(missing_docs)]
3030
pub const TC_H_MIN_EGRESS: u32 = 0xFFF3;
3131
#[allow(missing_docs)]
3232
pub const TC_H_MAJ_MASK: u32 = 0xFFFF0000;

0 commit comments

Comments
 (0)