Skip to content

Commit 0d11dac

Browse files
committed
WIP: debug
1 parent da4a2d6 commit 0d11dac

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

library/std_detect/src/detect/os/linux/auxvec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub(crate) fn auxv() -> Result<AuxVec, ()> {
118118
{
119119
// If calling getauxval fails, try to read the auxiliary vector from
120120
// its file:
121-
auxv_from_file("/proc/self/auxv")
121+
auxv_from_file("/proc/self/auxv").map_err(|_| ())
122122
}
123123
#[cfg(not(feature = "std_detect_file_io"))]
124124
{
@@ -220,7 +220,7 @@ fn auxv_from_buf(buf: &[usize]) -> Result<AuxVec, ()> {
220220
}
221221
// Suppress unused variable
222222
let _ = buf;
223-
Err(())
223+
Err(format!("hwcap not found"))
224224
}
225225

226226
#[cfg(test)]

library/std_detect/src/detect/os/linux/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
11
//! Run-time feature detection on Linux
22
//!
33
#[cfg(feature = "std_detect_file_io")]
4+
use alloc::format;
5+
#[cfg(feature = "std_detect_file_io")]
6+
use alloc::string::String;
7+
#[cfg(feature = "std_detect_file_io")]
48
use alloc::vec::Vec;
59

610
mod auxvec;
711

812
#[cfg(feature = "std_detect_file_io")]
9-
fn read_file(path: &str) -> Result<Vec<u8>, ()> {
10-
let mut path = Vec::from(path.as_bytes());
13+
fn read_file(orig_path: &str) -> Result<Vec<u8>, String> {
14+
let mut path = Vec::from(orig_path.as_bytes());
1115
path.push(0);
1216

1317
unsafe {
1418
let file = libc::open(path.as_ptr() as *const libc::c_char, libc::O_RDONLY);
1519
if file == -1 {
16-
return Err(());
20+
return Err(format!("Cannot open file at {orig_path}"));
1721
}
1822

1923
let mut data = Vec::new();
@@ -23,7 +27,7 @@ fn read_file(path: &str) -> Result<Vec<u8>, ()> {
2327
match libc::read(file, spare.as_mut_ptr() as *mut _, spare.len()) {
2428
-1 => {
2529
libc::close(file);
26-
return Err(());
30+
return Err(format!("Error while reading from file at {orig_path}"));
2731
}
2832
0 => break,
2933
n => data.set_len(data.len() + n as usize),

0 commit comments

Comments
 (0)