From 075afb2f2591089256bc494aac7637044447d2a3 Mon Sep 17 00:00:00 2001 From: Thomas Watson Date: Sat, 10 Feb 2024 12:45:14 -0600 Subject: [PATCH] AP_Param: clarify use of parameter text buffer Refer to it 'buffer' instead of 'string' to clarify that the length is respected and that it does not need to be null terminated. --- libraries/AP_Param/AP_Param.cpp | 14 +++++++------- libraries/AP_Param/AP_Param.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libraries/AP_Param/AP_Param.cpp b/libraries/AP_Param/AP_Param.cpp index e3983e2812b9a..e9838d6a98ff9 100644 --- a/libraries/AP_Param/AP_Param.cpp +++ b/libraries/AP_Param/AP_Param.cpp @@ -1627,15 +1627,15 @@ void AP_Param::load_defaults_file_from_romfs(const char *default_file, bool last // filename without the prefix: const char *trimmed_filename = &default_file[strlen(prefix)]; - uint32_t string_length; - const uint8_t *text = AP_ROMFS::find_decompress(trimmed_filename, string_length); - if (text == nullptr) { + uint32_t data_length; + const uint8_t *data = AP_ROMFS::find_decompress(trimmed_filename, data_length); + if (data == nullptr) { return; } - load_param_defaults((const char*)text, string_length, last_pass); + load_param_defaults((const char*)data, data_length, last_pass); - AP_ROMFS::free(text); + AP_ROMFS::free(data); } #endif // HAL_HAVE_AP_ROMFS_EMBEDDED_H @@ -2372,7 +2372,7 @@ bool AP_Param::load_defaults_file(const char *filename, bool last_pass) #if AP_PARAM_MAX_EMBEDDED_PARAM > 0 || (!AP_FILESYSTEM_FILE_READING_ENABLED && defined(HAL_HAVE_AP_ROMFS_EMBEDDED_H)) /* - count the number of parameter defaults present in supplied string + count the number of parameter defaults present in supplied buffer */ bool AP_Param::count_param_defaults(const volatile char *ptr, int32_t length, uint16_t &count) { @@ -2429,7 +2429,7 @@ void AP_Param::load_embedded_param_defaults(bool last_pass) #endif // AP_PARAM_MAX_EMBEDDED_PARAM > 0 /* - * load parameter defaults from supplied string + * load parameter defaults from supplied buffer */ void AP_Param::load_param_defaults(const volatile char *ptr, int32_t length, bool last_pass) { diff --git a/libraries/AP_Param/AP_Param.h b/libraries/AP_Param/AP_Param.h index 85d533c1fd148..ddd6f4ce638f9 100644 --- a/libraries/AP_Param/AP_Param.h +++ b/libraries/AP_Param/AP_Param.h @@ -750,7 +750,7 @@ class AP_Param // load an @ROMFS defaults.parm using ROMFS API: static void load_defaults_file_from_romfs(const char *filename, bool lastpass); - // load defaults from supplied string: + // load defaults from supplied buffer: static void load_param_defaults(const volatile char *ptr, int32_t length, bool last_pass); /*