Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: kernel: mark as `#[inline]` all `From::from()`s for `Error`

There was a recent request [1] to mark as `#[inline]` the simple
`From::from()` functions implemented for `Error`.

Thus mark all of the existing

impl From<...> for Error {
fn from(err: ...) -> Self {
...
}
}

functions in the `kernel` crate as `#[inline]`.

Suggested-by: Gary Guo <gary@garyguo.net>
Link: https://lore.kernel.org/all/8403c8b7a832b5274743816eb77abfa4@garyguo.net/ [1]
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Acked-by: Andreas Hindborg <a.hindborg@kernel.org>
Link: https://patch.msgid.link/20260326020406.1438210-1-alistair.francis@wdc.com
[ Dropped `projection.rs` since it is in another tree and already marked
as `inline(always)` and reworded accordingly. Changed Link tag to
Gary's original message and added Suggested-by. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

authored by

Alistair Francis and committed by
Miguel Ojeda
4f13c934 d58f0f14

+10
+3
rust/kernel/alloc/kvec/errors.rs
··· 15 15 } 16 16 17 17 impl<T> From<PushError<T>> for Error { 18 + #[inline] 18 19 fn from(_: PushError<T>) -> Error { 19 20 // Returning ENOMEM isn't appropriate because the system is not out of memory. The vector 20 21 // is just full and we are refusing to resize it. ··· 33 32 } 34 33 35 34 impl From<RemoveError> for Error { 35 + #[inline] 36 36 fn from(_: RemoveError) -> Error { 37 37 EINVAL 38 38 } ··· 57 55 } 58 56 59 57 impl<T> From<InsertError<T>> for Error { 58 + #[inline] 60 59 fn from(_: InsertError<T>) -> Error { 61 60 EINVAL 62 61 }
+6
rust/kernel/error.rs
··· 216 216 } 217 217 218 218 impl From<AllocError> for Error { 219 + #[inline] 219 220 fn from(_: AllocError) -> Error { 220 221 code::ENOMEM 221 222 } 222 223 } 223 224 224 225 impl From<TryFromIntError> for Error { 226 + #[inline] 225 227 fn from(_: TryFromIntError) -> Error { 226 228 code::EINVAL 227 229 } 228 230 } 229 231 230 232 impl From<Utf8Error> for Error { 233 + #[inline] 231 234 fn from(_: Utf8Error) -> Error { 232 235 code::EINVAL 233 236 } 234 237 } 235 238 236 239 impl From<LayoutError> for Error { 240 + #[inline] 237 241 fn from(_: LayoutError) -> Error { 238 242 code::ENOMEM 239 243 } 240 244 } 241 245 242 246 impl From<fmt::Error> for Error { 247 + #[inline] 243 248 fn from(_: fmt::Error) -> Error { 244 249 code::EINVAL 245 250 } 246 251 } 247 252 248 253 impl From<core::convert::Infallible> for Error { 254 + #[inline] 249 255 fn from(e: core::convert::Infallible) -> Error { 250 256 match e {} 251 257 }
+1
rust/kernel/xarray.rs
··· 172 172 } 173 173 174 174 impl<T> From<StoreError<T>> for Error { 175 + #[inline] 175 176 fn from(value: StoreError<T>) -> Self { 176 177 value.error 177 178 }