[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1g3ecQ7VLlrgKOSHr6teWgw9xcmVVQx1bFp2KpJD7y35lZpaC8ONb-jrPKapmFttEwVg2uhDwmv6mug9z5-GVZbqPbkOjcqjrSHtaW-k6ts=@protonmail.com>
Date: Mon, 05 Oct 2020 01:30:25 +0000
From: "Harley A.W. Lorenzo" <hl1998@...tonmail.com>
To: Sebastian Reichel <sre@...nel.org>
Cc: "linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"wangxiongfeng2@...wei.com" <wangxiongfeng2@...wei.com>,
"joe@...ches.com" <joe@...ches.com>
Subject: Re: [PATCH] test_power: add missing newlines when printing parameters by sysfs
Here is the updated patch using sprintf, diffing from the original patch by Xiongfeng Wang.
[PATCH] test_power: revise parameter printing to use sprintf
Signed-off-by: Harley A.W. Lorenzo <hl1998@...tonmail.com>
Suggested-by: Joe Perches <joe@...ches.com>
---
drivers/power/supply/test_power.c | 27 ++++++++++++++-------------
1 file changed, 14 insertions(+), 13 deletions(-)
diff --git a/drivers/power/supply/test_power.c b/drivers/power/supply/test_power.c
index 4895ee5e63a9..fbb179a1b615 100644
--- a/drivers/power/supply/test_power.c
+++ b/drivers/power/supply/test_power.c
@@ -352,8 +352,8 @@ 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");
+ char const *out = map_get_key(map_ac_online, ac_online, "unknown");
+ sprintf(buffer, "%s\n", out);
return strlen(buffer);
}
@@ -366,8 +366,8 @@ static int param_set_usb_online(const char *key, const struct kernel_param *kp)
static int param_get_usb_online(char *buffer, const struct kernel_param *kp)
{
- strcpy(buffer, map_get_key(map_ac_online, usb_online, "unknown"));
- strcat(buffer, "\n");
+ char const *out = map_get_key(map_ac_online, usb_online, "unknown");
+ sprintf(buffer, "%s\n", out);
return strlen(buffer);
}
@@ -381,8 +381,8 @@ static int param_set_battery_status(const char *key,
static int param_get_battery_status(char *buffer, const struct kernel_param *kp)
{
- strcpy(buffer, map_get_key(map_status, battery_status, "unknown"));
- strcat(buffer, "\n");
+ char const *out = map_get_key(map_ac_online, battery_status, "unknown");
+ sprintf(buffer, "%s\n", out);
return strlen(buffer);
}
@@ -396,8 +396,8 @@ static int param_set_battery_health(const char *key,
static int param_get_battery_health(char *buffer, const struct kernel_param *kp)
{
- strcpy(buffer, map_get_key(map_health, battery_health, "unknown"));
- strcat(buffer, "\n");
+ char const *out = map_get_key(map_ac_online, battery_health, "unknown");
+ sprintf(buffer, "%s\n", out);
return strlen(buffer);
}
@@ -412,8 +412,9 @@ static int param_set_battery_present(const char *key,
static int param_get_battery_present(char *buffer,
const struct kernel_param *kp)
{
- strcpy(buffer, map_get_key(map_present, battery_present, "unknown"));
- strcat(buffer, "\n");
+ char const *out = map_get_key(map_ac_online, battery_present,
+ "unknown");
+ sprintf(buffer, "%s\n", out);
return strlen(buffer);
}
@@ -429,9 +430,9 @@ static int param_set_battery_technology(const char *key,
static int param_get_battery_technology(char *buffer,
const struct kernel_param *kp)
{
- strcpy(buffer,
- map_get_key(map_technology, battery_technology, "unknown"));
- strcat(buffer, "\n");
+ char const *out = map_get_key(map_ac_online, battery_technology,
+ "unknown");
+ sprintf(buffer, "%s\n", out);
return strlen(buffer);
}
--
2.28.0
Powered by blists - more mailing lists