Skip to content

Commit a4a41a6

Browse files
Danilo Krummrichojeda
Danilo Krummrich
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]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Gary Guo <[email protected]> Signed-off-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent e7ac5fa commit a4a41a6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

rust/kernel/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl Error {
161161
}
162162

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

0 commit comments

Comments
 (0)