From: Hans de Goede <hdegoede@redhat.com>
To: Qing Wang <wangqing@vivo.com>,
Kenneth Chan <kenneth.t.chan@gmail.com>,
Mark Gross <mgross@linux.intel.com>,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] x86: replace snprintf in show functions with sysfs_emit
Date: Tue, 19 Oct 2021 17:12:47 +0200 [thread overview]
Message-ID: <0c1a4b5a-bfeb-4ad2-99cd-fa65b96c8346@redhat.com> (raw)
In-Reply-To: <1634280641-4862-1-git-send-email-wangqing@vivo.com>
Hi,
On 10/15/21 08:50, Qing Wang wrote:
> show() must not use snprintf() when formatting the value to be
> returned to user space.
>
> Fix the coccicheck warnings:
> WARNING: use scnprintf or sprintf.
>
> Use sysfs_emit instead of scnprintf or sprintf makes more sense.
>
> Signed-off-by: Qing Wang <wangqing@vivo.com>
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/panasonic-laptop.c | 18 +++++++++---------
> 1 file changed, 9 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c
> index d4f4444..37850d0 100644
> --- a/drivers/platform/x86/panasonic-laptop.c
> +++ b/drivers/platform/x86/panasonic-laptop.c
> @@ -470,7 +470,7 @@ static ssize_t numbatt_show(struct device *dev, struct device_attribute *attr,
> if (!acpi_pcc_retrieve_biosdata(pcc))
> return -EIO;
>
> - return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_NUM_BATTERIES]);
> + return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_NUM_BATTERIES]);
> }
>
> static ssize_t lcdtype_show(struct device *dev, struct device_attribute *attr,
> @@ -482,7 +482,7 @@ static ssize_t lcdtype_show(struct device *dev, struct device_attribute *attr,
> if (!acpi_pcc_retrieve_biosdata(pcc))
> return -EIO;
>
> - return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_LCD_TYPE]);
> + return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_LCD_TYPE]);
> }
>
> static ssize_t mute_show(struct device *dev, struct device_attribute *attr,
> @@ -494,7 +494,7 @@ static ssize_t mute_show(struct device *dev, struct device_attribute *attr,
> if (!acpi_pcc_retrieve_biosdata(pcc))
> return -EIO;
>
> - return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_MUTE]);
> + return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_MUTE]);
> }
>
> static ssize_t mute_store(struct device *dev, struct device_attribute *attr,
> @@ -524,7 +524,7 @@ static ssize_t sticky_key_show(struct device *dev, struct device_attribute *attr
> if (!acpi_pcc_retrieve_biosdata(pcc))
> return -EIO;
>
> - return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sticky_key);
> + return sysfs_emit(buf, "%u\n", pcc->sticky_key);
> }
>
> static ssize_t sticky_key_store(struct device *dev, struct device_attribute *attr,
> @@ -566,7 +566,7 @@ static ssize_t eco_mode_show(struct device *dev, struct device_attribute *attr,
> result = -EIO;
> break;
> }
> - return snprintf(buf, PAGE_SIZE, "%u\n", result);
> + return sysfs_emit(buf, "%u\n", result);
> }
>
> static ssize_t eco_mode_store(struct device *dev, struct device_attribute *attr,
> @@ -625,7 +625,7 @@ static ssize_t ac_brightness_show(struct device *dev, struct device_attribute *a
> if (!acpi_pcc_retrieve_biosdata(pcc))
> return -EIO;
>
> - return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_AC_CUR_BRIGHT]);
> + return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_AC_CUR_BRIGHT]);
> }
>
> static ssize_t ac_brightness_store(struct device *dev, struct device_attribute *attr,
> @@ -655,7 +655,7 @@ static ssize_t dc_brightness_show(struct device *dev, struct device_attribute *a
> if (!acpi_pcc_retrieve_biosdata(pcc))
> return -EIO;
>
> - return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_DC_CUR_BRIGHT]);
> + return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_DC_CUR_BRIGHT]);
> }
>
> static ssize_t dc_brightness_store(struct device *dev, struct device_attribute *attr,
> @@ -685,7 +685,7 @@ static ssize_t current_brightness_show(struct device *dev, struct device_attribu
> if (!acpi_pcc_retrieve_biosdata(pcc))
> return -EIO;
>
> - return snprintf(buf, PAGE_SIZE, "%u\n", pcc->sinf[SINF_CUR_BRIGHT]);
> + return sysfs_emit(buf, "%u\n", pcc->sinf[SINF_CUR_BRIGHT]);
> }
>
> static ssize_t current_brightness_store(struct device *dev, struct device_attribute *attr,
> @@ -710,7 +710,7 @@ static ssize_t current_brightness_store(struct device *dev, struct device_attrib
> static ssize_t cdpower_show(struct device *dev, struct device_attribute *attr,
> char *buf)
> {
> - return snprintf(buf, PAGE_SIZE, "%d\n", get_optd_power_state());
> + return sysfs_emit(buf, "%d\n", get_optd_power_state());
> }
>
> static ssize_t cdpower_store(struct device *dev, struct device_attribute *attr,
>
prev parent reply other threads:[~2021-10-19 15:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-15 6:50 Qing Wang
2021-10-19 15:12 ` 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=0c1a4b5a-bfeb-4ad2-99cd-fa65b96c8346@redhat.com \
--to=hdegoede@redhat.com \
--cc=kenneth.t.chan@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgross@linux.intel.com \
--cc=platform-driver-x86@vger.kernel.org \
--cc=wangqing@vivo.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
all inboxes | Powered by JetHome®