Skip to content

Commit 3056dec

Browse files
authored
Don't silently ignore errors in the manual auxv code. (#947)
When we have `default-features = false` and we don't have either "use-explicitly-provided-auxv" or "use-libc-auxv", we fall back t using src/backend/linux_raw/param/auxv.rs Add `#[must_use]` to several functions.
1 parent 2e4f70e commit 3056dec

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/backend/linux_raw/fs/dir.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,7 @@ impl Dir {
175175
}))
176176
}
177177

178+
#[must_use]
178179
fn read_more(&mut self) -> Option<io::Result<()>> {
179180
// The first few times we're called, we allocate a relatively small
180181
// buffer, because many directories are small. If we're called more,

src/backend/linux_raw/param/auxv.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ fn init_auxv() {
222222
Ok(buffer) => {
223223
// SAFETY: We assume the kernel returns a valid auxv.
224224
unsafe {
225-
init_from_aux_iter(AuxPointer(buffer.as_ptr().cast()));
225+
init_from_aux_iter(AuxPointer(buffer.as_ptr().cast())).unwrap();
226226
}
227227
return;
228228
}
@@ -250,6 +250,7 @@ fn init_auxv() {
250250
/// Process auxv entries from the open file `auxv`.
251251
#[cfg(feature = "alloc")]
252252
#[cold]
253+
#[must_use]
253254
fn init_from_auxv_file(auxv: OwnedFd) -> Option<()> {
254255
let mut buffer = Vec::<u8>::with_capacity(512);
255256
loop {
@@ -286,6 +287,7 @@ fn init_from_auxv_file(auxv: OwnedFd) -> Option<()> {
286287
/// The buffer contains `Elf_aux_t` elements, though it need not be aligned;
287288
/// function uses `read_unaligned` to read from it.
288289
#[cold]
290+
#[must_use]
289291
unsafe fn init_from_aux_iter(aux_iter: impl Iterator<Item = Elf_auxv_t>) -> Option<()> {
290292
let mut pagesz = 0;
291293
let mut clktck = 0;
@@ -396,6 +398,7 @@ unsafe fn init_from_aux_iter(aux_iter: impl Iterator<Item = Elf_auxv_t>) -> Opti
396398
/// which hopefully holds the value of the kernel-provided vDSO in memory. Do a
397399
/// series of checks to be as sure as we can that it's safe to use.
398400
#[cold]
401+
#[must_use]
399402
unsafe fn check_elf_base(base: *const Elf_Ehdr) -> Option<NonNull<Elf_Ehdr>> {
400403
// If we're reading a 64-bit auxv on a 32-bit platform, we'll see a zero
401404
// `a_val` because `AT_*` values are never greater than `u32::MAX`. Zero is

0 commit comments

Comments
 (0)