Skip to content

Commit 9e7aea5

Browse files
committed
libbpf-rs: minor fixes suggested by linter
clippy compalined here: https://github.com/libbpf/libbpf-rs/actions/runs/14391135733/job/40358223316 Signed-off-by: Ihor Solodrai <[email protected]>
1 parent f54cd6b commit 9e7aea5

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

libbpf-rs/src/btf/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ impl<'btf> BtfType<'btf> {
630630
let int = types::Int::try_from(skipped).unwrap();
631631
Ok(Ord::min(
632632
ptr_size,
633-
NonZeroUsize::new(((int.bits + 7) / 8).into()).unwrap(),
633+
NonZeroUsize::new(usize::from(int.bits.div_ceil(8))).unwrap(),
634634
))
635635
}
636636
BtfKind::Ptr => skipped.source.ptr_size(),

libbpf-rs/src/query.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -448,14 +448,8 @@ impl Iterator for ProgInfoIter {
448448

449449
fn next(&mut self) -> Option<Self::Item> {
450450
let fd = self.next_valid_fd()?;
451-
452451
let prog = ProgramInfo::load_from_fd(fd.as_fd(), &self.opts);
453-
454-
match prog {
455-
Ok(p) => Some(p),
456-
// TODO: We should consider bubbling up errors properly.
457-
Err(_err) => None,
458-
}
452+
prog.ok()
459453
}
460454
}
461455

@@ -612,14 +606,8 @@ impl Iterator for BtfInfoIter {
612606

613607
fn next(&mut self) -> Option<Self::Item> {
614608
let fd = self.next_valid_fd()?;
615-
616609
let info = BtfInfo::load_from_fd(fd.as_fd());
617-
618-
match info {
619-
Ok(i) => Some(i),
620-
// TODO: We should consider bubbling up errors properly.
621-
Err(_err) => None,
622-
}
610+
info.ok()
623611
}
624612
}
625613

0 commit comments

Comments
 (0)