Commit 411643e9 authored by Harley A.W. Lorenzo's avatar Harley A.W. Lorenzo Committed by Sebastian Reichel

power: supply: test-power: revise parameter printing to use sprintf

Simplify code by using sprintf instead of strcpy+strcat+strlen.
Signed-off-by: default avatarHarley A.W. Lorenzo <hl1998@protonmail.com>
Suggested-by: default avatarJoe Perches <joe@perches.com>
Signed-off-by: default avatarSebastian Reichel <sebastian.reichel@collabora.com>
parent 10a4357f
......@@ -352,9 +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");
return strlen(buffer);
return sprintf(buffer, "%s\n",
map_get_key(map_ac_online, ac_online, "unknown"));
}
static int param_set_usb_online(const char *key, const struct kernel_param *kp)
......@@ -366,9 +365,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");
return strlen(buffer);
return sprintf(buffer, "%s\n",
map_get_key(map_ac_online, usb_online, "unknown"));
}
static int param_set_battery_status(const char *key,
......@@ -381,9 +379,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");
return strlen(buffer);
return sprintf(buffer, "%s\n",
map_get_key(map_ac_online, battery_status, "unknown"));
}
static int param_set_battery_health(const char *key,
......@@ -396,9 +393,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");
return strlen(buffer);
return sprintf(buffer, "%s\n",
map_get_key(map_ac_online, battery_health, "unknown"));
}
static int param_set_battery_present(const char *key,
......@@ -412,9 +408,8 @@ 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");
return strlen(buffer);
return sprintf(buffer, "%s\n",
map_get_key(map_ac_online, battery_present, "unknown"));
}
static int param_set_battery_technology(const char *key,
......@@ -429,10 +424,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");
return strlen(buffer);
return sprintf(buffer, "%s\n",
map_get_key(map_ac_online, battery_technology,
"unknown"));
}
static int param_set_battery_capacity(const char *key,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment