diff mbox series

ACPICA: Replace deprecated strncpy() with strscpy()

Message ID 20250317143806244wrGxYdlssPbWp7T7W5Gbr@zte.com.cn
State New
Headers show
Series ACPICA: Replace deprecated strncpy() with strscpy() | expand

Commit Message

feng.wei8@zte.com.cn March 17, 2025, 6:38 a.m. UTC
From: FengWei <feng.wei8@zte.com.cn>

strncpy() is deprecated for NUL-terminated destination buffers. Use
strscpy() instead and remove the manual NUL-termination.

Signed-off-by: FengWei <feng.wei8@zte.com.cn>
---
 drivers/acpi/acpica/utnonansi.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/acpi/acpica/utnonansi.c b/drivers/acpi/acpica/utnonansi.c
index ff0802ace19b..1da9b8246011 100644
--- a/drivers/acpi/acpica/utnonansi.c
+++ b/drivers/acpi/acpica/utnonansi.c
@@ -168,8 +168,7 @@  void acpi_ut_safe_strncpy(char *dest, char *source, acpi_size dest_size)
 {
 	/* Always terminate destination string */

-	strncpy(dest, source, dest_size);
-	dest[dest_size - 1] = 0;
+	strscpy(dest, source, dest_size);
 }

 #endif