From: Joe Perches <joe@perches.com>
To: Sebastian Reichel <sre@kernel.org>,
Xiongfeng Wang <wangxiongfeng2@huawei.com>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] test_power: add missing newlines when printing parameters by sysfs
Date: Sat, 03 Oct 2020 14:43:09 -0700 [thread overview]
Message-ID: <472008b94f4b20915425db4714fdb505cb0cbe5a.camel@perches.com> (raw)
In-Reply-To: <20201003212336.5et7erdf6fihqscu@earth.universe>
On Sat, 2020-10-03 at 23:23 +0200, Sebastian Reichel wrote:
> Hi,
>
> 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@huawei.com>
> > ---
>
> 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.
next prev parent reply other threads:[~2020-10-03 21:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-04 6:09 [PATCH] test_power: add missing newlines when printing parameters by sysfs Xiongfeng Wang
2020-10-03 21:23 ` Sebastian Reichel
2020-10-03 21:43 ` Joe Perches [this message]
2020-10-03 21:50 ` Sebastian Reichel
2020-10-03 21:55 ` Joe Perches
2020-10-04 22:16 ` Sebastian Reichel
2020-10-05 1:30 ` Harley A.W. Lorenzo
2020-10-05 4:19 ` Joe Perches
2020-10-05 4:44 ` Harley A.W. Lorenzo
2020-10-08 23:07 ` Sebastian Reichel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=472008b94f4b20915425db4714fdb505cb0cbe5a.camel@perches.com \
--to=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sre@kernel.org \
--cc=wangxiongfeng2@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox