mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-12 00:33:37 +08:00
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:
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)
|
||||
|
||||
Reference in New Issue
Block a user