Skip to content

Commit f04f9d7

Browse files
Danilo Krummrichfbq
authored andcommitted
rust: error: check for config test in Error::name
Additional to `testlib` also check for `test` in `Error::name`. This is required by a subsequent patch that (indirectly) uses `Error` in test cases. Reviewed-by: Alice Ryhl <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 56a0c3c commit f04f9d7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rust/kernel/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl Error {
143143
}
144144

145145
/// Returns a string representing the error, if one exists.
146-
#[cfg(not(testlib))]
146+
#[cfg(not(any(test, testlib)))]
147147
pub fn name(&self) -> Option<&'static CStr> {
148148
// SAFETY: Just an FFI call, there are no extra safety requirements.
149149
let ptr = unsafe { bindings::errname(-self.0) };
@@ -160,7 +160,7 @@ impl Error {
160160
/// When `testlib` is configured, this always returns `None` to avoid the dependency on a
161161
/// kernel function so that tests that use this (e.g., by calling [`Result::unwrap`]) can still
162162
/// run in userspace.
163-
#[cfg(testlib)]
163+
#[cfg(any(test, testlib))]
164164
pub fn name(&self) -> Option<&'static CStr> {
165165
None
166166
}

0 commit comments

Comments
 (0)