Skip to contentSkip to conversation

rust: kernel: module_param: replace pr_warn with pr_warn_once

PATCH In review Xiaobo Liu 2 participants 2 messages May 18

Subsystems (2)
lore
Share & tools
lore

Xiaobo Liu

author
#0 lore raw

PATCH 1/1 rust: kernel: module_param: replace pr_warn with pr_warn_once

Replace pr_warn!() with pr_warn_once!() in module_param::set_param() to avoid flooding the kernel log when a null pointer is repeatedly passed.

The original code had a TODO comment noting that pr_warn_once should be used once available. Since pr_warn_once!() is now available, switch to it and update the comment accordingly.

---
 rust/kernel/module_param.rs | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
rust/kernel/module_param.rs +2 -2
index 6a8a7a875..fedb709fa 100644
@@ -62,8 +62,8 @@ pub trait ModuleParam: Sized + Copy {
     // NOTE: If we start supporting arguments without values, val _is_ allowed
     // to be null here.
     if val.is_null() {
-        // TODO: Use pr_warn_once available.
-        crate::pr_warn!("Null pointer passed to `module_param::set_param`");
+        // `pr_warn_once` is already available, use it.
+        crate::pr_warn_once!("Null pointer passed to `module_param::set_param`");
         return EINVAL.to_errno();
     }
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 9 lines · Xiaobo Liu

Replace pr_warn!() with pr_warn_once!() in module_param::set_param() to avoid flooding the kernel log when a null pointer is repeatedly passed.

The original code had a TODO comment noting that pr_warn_once should be used once available. Since pr_warn_once!() is now available, switch to it and update the comment accordingly.

Isn't this

https://lore.kernel.org/rust-for-linux/[email protected]/

and this:

https://lore.kernel.org/rust-for-linux/[email protected]/

? Cc'ing the authors of both. I will reply in the second one too.

(Also, your email seems to have been sent twice to the list)

In any case, Sashiko is correct, this "time-based comment" is not very useful:

Quoted 1 line

+ // pr_warn_once is already available, use it.

Cheers,
Miguel