* [PATCH] acpi: replace snprintf in show functions with sysfs_emit
@ 2021-10-13 3:24 Qing Wang
2021-10-13 18:04 ` Rafael J. Wysocki
0 siblings, 1 reply; 2+ messages in thread
From: Qing Wang @ 2021-10-13 3:24 UTC (permalink / raw)
To: Rafael J. Wysocki, Len Brown, linux-acpi, linux-kernel; +Cc: Qing Wang
coccicheck complains about the use of snprintf() in sysfs show functions.
Fix the coccicheck warning:
WARNING: use scnprintf or sprintf.
Use sysfs_emit instead of scnprintf or sprintf makes more sense.
Signed-off-by: Qing Wang <wangqing@vivo.com>
---
drivers/acpi/acpi_lpss.c | 2 +-
drivers/acpi/dock.c | 8 ++++----
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
index 894b7e6..9c437d4 100644
--- a/drivers/acpi/acpi_lpss.c
+++ b/drivers/acpi/acpi_lpss.c
@@ -748,7 +748,7 @@ static ssize_t lpss_ltr_show(struct device *dev, struct device_attribute *attr,
if (ret)
return ret;
- return snprintf(buf, PAGE_SIZE, "%08x\n", ltr_value);
+ return sysfs_emit(buf, "%08x\n", ltr_value);
}
static ssize_t lpss_ltr_mode_show(struct device *dev,
diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
index 7cf9215..c8e9b96 100644
--- a/drivers/acpi/dock.c
+++ b/drivers/acpi/dock.c
@@ -492,7 +492,7 @@ static ssize_t docked_show(struct device *dev,
struct acpi_device *adev = NULL;
acpi_bus_get_device(dock_station->handle, &adev);
- return snprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev));
+ return sysfs_emit(buf, "%u\n", acpi_device_enumerated(adev));
}
static DEVICE_ATTR_RO(docked);
@@ -504,7 +504,7 @@ static ssize_t flags_show(struct device *dev,
{
struct dock_station *dock_station = dev->platform_data;
- return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
+ return sysfs_emit(buf, "%d\n", dock_station->flags);
}
static DEVICE_ATTR_RO(flags);
@@ -543,7 +543,7 @@ static ssize_t uid_show(struct device *dev,
if (ACPI_FAILURE(status))
return 0;
- return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
+ return sysfs_emit(buf, "%llx\n", lbuf);
}
static DEVICE_ATTR_RO(uid);
@@ -562,7 +562,7 @@ static ssize_t type_show(struct device *dev,
else
type = "unknown";
- return snprintf(buf, PAGE_SIZE, "%s\n", type);
+ return sysfs_emit(buf, "%s\n", type);
}
static DEVICE_ATTR_RO(type);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] acpi: replace snprintf in show functions with sysfs_emit
2021-10-13 3:24 [PATCH] acpi: replace snprintf in show functions with sysfs_emit Qing Wang
@ 2021-10-13 18:04 ` Rafael J. Wysocki
0 siblings, 0 replies; 2+ messages in thread
From: Rafael J. Wysocki @ 2021-10-13 18:04 UTC (permalink / raw)
To: Qing Wang
Cc: Rafael J. Wysocki, Len Brown, ACPI Devel Maling List,
Linux Kernel Mailing List
On Wed, Oct 13, 2021 at 5:25 AM Qing Wang <wangqing@vivo.com> wrote:
>
> coccicheck complains about the use of snprintf() in sysfs show functions.
>
> Fix the coccicheck warning:
> WARNING: use scnprintf or sprintf.
>
> Use sysfs_emit instead of scnprintf or sprintf makes more sense.
>
> Signed-off-by: Qing Wang <wangqing@vivo.com>
> ---
> drivers/acpi/acpi_lpss.c | 2 +-
> drivers/acpi/dock.c | 8 ++++----
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/acpi/acpi_lpss.c b/drivers/acpi/acpi_lpss.c
> index 894b7e6..9c437d4 100644
> --- a/drivers/acpi/acpi_lpss.c
> +++ b/drivers/acpi/acpi_lpss.c
> @@ -748,7 +748,7 @@ static ssize_t lpss_ltr_show(struct device *dev, struct device_attribute *attr,
> if (ret)
> return ret;
>
> - return snprintf(buf, PAGE_SIZE, "%08x\n", ltr_value);
> + return sysfs_emit(buf, "%08x\n", ltr_value);
> }
>
> static ssize_t lpss_ltr_mode_show(struct device *dev,
> diff --git a/drivers/acpi/dock.c b/drivers/acpi/dock.c
> index 7cf9215..c8e9b96 100644
> --- a/drivers/acpi/dock.c
> +++ b/drivers/acpi/dock.c
> @@ -492,7 +492,7 @@ static ssize_t docked_show(struct device *dev,
> struct acpi_device *adev = NULL;
>
> acpi_bus_get_device(dock_station->handle, &adev);
> - return snprintf(buf, PAGE_SIZE, "%u\n", acpi_device_enumerated(adev));
> + return sysfs_emit(buf, "%u\n", acpi_device_enumerated(adev));
> }
> static DEVICE_ATTR_RO(docked);
>
> @@ -504,7 +504,7 @@ static ssize_t flags_show(struct device *dev,
> {
> struct dock_station *dock_station = dev->platform_data;
>
> - return snprintf(buf, PAGE_SIZE, "%d\n", dock_station->flags);
> + return sysfs_emit(buf, "%d\n", dock_station->flags);
>
> }
> static DEVICE_ATTR_RO(flags);
> @@ -543,7 +543,7 @@ static ssize_t uid_show(struct device *dev,
> if (ACPI_FAILURE(status))
> return 0;
>
> - return snprintf(buf, PAGE_SIZE, "%llx\n", lbuf);
> + return sysfs_emit(buf, "%llx\n", lbuf);
> }
> static DEVICE_ATTR_RO(uid);
>
> @@ -562,7 +562,7 @@ static ssize_t type_show(struct device *dev,
> else
> type = "unknown";
>
> - return snprintf(buf, PAGE_SIZE, "%s\n", type);
> + return sysfs_emit(buf, "%s\n", type);
> }
> static DEVICE_ATTR_RO(type);
>
> --
Applied as 5.16 material with some edits in the subject and changelog, thanks!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-13 18:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-13 3:24 [PATCH] acpi: replace snprintf in show functions with sysfs_emit Qing Wang
2021-10-13 18:04 ` Rafael J. Wysocki
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.