acpica: Removing deprecated strncpy()
Subsystems (2)
PATCH 1/1 acpica: Removing deprecated strncpy()
This patch suggests the replacement of strncpy with strscpy
as per Documentation/process/deprecated.
The strncpy() fails to guarantee NULL termination,
The function adds zero pads which isn't really convenient for short strings as it may cause performance issues.
strscpy() is a preferred replacement because
it overcomes the limitations of strncpy mentioned above.
Compile Tested
--- drivers/acpi/acpica/exconvrt.c | 2 +- drivers/acpi/acpica/tbfind.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/acpi/acpica/exconvrt.c +1 -1
@@ -226,7 +226,7 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,/* Copy the string to the buffer */ new_buf = return_desc->buffer.pointer; -strncpy ((char *)new_buf, (char *)obj_desc->string.pointer, +strscpy ((char *)new_buf, (char *)obj_desc->string.pointer, obj_desc->string.length);break ;
drivers/acpi/acpica/tbfind.c +2 -2
@@ -57,8 +57,8 @@ acpi_tb_find_table(char *signature,memset (&header,0 ,sizeof (struct acpi_table_header ));ACPI_COPY_NAMESEG (header.signature, signature); -strncpy (header.oem_id, oem_id,ACPI_OEM_ID_SIZE ); -strncpy (header.oem_table_id, oem_table_id,ACPI_OEM_TABLE_ID_SIZE ); +strscpy (header.oem_id, oem_id,ACPI_OEM_ID_SIZE ); +strscpy (header.oem_table_id, oem_table_id,ACPI_OEM_TABLE_ID_SIZE );/* Search for the table */
Signature · 1 line
2.39.5
Rafael J. Wysocki
maintainerQuoted 11 lines · Kevin Paul Reddy Janagari
This patch suggests the replacement of strncpy with strscpy
as perDocumentation/process/deprecated.
Thestrncpy()fails to guarantee NULL termination,
The function adds zero pads which isn't really convenient for short strings as it may cause performance issues.
strscpy()is a preferred replacement because
it overcomes the limitations of strncpy mentioned above.Compile Tested
ACPICA material is primarily handled by the upstream ACPICA project on GitHub, so ACPICA changes should first be submitted to upstream ACPICA as indicated on this list for many times, see for instance:
Quoted 38 lines
Signed-off-by Kevin Paul Reddy Janagari <[email protected]>--- drivers/acpi/acpica/exconvrt.c | 2 +- drivers/acpi/acpica/tbfind.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)drivers/acpi/acpica/exconvrt.c +1
-1@@ -226,7 +226,7 @@ acpi_ex_convert_to_buffer(union acpi_operand_object *obj_desc,/* Copy the string to the buffer */ new_buf = return_desc->buffer.pointer; -strncpy ((char *)new_buf, (char *)obj_desc->string.pointer, +strscpy ((char *)new_buf, (char *)obj_desc->string.pointer, obj_desc->string.length);break ;drivers/acpi/acpica/tbfind.c +2
-3@@ -57,8 +57,8 @@ acpi_tb_find_table(char *signature,memset (&header,0 ,sizeof (struct acpi_table_header ));ACPI_COPY_NAMESEG (header.signature, signature); -strncpy (header.oem_id, oem_id,ACPI_OEM_ID_SIZE ); -strncpy (header.oem_table_id, oem_table_id,ACPI_OEM_TABLE_ID_SIZE ); +strscpy (header.oem_id, oem_id,ACPI_OEM_ID_SIZE ); +strscpy (header.oem_table_id, oem_table_id,ACPI_OEM_TABLE_ID_SIZE );/* Search for the table */ --2.39.5