File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
library/std_detect/src/detect/os/linux Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ pub(crate) fn auxv() -> Result<AuxVec, ()> {
118
118
{
119
119
// If calling getauxval fails, try to read the auxiliary vector from
120
120
// its file:
121
- auxv_from_file ( "/proc/self/auxv" )
121
+ auxv_from_file ( "/proc/self/auxv" ) . map_err ( |_| ( ) )
122
122
}
123
123
#[ cfg( not( feature = "std_detect_file_io" ) ) ]
124
124
{
@@ -220,7 +220,7 @@ fn auxv_from_buf(buf: &[usize]) -> Result<AuxVec, ()> {
220
220
}
221
221
// Suppress unused variable
222
222
let _ = buf;
223
- Err ( ( ) )
223
+ Err ( format ! ( "hwcap not found" ) )
224
224
}
225
225
226
226
#[ cfg( test) ]
Original file line number Diff line number Diff line change 1
1
//! Run-time feature detection on Linux
2
2
//!
3
3
#[ 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" ) ]
4
8
use alloc:: vec:: Vec ;
5
9
6
10
mod auxvec;
7
11
8
12
#[ 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 ( ) ) ;
11
15
path. push ( 0 ) ;
12
16
13
17
unsafe {
14
18
let file = libc:: open ( path. as_ptr ( ) as * const libc:: c_char , libc:: O_RDONLY ) ;
15
19
if file == -1 {
16
- return Err ( ( ) ) ;
20
+ return Err ( format ! ( "Cannot open file at {orig_path}" ) ) ;
17
21
}
18
22
19
23
let mut data = Vec :: new ( ) ;
@@ -23,7 +27,7 @@ fn read_file(path: &str) -> Result<Vec<u8>, ()> {
23
27
match libc:: read ( file, spare. as_mut_ptr ( ) as * mut _ , spare. len ( ) ) {
24
28
-1 => {
25
29
libc:: close ( file) ;
26
- return Err ( ( ) ) ;
30
+ return Err ( format ! ( "Error while reading from file at {orig_path}" ) ) ;
27
31
}
28
32
0 => break ,
29
33
n => data. set_len ( data. len ( ) + n as usize ) ,
You can’t perform that action at this time.
0 commit comments