GCS_MAVLINK: fixed warning in ftp build with gcc 11.3

This commit is contained in:
Andrew Tridgell 2022-10-04 20:11:13 +11:00 committed by Randy Mackay
parent 40d514e1c3
commit 80302ba27c
1 changed files with 6 additions and 1 deletions

View File

@ -579,7 +579,12 @@ int GCS_MAVLINK::gen_dir_entry(char *dest, size_t space, const char *path, const
}
if (is_file) {
const size_t full_path_len = strlen(path) + strnlen(entry->d_name, 256); // FIXME: Really should do better then just hardcoding 256
#ifdef MAX_NAME_LEN
const uint8_t max_name_len = MIN(unsigned(MAX_NAME_LEN), 255U);
#else
const uint8_t max_name_len = 255U;
#endif
const size_t full_path_len = strlen(path) + strnlen(entry->d_name, max_name_len);
char full_path[full_path_len + 2];
hal.util->snprintf(full_path, sizeof(full_path), "%s/%s", path, entry->d_name);
struct stat st;