Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copter: SystemID: Fix unutilized variables #29194

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lthall
Copy link
Contributor

@lthall lthall commented Jan 30, 2025

This PR addresses a problem found by Peter Barker:

Looking through some static analysis results and came across this one:

../../ArduCopter/mode_systemid.cpp:270:33: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage [core.uninitialized.Assign]
target_roll += waveform_sample100.0f;
~~~~~~~~~~~ ^
../../ArduCopter/mode_systemid.cpp:273:34: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage [core.uninitialized.Assign]
target_pitch += waveform_sample
100.0f;
~~~~~~~~~~~~ ^
../../ArduCopter/mode_systemid.cpp:279:33: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage [core.uninitialized.Assign]
target_roll += waveform_sample100.0f;
~~~~~~~~~~~ ^
../../ArduCopter/mode_systemid.cpp:283:34: warning: The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage [core.uninitialized.Assign]
target_pitch += waveform_sample
100.0f;
~~~~~~~~~~~~ ^
../../ArduCopter/mode_systemid.cpp:352:9: warning: 1st function call argument is an uninitialized value [core.CallAndMessage]
attitude_control->input_euler_angle_roll_pitch_euler_rate_yaw(target_roll, target_pitch, target_yaw_rate);
.
What that's saying is that if this if we don't execute the block gated by if (!is_poscontrol_axis_type()) then both target_roll and target_pitch remain uniniitalised on the stack. Which is bad....

ArduCopter/mode_systemid.cpp Outdated Show resolved Hide resolved
@lthall lthall force-pushed the 20250130_SystemID_InitTargets branch from 240e780 to d7b8b27 Compare January 30, 2025 12:55
@rmackay9 rmackay9 dismissed peterbarker’s stale review January 30, 2025 23:43

PeterB's request addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants