Skip to contentSkip to conversation

ACPI: processor: idle: Replace strlcat() with better alternative

PATCH Applied Andy Shevchenko 2 participants 2 messages Mar 17 – Mar 18 ACPI

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 ACPI: processor: idle: Replace strlcat() with better alternative

strlcpy() and strlcat() are confusing APIs and the former one already gone from the kernel. In preparation to kill strlcat() replace it with the better alternative.

---

v2: moved to scnprintf() to avoid GCC warning (clang was and is okay)

 drivers/acpi/processor_idle.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/acpi/processor_idle.c +1 -3
index 45b5d17443cf..479995a4c48a 100644
@@ -1010,9 +1010,7 @@ static bool combine_lpi_states(struct acpi_lpi_state *local,
 	result->arch_flags = parent->arch_flags;
 	result->index = parent->index;
 
-	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);
+	scnprintf(result->desc, ACPI_CX_DESC_LEN, "%s+%s", local->desc, parent->desc);
 	return true;
 }
 
Signature · 1 line
2.50.1
maintainer Applied
#1 lore raw
Quoted 19 lines · Andy Shevchenko

strlcpy() and strlcat() are confusing APIs and the former one already gone from the kernel. In preparation to kill strlcat() replace it with the better alternative.

---

v2: moved to scnprintf() to avoid GCC warning (clang was and is okay)

 drivers/acpi/processor_idle.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/acpi/processor_idle.c +0 -0
index 45b5d17443cf..479995a4c48a 100644
@@ -1010,9 +1010,7 @@ static bool combine_lpi_states(struct acpi_lpi_state *local,
        result->arch_flags = parent->arch_flags;

drivers/acpi/processor_idle.c static bool combine_lpi_states(struct acpi_lpi_state *local,

Quoted 10 lines
drivers/acpi/processor_idle.c +1 -4
        result->index = parent->index;
 
-       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);
+       scnprintf(result->desc, ACPI_CX_DESC_LEN, "%s+%s", local->desc, parent->desc);
        return true;
 }
 
--

Applied as 7.1 material, thanks!