Skip to content

Commit 20c0d42

Browse files
hoshinolinajannau
authored andcommitted
kernel/error: Make clippy::undocumented_unsafe_blocks happy
Signed-off-by: Asahi Lina <lina@asahilina.net>
1 parent 225e5a7 commit 20c0d42

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

rust/kernel/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ impl fmt::Debug for Error {
276276
match self.name() {
277277
// Print out number if no name can be found.
278278
None => f.debug_tuple("Error").field(&-self.0).finish(),
279-
// SAFETY: These strings are ASCII-only.
280279
Some(name) => f
280+
// SAFETY: These strings are ASCII-only.
281281
.debug_tuple(unsafe { core::str::from_utf8_unchecked(name) })
282282
.finish(),
283283
}
@@ -382,6 +382,7 @@ pub(crate) fn from_err_ptr<T>(ptr: *mut T) -> Result<*mut T> {
382382
if unsafe { bindings::IS_ERR(const_ptr) } {
383383
// SAFETY: The FFI function does not deref the pointer.
384384
let err = unsafe { bindings::PTR_ERR(const_ptr) };
385+
#[allow(clippy::unnecessary_cast)]
385386
// CAST: If `IS_ERR()` returns `true`,
386387
// then `PTR_ERR()` is guaranteed to return a
387388
// negative value greater-or-equal to `-bindings::MAX_ERRNO`,
@@ -391,7 +392,6 @@ pub(crate) fn from_err_ptr<T>(ptr: *mut T) -> Result<*mut T> {
391392
//
392393
// SAFETY: `IS_ERR()` ensures `err` is a
393394
// negative value greater-or-equal to `-bindings::MAX_ERRNO`.
394-
#[allow(clippy::unnecessary_cast)]
395395
return Err(unsafe { Error::from_errno_unchecked(err as core::ffi::c_int) });
396396
}
397397
Ok(ptr)

0 commit comments

Comments
 (0)