Skip to content

Commit

Permalink
ACPI: move from strlcpy() with unused retval to strscpy()
Browse files Browse the repository at this point in the history
Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Wolfram Sang authored and Rafael J. Wysocki committed Aug 23, 2022
1 parent 1c23f9e commit b75d2cd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions drivers/acpi/bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ static bool acpi_of_modalias(struct acpi_device *adev,

str = obj->string.pointer;
chr = strchr(str, ',');
strlcpy(modalias, chr ? chr + 1 : str, len);
strscpy(modalias, chr ? chr + 1 : str, len);

return true;
}
Expand All @@ -822,7 +822,7 @@ void acpi_set_modalias(struct acpi_device *adev, const char *default_id,
char *modalias, size_t len)
{
if (!acpi_of_modalias(adev, modalias, len))
strlcpy(modalias, default_id, len);
strscpy(modalias, default_id, len);
}
EXPORT_SYMBOL_GPL(acpi_set_modalias);

Expand Down
8 changes: 4 additions & 4 deletions drivers/acpi/processor_idle.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr)

state = &drv->states[count];
snprintf(state->name, CPUIDLE_NAME_LEN, "C%d", i);
strlcpy(state->desc, cx->desc, CPUIDLE_DESC_LEN);
strscpy(state->desc, cx->desc, CPUIDLE_DESC_LEN);
state->exit_latency = cx->latency;
state->target_residency = cx->latency * latency_factor;
state->enter = acpi_idle_enter;
Expand Down Expand Up @@ -956,7 +956,7 @@ static int acpi_processor_evaluate_lpi(acpi_handle handle,

obj = pkg_elem + 9;
if (obj->type == ACPI_TYPE_STRING)
strlcpy(lpi_state->desc, obj->string.pointer,
strscpy(lpi_state->desc, obj->string.pointer,
ACPI_CX_DESC_LEN);

lpi_state->index = state_idx;
Expand Down Expand Up @@ -1022,7 +1022,7 @@ static bool combine_lpi_states(struct acpi_lpi_state *local,
result->arch_flags = parent->arch_flags;
result->index = parent->index;

strlcpy(result->desc, local->desc, ACPI_CX_DESC_LEN);
strscpy(result->desc, local->desc, ACPI_CX_DESC_LEN);
strlcat(result->desc, "+", ACPI_CX_DESC_LEN);
strlcat(result->desc, parent->desc, ACPI_CX_DESC_LEN);
return true;
Expand Down Expand Up @@ -1196,7 +1196,7 @@ static int acpi_processor_setup_lpi_states(struct acpi_processor *pr)

state = &drv->states[i];
snprintf(state->name, CPUIDLE_NAME_LEN, "LPI-%d", i);
strlcpy(state->desc, lpi->desc, CPUIDLE_DESC_LEN);
strscpy(state->desc, lpi->desc, CPUIDLE_DESC_LEN);
state->exit_latency = lpi->wake_latency;
state->target_residency = lpi->min_residency;
if (lpi->arch_flags)
Expand Down
6 changes: 3 additions & 3 deletions drivers/acpi/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
struct acpi_dev_match_info match = {};
struct device *dev;

strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
strscpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
match.uid = uid;
match.hrv = hrv;

Expand Down Expand Up @@ -911,7 +911,7 @@ acpi_dev_get_next_match_dev(struct acpi_device *adev, const char *hid, const cha
struct acpi_dev_match_info match = {};
struct device *dev;

strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
strscpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
match.uid = uid;
match.hrv = hrv;

Expand Down Expand Up @@ -961,7 +961,7 @@ EXPORT_SYMBOL(acpi_video_backlight_string);

static int __init acpi_backlight(char *str)
{
strlcpy(acpi_video_backlight_string, str,
strscpy(acpi_video_backlight_string, str,
sizeof(acpi_video_backlight_string));
return 1;
}
Expand Down

0 comments on commit b75d2cd

Please sign in to comment.