mirror of
https://github.com/torvalds/linux.git
synced 2024-11-27 06:31:52 +00:00
power: supply: test-power: revise parameter printing to use sprintf
Simplify code by using sprintf instead of strcpy+strcat+strlen. Signed-off-by: Harley A.W. Lorenzo <hl1998@protonmail.com> Suggested-by: Joe Perches <joe@perches.com> Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
parent
10a4357f4a
commit
411643e949
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user