Skip to content

Commit b75d2cd

Browse files
Wolfram Sangrafaeljw
authored andcommitted
ACPI: move from strlcpy() with unused retval to strscpy()
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 <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 1c23f9e commit b75d2cd

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

drivers/acpi/bus.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ static bool acpi_of_modalias(struct acpi_device *adev,
802802

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

807807
return true;
808808
}
@@ -822,7 +822,7 @@ void acpi_set_modalias(struct acpi_device *adev, const char *default_id,
822822
char *modalias, size_t len)
823823
{
824824
if (!acpi_of_modalias(adev, modalias, len))
825-
strlcpy(modalias, default_id, len);
825+
strscpy(modalias, default_id, len);
826826
}
827827
EXPORT_SYMBOL_GPL(acpi_set_modalias);
828828

drivers/acpi/processor_idle.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ static int acpi_processor_setup_cstates(struct acpi_processor *pr)
787787

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

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

962962
lpi_state->index = state_idx;
@@ -1022,7 +1022,7 @@ static bool combine_lpi_states(struct acpi_lpi_state *local,
10221022
result->arch_flags = parent->arch_flags;
10231023
result->index = parent->index;
10241024

1025-
strlcpy(result->desc, local->desc, ACPI_CX_DESC_LEN);
1025+
strscpy(result->desc, local->desc, ACPI_CX_DESC_LEN);
10261026
strlcat(result->desc, "+", ACPI_CX_DESC_LEN);
10271027
strlcat(result->desc, parent->desc, ACPI_CX_DESC_LEN);
10281028
return true;
@@ -1196,7 +1196,7 @@ static int acpi_processor_setup_lpi_states(struct acpi_processor *pr)
11961196

11971197
state = &drv->states[i];
11981198
snprintf(state->name, CPUIDLE_NAME_LEN, "LPI-%d", i);
1199-
strlcpy(state->desc, lpi->desc, CPUIDLE_DESC_LEN);
1199+
strscpy(state->desc, lpi->desc, CPUIDLE_DESC_LEN);
12001200
state->exit_latency = lpi->wake_latency;
12011201
state->target_residency = lpi->min_residency;
12021202
if (lpi->arch_flags)

drivers/acpi/utils.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -878,7 +878,7 @@ bool acpi_dev_present(const char *hid, const char *uid, s64 hrv)
878878
struct acpi_dev_match_info match = {};
879879
struct device *dev;
880880

881-
strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
881+
strscpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
882882
match.uid = uid;
883883
match.hrv = hrv;
884884

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

914-
strlcpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
914+
strscpy(match.hid[0].id, hid, sizeof(match.hid[0].id));
915915
match.uid = uid;
916916
match.hrv = hrv;
917917

@@ -961,7 +961,7 @@ EXPORT_SYMBOL(acpi_video_backlight_string);
961961

962962
static int __init acpi_backlight(char *str)
963963
{
964-
strlcpy(acpi_video_backlight_string, str,
964+
strscpy(acpi_video_backlight_string, str,
965965
sizeof(acpi_video_backlight_string));
966966
return 1;
967967
}

0 commit comments

Comments
 (0)