File tree 2 files changed +10
-4
lines changed
2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change 7
7
#include <linux/gfp.h>
8
8
#include <linux/highmem.h>
9
9
#include <linux/uio.h>
10
+ #include <linux/errname.h>
10
11
11
12
void rust_helper_BUG (void )
12
13
{
@@ -117,6 +118,11 @@ long rust_helper_ptr_err(__force const void *ptr)
117
118
}
118
119
EXPORT_SYMBOL_GPL (rust_helper_ptr_err );
119
120
121
+ const char * rust_helper_errname (int err )
122
+ {
123
+ return errname (err );
124
+ }
125
+
120
126
/* We use bindgen's --size_t-is-usize option to bind the C size_t type
121
127
* as the Rust usize type, so we can use it in contexts where Rust
122
128
* expects a usize like slice (array) indices. usize is defined to be
Original file line number Diff line number Diff line change @@ -98,11 +98,11 @@ impl Error {
98
98
99
99
impl fmt:: Debug for Error {
100
100
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
101
+ extern "C" {
102
+ fn rust_helper_errname ( err : c_types:: c_int ) -> * const c_types:: c_char ;
103
+ }
101
104
// SAFETY: FFI call.
102
- #[ cfg( CONFIG_SYMBOLIC_ERRNAME ) ]
103
- let name = unsafe { crate :: bindings:: errname ( -self . 0 ) } ;
104
- #[ cfg( not( CONFIG_SYMBOLIC_ERRNAME ) ) ]
105
- let name: * const c_types:: c_char = core:: ptr:: null ( ) ;
105
+ let name = unsafe { rust_helper_errname ( -self . 0 ) } ;
106
106
107
107
if name. is_null ( ) {
108
108
// Print out number if no name can be found.
You can’t perform that action at this time.
0 commit comments