Add static_assert to verify LOG_FILEPATH_SCANF_WIDTH is synchronized

- Add compile-time check that LOG_FILEPATH_SIZE == 256
- Ensures LOG_FILEPATH_SCANF_WIDTH stays synchronized if buffer size changes
- Provides clear error message if someone modifies LOG_FILEPATH_SIZE

Co-authored-by: dakejahl <37091262+dakejahl@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-12-15 21:50:04 +00:00
co-authored by dakejahl
parent ca336fb299
commit fe7bf8472b
@@ -61,7 +61,9 @@ static_assert(PX4_MAX_FILEPATH >= MavlinkLogHandler::LOG_FILEPATH_SIZE,
// Width specifier for sscanf - must be LOG_FILEPATH_SIZE - 1
// This is hardcoded as 255 because preprocessor can't evaluate (256-1) in format strings
// The static_assert below ensures this stays synchronized with LOG_FILEPATH_SIZE
#define LOG_FILEPATH_SCANF_WIDTH "255"
static_assert(MavlinkLogHandler::LOG_FILEPATH_SIZE == 256, "Update LOG_FILEPATH_SCANF_WIDTH if LOG_FILEPATH_SIZE changes");
MavlinkLogHandler::MavlinkLogHandler(Mavlink &mavlink)
: _mavlink(mavlink)