Skip to content

Commit

Permalink
AP_Param: clarify use of parameter text buffer
Browse files Browse the repository at this point in the history
Refer to it 'buffer' instead of 'string' to clarify that the length is
respected and that it does not need to be null terminated.
  • Loading branch information
tpwrules committed Feb 10, 2024
1 parent 9cc889e commit 075afb2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
14 changes: 7 additions & 7 deletions libraries/AP_Param/AP_Param.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion libraries/AP_Param/AP_Param.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/*
Expand Down

0 comments on commit 075afb2

Please sign in to comment.