Files
ardupilot/libraries/AR_Motors
Peter BarkerandClaude Opus 5 b3d9979f06 AR_Motors: avoid variable-length array in output_omni()
output_omni() sized a stack buffer by the runtime _motors_num.  VLAs are
non-standard C++, and clang-scan-build cannot correlate the loop which
fills the buffer with the loop which reads it back, so it reports the
read as a garbage value.

Size the buffer to AP_MOTORS_NUM_MOTORS_MAX and zero-initialise it.
setup_omni() only ever sets _motors_num to 3 or 4, and the
_throttle_factor / _steering_factor / _lateral_factor arrays it is
indexed alongside are already that size, so the buffer is large enough;
the initialiser additionally makes the read defined whatever the
analyser assumes about _motors_num.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-27 14:01:54 +10:00
..