From bcccc6e1918fe7f3cb710e85a5ecd9c0360747c2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 4 Oct 2022 20:11:13 +1100 Subject: [PATCH] GCS_MAVLINK: fixed warning in ftp build with gcc 11.3 --- libraries/GCS_MAVLink/GCS_FTP.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/GCS_MAVLink/GCS_FTP.cpp b/libraries/GCS_MAVLink/GCS_FTP.cpp index f9098f4fd5..8ce03c23e6 100644 --- a/libraries/GCS_MAVLink/GCS_FTP.cpp +++ b/libraries/GCS_MAVLink/GCS_FTP.cpp @@ -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;