Copter: SystemID: Fix unutilized variables #29194
Open
+2
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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_sample100.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_sample100.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....