History

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.

Danilo Krummrich committed 2 years ago

Commit 4a28ab41 parent 29a48d21 file · +2 −2Browse files

Showing the changes to rust/kernel (1 of 1 file). Show all

Unified · Split

rust/kernel/error.rs+2−2
@@ -161,7 +161,7 @@ impl Error { · 160 unmodified lines
161 }161 }
162 162
163 /// Returns a string representing the error, if one exists.163 /// Returns a string representing the error, if one exists.
164 #[cfg(not(testlib))]164 #[cfg(not(any(test, testlib)))]
165 pub fn name(&self) -> Option<&'static CStr> {165 pub fn name(&self) -> Option<&'static CStr> {
166 // SAFETY: Just an FFI call, there are no extra safety requirements.166 // SAFETY: Just an FFI call, there are no extra safety requirements.
167 let ptr = unsafe { bindings::errname(-self.0.get()) };167 let ptr = unsafe { bindings::errname(-self.0.get()) };
@@ -178,7 +178,7 @@ impl Error { · 10 unmodified lines
178 /// When `testlib` is configured, this always returns `None` to avoid the dependency on a178 /// When `testlib` is configured, this always returns `None` to avoid the dependency on a
179 /// kernel function so that tests that use this (e.g., by calling [`Result::unwrap`]) can still179 /// kernel function so that tests that use this (e.g., by calling [`Result::unwrap`]) can still
180 /// run in userspace.180 /// run in userspace.
181 #[cfg(testlib)]181 #[cfg(any(test, testlib))]
182 pub fn name(&self) -> Option<&'static CStr> {182 pub fn name(&self) -> Option<&'static CStr> {
183 None183 None
184 }184 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t