From: Hans de Goede <hdegoede@redhat.com>
To: cgel.zte@gmail.com, matan@svgalib.org
Cc: markgross@kernel.org, platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org, Ye Guojin <ye.guojin@zte.com.cn>,
Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH] platform/x86: lg-laptop: replace snprintf in show functions with sysfs_emit
Date: Fri, 22 Oct 2021 11:14:20 +0200 [thread overview]
Message-ID: <39927c6d-8c55-5667-4aa0-31d746df90cc@redhat.com> (raw)
In-Reply-To: <20211022090722.1065457-1-ye.guojin@zte.com.cn>
Hi,
On 10/22/21 11:07, cgel.zte@gmail.com wrote:
> From: Ye Guojin <ye.guojin@zte.com.cn>
>
> coccicheck complains about the use of snprintf() in sysfs show
> functions:
> WARNING use scnprintf or sprintf
>
> Use sysfs_emit instead of scnprintf or sprintf makes more sense.
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Ye Guojin <ye.guojin@zte.com.cn>
Thank you for your patch, I've applied this patch to my review-hans
branch:
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/log/?h=review-hans
Note it will show up in my review-hans branch once I've pushed my
local branch there, which might take a while.
Once I've run some tests on this branch the patches there will be
added to the platform-drivers-x86/for-next branch and eventually
will be included in the pdx86 pull-request to Linus for the next
merge-window.
Regards,
Hans
> ---
> drivers/platform/x86/lg-laptop.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/platform/x86/lg-laptop.c b/drivers/platform/x86/lg-laptop.c
> index 7e9351c36389..ae9293024c77 100644
> --- a/drivers/platform/x86/lg-laptop.c
> +++ b/drivers/platform/x86/lg-laptop.c
> @@ -330,7 +330,7 @@ static ssize_t fan_mode_show(struct device *dev,
> status = r->integer.value & 0x01;
> kfree(r);
>
> - return snprintf(buffer, PAGE_SIZE, "%d\n", status);
> + return sysfs_emit(buffer, "%d\n", status);
> }
>
> static ssize_t usb_charge_store(struct device *dev,
> @@ -372,7 +372,7 @@ static ssize_t usb_charge_show(struct device *dev,
>
> kfree(r);
>
> - return snprintf(buffer, PAGE_SIZE, "%d\n", status);
> + return sysfs_emit(buffer, "%d\n", status);
> }
>
> static ssize_t reader_mode_store(struct device *dev,
> @@ -414,7 +414,7 @@ static ssize_t reader_mode_show(struct device *dev,
>
> kfree(r);
>
> - return snprintf(buffer, PAGE_SIZE, "%d\n", status);
> + return sysfs_emit(buffer, "%d\n", status);
> }
>
> static ssize_t fn_lock_store(struct device *dev,
> @@ -455,7 +455,7 @@ static ssize_t fn_lock_show(struct device *dev,
> status = !!r->buffer.pointer[0];
> kfree(r);
>
> - return snprintf(buffer, PAGE_SIZE, "%d\n", status);
> + return sysfs_emit(buffer, "%d\n", status);
> }
>
> static ssize_t battery_care_limit_store(struct device *dev,
> @@ -520,7 +520,7 @@ static ssize_t battery_care_limit_show(struct device *dev,
> if (status != 80 && status != 100)
> status = 0;
>
> - return snprintf(buffer, PAGE_SIZE, "%d\n", status);
> + return sysfs_emit(buffer, "%d\n", status);
> }
>
> static DEVICE_ATTR_RW(fan_mode);
>
prev parent reply other threads:[~2021-10-22 9:16 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-22 9:07 cgel.zte
2021-10-22 9:14 ` Hans de Goede [this message]
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=39927c6d-8c55-5667-4aa0-31d746df90cc@redhat.com \
--to=hdegoede@redhat.com \
--cc=cgel.zte@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=matan@svgalib.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=ye.guojin@zte.com.cn \
--cc=zealci@zte.com.cn \
/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
all inboxes | Powered by JetHome®