[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200720195234.GC2952@minyard.net>
Date: Mon, 20 Jul 2020 14:52:34 -0500
From: Corey Minyard <minyard@....org>
To: Xiongfeng Wang <wangxiongfeng2@...wei.com>
Cc: arnd@...db.de, gregkh@...uxfoundation.org,
openipmi-developer@...ts.sourceforge.net,
linux-kernel@...r.kernel.org, guohanjun@...wei.com
Subject: Re: [PATCH] ipmi/watchdog: add missing newlines when printing
parameters by sysfs
On Mon, Jul 20, 2020 at 10:03:25AM +0800, Xiongfeng Wang wrote:
> When I cat some ipmi_watchdog parameters by sysfs, it displays as
> follows. It's better to add a newline for easy reading.
>
> root@(none):/# cat /sys/module/ipmi_watchdog/parameters/action
> resetroot@(none):/# cat /sys/module/ipmi_watchdog/parameters/preaction
> pre_noneroot@(none):/# cat /sys/module/ipmi_watchdog/parameters/preop
> preop_noneroot@(none):/#
Yeah, that's not consistent with other things displayed in the kernel.
>
> Signed-off-by: Xiongfeng Wang <wangxiongfeng2@...wei.com>
> ---
> drivers/char/ipmi/ipmi_watchdog.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/char/ipmi/ipmi_watchdog.c b/drivers/char/ipmi/ipmi_watchdog.c
> index 55986e1..3e05a1d 100644
> --- a/drivers/char/ipmi/ipmi_watchdog.c
> +++ b/drivers/char/ipmi/ipmi_watchdog.c
> @@ -232,12 +232,16 @@ static int set_param_str(const char *val, const struct kernel_param *kp)
> static int get_param_str(char *buffer, const struct kernel_param *kp)
> {
> action_fn fn = (action_fn) kp->arg;
> - int rv;
> + int rv, len;
>
> rv = fn(NULL, buffer);
> if (rv)
> return rv;
> - return strlen(buffer);
> +
> + len = strlen(buffer);
> + len += sprintf(buffer + len, "\n");
sprintf is kind of overkill to stick a \n on the end of a line. How
about:
buffer[len++] = '\n';
Since you are returning the length, you shouldn't need to nil terminate
the string.
An unrelated question: Are you using any of the special functions of the
IPMI watchdog, like the pretimeout?
-corey
> +
> + return len;
> }
>
>
> --
> 1.7.12.4
>
Powered by blists - more mailing lists