Re: [PATCH v3 2/2] watchdog: use kstrtouint to parse softlockup_panic=

From: Guenter Roeck

Date: Tue Sep 22 2026 - 12:28:08 EST


On Tue, Sep 22, 2026 at 10:49:52PM +0800, 林濬哲 wrote:
>
> simple_strtoul() is deprecated. Use kstrtouint() instead; on a parse
> error the variable is now left unchanged instead of being silently
> clamped.
>
> __setup() handlers return whether they handled the option and cannot
> propagate parse errors, so the handler simply returns 1.
>
> v3: do not warn on parse errors (Guenter Roeck).
>
> Signed-off-by: Lin Junzhe <m18667909625@xxxxxxx>
> Assisted-by: AI coding assistant (per kernel AI guidelines)
> ---
> kernel/watchdog.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/watchdog.c b/kernel/watchdog.c
> index 420f08140713..69cd5ebb4929 100644
> --- a/kernel/watchdog.c
> +++ b/kernel/watchdog.c
> @@ -423,10 +423,11 @@ static unsigned long soft_lockup_nmi_warn;
>
> static int __init softlockup_panic_setup(char *str)
> {
> - int ret;
> + unsigned int val;
>
> - ret = kstrtouint(str, 0, &softlockup_panic);
> - return ret ? ret : 1;
> + if (!kstrtouint(str, 0, &val))
> + softlockup_panic = val;
> + return 1;

This is not v3, it is a patch applied on top of a previous version,
and it unnecessarily introduces a temporary variable.

Guenter