@@ -626,8 +626,6 @@ void acpi_ut_repair_name(char *name);
#if defined (ACPI_DEBUGGER) || defined (ACPI_APPLICATION) || defined (ACPI_DEBUG_OUTPUT)
u8 acpi_ut_safe_strcpy(char *dest, acpi_size dest_size, char *source);
-void acpi_ut_safe_strncpy(char *dest, char *source, acpi_size dest_size);
-
u8 acpi_ut_safe_strcat(char *dest, acpi_size dest_size, char *source);
u8
@@ -63,7 +63,7 @@ void acpi_db_open_debug_file(char *name)
}
acpi_os_printf("Debug output file %s opened\n", name);
- acpi_ut_safe_strncpy(acpi_gbl_db_debug_filename, name,
+ strscpy(acpi_gbl_db_debug_filename, name,
sizeof(acpi_gbl_db_debug_filename));
acpi_gbl_db_output_to_file = TRUE;
}
@@ -60,7 +60,7 @@ void acpi_ps_init_op(union acpi_parse_object *op, u16 opcode)
op->common.descriptor_type = ACPI_DESC_TYPE_PARSER;
op->common.aml_opcode = opcode;
- ACPI_DISASM_ONLY_MEMBERS(acpi_ut_safe_strncpy(op->common.aml_op_name,
+ ACPI_DISASM_ONLY_MEMBERS(strscpy(op->common.aml_op_name,
(acpi_ps_get_opcode_info
(opcode))->name,
sizeof(op->common.
@@ -164,12 +164,4 @@ acpi_ut_safe_strncat(char *dest,
return (FALSE);
}
-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;
-}
-
#endif
@@ -368,7 +368,7 @@ acpi_ut_track_allocation(struct acpi_debug_mem_block *allocation,
allocation->component = component;
allocation->line = line;
- acpi_ut_safe_strncpy(allocation->module, (char *)module,
+ strscpy(allocation->module, (char *)module,
ACPI_MAX_MODULE_NAME);
if (!element) {
I wanted to gather some thoughts on removing `acpi_ut_safe_strncpy` (and potentially other `acpi...safe...()` interfaces) in favor of pre-existing interfaces in the kernel (like strscpy). Running a git blame shows these functions were implemented 10 years ago and their implementations generally mirror the _newer_ and more robust stuff in lib/string.h -- Let's just use these, right? I appreciate any comments and whether or not I should stop at just `strncpy`. Thanks Signed-off-by: Justin Stitt <justinstitt@google.com> --- drivers/acpi/acpica/acutils.h | 2 -- drivers/acpi/acpica/dbfileio.c | 2 +- drivers/acpi/acpica/psutils.c | 2 +- drivers/acpi/acpica/utnonansi.c | 8 -------- drivers/acpi/acpica/uttrack.c | 2 +- 5 files changed, 3 insertions(+), 13 deletions(-) --- base-commit: f9604036a3fb6149badf346994b46b03f9292db7 change-id: 20230824-strncpy-drivers-acpi-acpica-321af3eb414e Best regards, -- Justin Stitt <justinstitt@google.com>