Re: [PATCH] test_power: add missing newlines when printing parameters by sysfs

From: Sebastian Reichel
Date: Sun Oct 04 2020 - 18:16:50 EST


Hi,

On Sat, Oct 03, 2020 at 02:55:41PM -0700, Joe Perches wrote:
> On Sat, 2020-10-03 at 23:50 +0200, Sebastian Reichel wrote:
> > Hi,
> >
> > On Sat, Oct 03, 2020 at 02:43:09PM -0700, Joe Perches wrote:
> > > On Sat, 2020-10-03 at 23:23 +0200, Sebastian Reichel wrote:
> > > > On Fri, Sep 04, 2020 at 02:09:58PM +0800, Xiongfeng Wang wrote:
> > > > > When I cat some module parameters by sysfs, it displays as follows.
> > > > > It's better to add a newline for easy reading.
> > > []
> > > > > root@syzkaller:~# cd /sys/module/test_power/parameters/
> > > > > root@syzkaller:/sys/module/test_power/parameters# cat ac_online
> > > > > onroot@syzkaller:/sys/module/test_power/parameters# cat battery_present
> > > > > trueroot@syzkaller:/sys/module/test_power/parameters# cat battery_health
> > > > > goodroot@syzkaller:/sys/module/test_power/parameters# cat battery_status
> > > > > dischargingroot@syzkaller:/sys/module/test_power/parameters# cat battery_technology
> > > > > LIONroot@syzkaller:/sys/module/test_power/parameters# cat usb_online
> > > > > onroot@syzkaller:/sys/module/test_power/parameters#
> > > > >
> > > > > Signed-off-by: Xiongfeng Wang <wangxiongfeng2@xxxxxxxxxx>
> > > > > ---
> > > >
> > > > Thanks, queued.
> > > []
> > > > > diff --git a/drivers/power/supply/test_power.c b/drivers/power/supply/test_power.c
> > > []
> > > > > @@ -353,6 +353,7 @@ static int param_set_ac_online(const char *key, const struct kernel_param *kp)
> > > > > static int param_get_ac_online(char *buffer, const struct kernel_param *kp)
> > > > > {
> > > > > strcpy(buffer, map_get_key(map_ac_online, ac_online, "unknown"));
> > > > > + strcat(buffer, "\n");
> > > > > return strlen(buffer);
> > > > > }
> > >
> > > All of these would be better as sprintf(buffer, "%s\n", <whatever>)
> > > so the output is scanned just once instead of scanned three times.
> >
> > Agreed. Anybody willing to send a patch? :)
>
> Well, you _are_ the maintainer. Why not you?

I prefer to have patches reviewed and when I sent out patches for
my own subsystem I often do not get any reviews at all. From my
experience people often like to increase their patch count anyways
(e.g. because their employer wanting to see high patch count), so
asking others to write the patch is an easy workaround for me. I
then only do the leftovers.

-- Sebastian

Attachment: signature.asc
Description: PGP signature