ACPI: move from strlcpy() with unused retval to strscpy()
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Thu, 18 Aug 2022 20:59:55 +0000 (22:59 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 23 Aug 2022 16:55:14 +0000 (18:55 +0200)
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>
drivers/acpi/bus.c
drivers/acpi/processor_idle.c
drivers/acpi/utils.c

index c0d20d997891c34d69c6397f3f1fcfcc96ab0220..1d29f5dc7d7960c9ece83b0d789c68faf1446ba8 100644 (file)
@@ -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;
 }
@@ -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);
 
index 16a1663d02d460579e61c9e98ff2d1ca5d0ba0c8..1778016ea89517ab5042fdd5663f7784fddfb37e 100644 (file)
@@ -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;
@@ -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;
@@ -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;
@@ -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)
index 5a7b8065e77ffd73f4d1b339571fc5e12d9d58f7..4acd6f7d1395ebd4b15c967d689a3b78a78a67c7 100644 (file)
@@ -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;
 
@@ -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;
 
@@ -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;
 }