lkml.org 
[lkml]   [2026]   [Feb]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC v3 07/27] rust: error: impl From<FromBytesWithNulError> for Kernel Error
Date
From: Alistair Francis <alistair.francis@wdc.com>

Implement From<FromBytesWithNulError> for the Kernel Error type

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
rust/kernel/error.rs | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
index 258b12afdcba..569d9d032ab3 100644
--- a/rust/kernel/error.rs
+++ b/rust/kernel/error.rs
@@ -12,6 +12,7 @@
str::CStr,
};

+use core::ffi::FromBytesWithNulError;
use core::num::NonZeroI32;
use core::num::TryFromIntError;
use core::str::Utf8Error;
@@ -251,6 +252,12 @@ fn from(e: core::convert::Infallible) -> Error {
}
}

+impl From<FromBytesWithNulError> for Error {
+ fn from(_: FromBytesWithNulError) -> Error {
+ code::EINVAL
+ }
+}
+
/// A [`Result`] with an [`Error`] error type.
///
/// To be used as the return type for functions that may fail.
--
2.52.0

\
 
 \ /
  Last update: 2026-02-11 04:34    [from the cache]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and my Meterkast|Read the blog