rust: error: use pr_warn_once! in from_errno
PATCH 1/1 rust: error: use pr_warn_once! in from_errno
Replace crate::pr_warn! with crate::pr_warn_once! in Error::from_errno to prevent logging noise if an invalid errno is repeatedly passed. This resolves a pending TODO in the file.
--- rust/kernel/error.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
rust/kernel/error.rs +1 -2
@@ -123,8 +123,7 @@ pub fn from_errno(errno: crate::ffi::c_int) -> Error {if let Some (error) =Self ::try_from_errno (errno) { error }else { -// TODO: Make it a `WARN_ONCE` once available. -crate ::pr_warn!( +crate ::pr_warn_once!("attempted to create `Error` with out of range `errno`: {}\n" , errno );
Signature · 1 line
2.55.0
Quoted 14 lines · On Sat, 11 Jul 2026 23:09:19 +0200 alessioMaroni0 <[email protected]>…
Replace
crate::pr_warn! withcrate::pr_warn_once! inError::from_errnoto prevent logging noise if an invalid errno is repeatedly passed. This resolves a pending TODO in the file.Signed-off-by alessioMaroni0 <[email protected]>--- rust/kernel/error.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)rust/kernel/error.rs +0
-0
rust/kernel/error.rs pub fn from_errno(errno: crate::ffi::c_int) -> Error { · line 128
Quoted 8 lines
rust/kernel/error.rs +1
-2@@ -123,8 +123,7 @@ pub fn from_errno(errno: crate::ffi::c_int) -> Error {if let Some (error) =Self ::try_from_errno (errno) { error }else { -// TODO: Make it a `WARN_ONCE` once available. -crate ::pr_warn!( +crate ::pr_warn_once!("attempted to create `Error` with out of range `errno`: {}\n" , errno
WARN_ONCE and pr_warn_once are not the same thing.
WARN_ONCE prints a full stack trace and register dump.
pr_warn_once is just sorta of printk.
I'll add warn_once macro after the patch to add bug macro [1] is merged.
[1] https://lore.kernel.org/rust-for-linux/[email protected]/
Quoted 6 lines · On Sat, Jul 11, 2026 at 11:09 PM alessioMaroni0 <[email protected]>…
Replace
crate::pr_warn! withcrate::pr_warn_once! inError::from_errnoto prevent logging noise if an invalid errno is repeatedly passed. This resolves a pending TODO in the file.Signed-off-by alessioMaroni0 <[email protected]>
Thanks for the patch!
There were already others:
https://lore.kernel.org/rust-for-linux/[email protected]/
https://lore.kernel.org/rust-for-linux/[email protected]/
Also, is the Signed-off-by name a "known identity"?
Cheers,
Miguel