Skip to content

fix(ci): enable clang-tidy misc-unused-parameter#26981

Open
kuralme wants to merge 1 commit intoPX4:mainfrom
kuralme:clang-tidy-fix/misc-unused-parameters
Open

fix(ci): enable clang-tidy misc-unused-parameter#26981
kuralme wants to merge 1 commit intoPX4:mainfrom
kuralme:clang-tidy-fix/misc-unused-parameters

Conversation

@kuralme
Copy link
Copy Markdown
Contributor

@kuralme kuralme commented Apr 6, 2026

Solved Problem

Fixes a Tier 1(?) item from #26442 .
Addresses many violations across the codebase by enabling misc-unused-parameter, improving code quality and maintainability. Changes involve mostly disabling unused argc & *argv[] parameters.

Solution

  • Removed -misc-unused-parameter  from the .clang-tidy configuration file.
  • C++ Fixes:
    • Added [[maybe_unused]] for parameters that are used conditionally (e.g., inside #ifdef blocks).
    • Commented out parameter names in function signatures (e.g., int main(int /*argc*/, char ** /*argv*/)) for mandatory overrides where the body does not use the data.
  • C Fixes:
    • Applied (void)variable casting at the start of functions to suppress warnings while maintaining C compatibility.

Changelog Entry

For release notes:

Refactor: Enable clang-tidy unused parameter check and resolve existing violations

Alternatives

Test coverage

Verified locally using the PX4 Dev Docker container:

make px4_sitl_default-clang clang-tidy

and

make quick_check

Confirmed that the 297 violations are resolved and no new errors are introduced.

Context

Follow-up to the CI infrastructure improvements in #26367 .

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR re-enables the clang-tidy misc-unused-parameters check by removing its exclusion from .clang-tidy, and then resolves the resulting warnings across the codebase by explicitly marking intentionally-unused parameters (C++: [[maybe_unused]] or elided parameter names; C: (void)parameter).

Changes:

  • Enable clang-tidy unused-parameter diagnostics by updating .clang-tidy.
  • Mechanically suppress unused-parameter warnings across many modules/libraries (CLI entrypoints, callbacks, overrides, helpers).
  • Use a mix of [[maybe_unused]], unnamed parameters, and C-style (void) casts depending on language/context.

Reviewed changes

Copilot reviewed 164 out of 164 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/systemcmds/shutdown/shutdown.cpp Suppress unused CLI args for shutdown command entrypoint.
src/systemcmds/param/param.cpp Suppress unused callback argument parameter.
src/systemcmds/bsondump/bsondump.cpp Suppress unused BSON decoder parameters in callbacks.
src/modules/vtol_att_control/vtol_att_control_main.cpp Suppress unused CLI args in ModuleBase hooks.
src/modules/uxrce_dds_client/uxrce_dds_client.cpp Suppress unused callback/CLI parameters for uXRCE DDS client.
src/modules/uxrce_dds_client/srv_base.cpp Suppress unused constructor/argument parameters in service base.
src/modules/uuv_pos_control/uuv_pos_control.cpp Suppress unused parameters in UUV position control module hooks.
src/modules/uuv_att_control/uuv_att_control.cpp Suppress unused parameters in UUV attitude control module hooks.
src/modules/temperature_compensation/TemperatureCompensationModule.cpp Suppress unused CLI args in task spawn.
src/modules/temperature_compensation/temperature_calibration/task.cpp Suppress unused CLI args in calibration entrypoint.
src/modules/simulation/system_power_simulator/SystemPowerSimulator.cpp Suppress unused CLI args in simulator module hooks.
src/modules/simulation/simulator_sih/sih.cpp Suppress unused parameters in SIH simulator module hooks.
src/modules/simulation/sensor_mag_sim/SensorMagSim.cpp Suppress unused CLI args in sim sensor module hooks.
src/modules/simulation/sensor_gps_sim/SensorGpsSim.cpp Suppress unused CLI args in sim sensor module hooks.
src/modules/simulation/sensor_baro_sim/SensorBaroSim.cpp Suppress unused CLI args in sim sensor module hooks.
src/modules/simulation/sensor_airspeed_sim/SensorAirspeedSim.cpp Suppress unused CLI args in sim sensor module hooks.
src/modules/simulation/sensor_agp_sim/SensorAgpSim.cpp Suppress unused CLI args in sim sensor module hooks.
src/modules/simulation/pwm_out_sim/PWMSim.cpp Suppress unused CLI args in custom_command.
src/modules/simulation/battery_simulator/BatterySimulator.cpp Suppress unused CLI args in simulator module hooks.
src/modules/sensors/sensors.cpp Suppress unused CLI args in custom_command.
src/modules/rover_mecanum/RoverMecanum.cpp Suppress unused CLI args in rover module hooks.
src/modules/rover_differential/RoverDifferential.cpp Suppress unused CLI args in rover module hooks.
src/modules/rover_ackermann/RoverAckermann.cpp Suppress unused CLI args in rover module hooks.
src/modules/rover_ackermann/AckermannDriveModes/AckermannAutoMode/AckermannAutoMode.cpp Suppress unused parameters in Ackermann auto mode helper.
src/modules/replay/Replay.cpp Suppress unused parameters in replay helpers/ModuleBase instantiate.
src/modules/rc_update/rc_update.cpp Suppress unused CLI args in RCUpdate module hooks.
src/modules/payload_deliverer/payload_deliverer.cpp Suppress unused CLI args in task spawn.
src/modules/navigator/navigator_main.cpp Suppress unused parameters in navigator module hooks.
src/modules/navigator/MissionFeasibility/FeasibilityChecker.cpp Suppress unused index parameters in feasibility checks.
src/modules/navigator/mission_block.cpp Suppress unused land precision parameter.
src/modules/navigator/mission_base.cpp Suppress unused execute_jump parameter in position item navigation.
src/modules/navigator/GeofenceBreachAvoidance/geofence_breach_avoidance.cpp Suppress unused altitude parameter in home position setter.
src/modules/navigator/geofence.cpp Suppress unused altitude/filename parameters in geofence helpers.
src/modules/mc_rate_control/MulticopterRateControl.cpp Suppress unused CLI args in custom_command.
src/modules/mc_pos_control/Takeoff/Takeoff.cpp Suppress unused takeoff desired vertical speed parameter.
src/modules/mc_pos_control/MulticopterPositionControl.cpp Suppress unused CLI args in custom_command.
src/modules/mc_hover_thrust_estimator/MulticopterHoverThrustEstimator.cpp Suppress unused CLI args in module hooks.
src/modules/mc_autotune_attitude_control/mc_autotune_attitude_control.cpp Suppress unused CLI args in module hooks.
src/modules/mc_att_control/mc_att_control_main.cpp Suppress unused CLI args in custom_command.
src/modules/manual_control/ManualControl.cpp Suppress unused CLI args in module hooks.
src/modules/mag_bias_estimator/MagBiasEstimator.hpp Suppress unused CLI args in inline custom_command.
src/modules/mag_bias_estimator/MagBiasEstimator.cpp Suppress unused CLI args in task spawn.
src/modules/logger/watchdog.cpp Mark parameters maybe-unused for conditional compilation paths.
src/modules/logger/logger.cpp Suppress unused CLI args and conditionally-unused parameters.
src/modules/logger/log_writer_file.cpp Mark parameter maybe-unused for conditional compilation paths.
src/modules/local_position_estimator/BlockLocalPositionEstimator.cpp Suppress unused params in dynamics and module hooks.
src/modules/load_mon/LoadMon.hpp Suppress unused CLI args in inline custom_command.
src/modules/load_mon/LoadMon.cpp Suppress unused CLI args in task spawn.
src/modules/landing_target_estimator/landing_target_estimator_main.cpp Suppress unused CLI args in thread main.
src/modules/gyro_fft/GyroFFT.cpp Suppress unused CLI args in module hooks.
src/modules/gyro_calibration/GyroCalibration.cpp Suppress unused CLI args in module hooks.
src/modules/gimbal/input_test.cpp Suppress unused parameters in gimbal input test implementation.
src/modules/gimbal/input_mavlink.cpp Suppress unused already_active parameter in gimbal MAVLink inputs.
src/modules/gimbal/gimbal.cpp Suppress unused CLI args in gimbal thread entrypoint.
src/modules/fw_rate_control/FixedwingRateControl.cpp Suppress unused CLI args in custom_command.
src/modules/fw_mode_manager/FixedWingModeManager.cpp Suppress unused parameters across FW mode manager methods and hooks.
src/modules/fw_lateral_longitudinal_control/FwLateralLongitudinalControl.cpp Suppress unused control interval in TECS update wrapper; unused CLI args in custom_command.
src/modules/fw_autotune_attitude_control/fw_autotune_attitude_control.cpp Suppress unused CLI args in custom_command.
src/modules/fw_att_control/FixedwingAttitudeControl.cpp Suppress unused CLI args in custom_command.
src/modules/flight_mode_manager/tasks/Utility/StickAccelerationXY.cpp Suppress unused dt parameter in lockPosition.
src/modules/flight_mode_manager/tasks/ManualAltitudeSmoothVel/FlightTaskManualAltitudeSmoothVel.cpp Suppress unused EKF reset deltas.
src/modules/flight_mode_manager/tasks/ManualAltitude/FlightTaskManualAltitude.cpp Suppress unused EKF reset HAGL delta.
src/modules/flight_mode_manager/tasks/ManualAcceleration/FlightTaskManualAcceleration.cpp Suppress unused EKF reset delta parameter.
src/modules/flight_mode_manager/tasks/FlightTask/FlightTask.hpp Suppress unused default-impl parameters in base virtual method.
src/modules/flight_mode_manager/tasks/FlightTask/FlightTask.cpp Suppress unused last_setpoint parameter in base activate.
src/modules/flight_mode_manager/tasks/Auto/FlightTaskAuto.cpp Suppress unused EKF reset deltas.
src/modules/flight_mode_manager/FlightModeManager.cpp Suppress unused params and CLI args in module hooks.
src/modules/events/send_event.cpp Suppress unused CLI args in module hooks.
src/modules/ekf2/EKF2.cpp Suppress unused timestamp-arg parameters in conditional EKF2 helpers; unused CLI args in custom_command.
src/modules/ekf2/EKF/output_predictor/output_predictor.cpp Suppress unused vertical position change parameter.
src/modules/ekf2/EKF/ekf_helper.cpp Suppress unused vpos variance argument.
src/modules/ekf2/EKF/aid_sources/sideslip/sideslip_fusion.cpp Suppress unused IMU sample parameter.
src/modules/ekf2/EKF/aid_sources/range_finder/sensor_range_finder.cpp Suppress unused time parameter.
src/modules/ekf2/EKF/aid_sources/external_vision/ev_yaw_control.cpp Suppress unused IMU sample parameter.
src/modules/ekf2/EKF/aid_sources/external_vision/ev_pos_control.cpp Suppress unused IMU sample parameter.
src/modules/ekf2/EKF/aid_sources/external_vision/ev_height_control.cpp Suppress unused IMU sample parameter.
src/modules/dataman/dataman.cpp Suppress unused CLI args in dataman task main.
src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessUUV.cpp Suppress unused parameters in setpoint update.
src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTiltrotorVTOL.cpp Suppress unused control_sp parameter in setpoint update.
src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessTailsitterVTOL.cpp Suppress unused parameters in setpoint update.
src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessStandardVTOL.cpp Suppress unused parameters in setpoint update.
src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessRoverAckermann.cpp Suppress unused parameters in setpoint update.
src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessMCTilt.cpp Suppress unused matrix index/control_sp params in helpers.
src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessHelicopterCoaxial.cpp Suppress unused matrix index parameter in setpoint update; unused index in helper.
src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessHelicopter.cpp Suppress unused matrix index parameter in setpoint update; unused index in helper.
src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessFixedWing.cpp Suppress unused parameters in setpoint update; unused matrix index in auxiliary allocation.
src/modules/control_allocator/VehicleActuatorEffectiveness/ActuatorEffectivenessCustom.cpp Suppress unused parameters in setpoint update.
src/modules/control_allocator/ControlAllocator.cpp Suppress unused CLI args in module hooks.
src/modules/commander/HealthAndArmingChecks/Common.hpp Suppress unused parameters in event reporting template.
src/modules/commander/HealthAndArmingChecks/checks/vtolCheck.cpp Suppress unused context parameter in check implementation.
src/modules/commander/HealthAndArmingChecks/checks/sdcardCheck.cpp Suppress unused context parameter in check implementation.
src/modules/commander/HealthAndArmingChecks/checks/rallyPointCheck.cpp Suppress unused context parameter in check implementation.
src/modules/commander/HealthAndArmingChecks/checks/opticalFlowCheck.cpp Suppress unused context parameter in check implementation.
src/modules/commander/HealthAndArmingChecks/checks/offboardCheck.cpp Suppress unused context parameter in check implementation.
src/modules/commander/HealthAndArmingChecks/checks/missionCheck.cpp Suppress unused context parameter in check implementation.
src/modules/commander/HealthAndArmingChecks/checks/magnetometerCheck.cpp Suppress unused context parameter in consistency check.
src/modules/commander/HealthAndArmingChecks/checks/loggerCheck.cpp Suppress unused context parameter in check implementation.
src/modules/commander/HealthAndArmingChecks/checks/homePositionCheck.cpp Suppress unused context parameter in check implementation.
src/modules/commander/HealthAndArmingChecks/checks/geofenceCheck.cpp Suppress unused context parameter in check implementation.
src/modules/commander/HealthAndArmingChecks/checks/failureDetectorCheck.cpp Suppress unused context parameter in check implementation.
src/modules/commander/HealthAndArmingChecks/checks/estimatorCheck.cpp Suppress unused context/status parameters in check helpers.
src/modules/commander/HealthAndArmingChecks/checks/distanceSensorChecks.cpp Suppress unused context parameter in check implementation.
src/modules/commander/HealthAndArmingChecks/checks/cpuResourceCheck.cpp Suppress unused context parameter in check implementation.
src/modules/commander/HealthAndArmingChecks/checks/baroCheck.cpp Suppress unused context parameter in check implementation.
src/modules/commander/HealthAndArmingChecks/checks/armPermissionCheck.cpp Suppress unused context parameter in check implementation.
src/modules/commander/failsafe/framework.cpp Suppress unused state parameter in delay clearing helper.
src/modules/commander/Commander.cpp Suppress unused argc in task spawn.
src/modules/camera_feedback/CameraFeedback.cpp Suppress unused CLI args in module hooks.
src/modules/attitude_estimator_q/attitude_estimator_q_main.cpp Suppress unused CLI args in module hooks.
src/modules/airspeed_selector/AirspeedValidator.cpp Suppress unused vertical variance parameter in wind estimator update.
src/modules/airspeed_selector/airspeed_selector_main.cpp Suppress unused CLI args in task spawn.
src/modules/airship_att_control/airship_att_control_main.cpp Suppress unused CLI args in module hooks.
src/lib/variable_length_ringbuffer/VariableLengthRingbuffer.cpp Mark buffer length param maybe-unused (assert-only usage).
src/lib/terrain_estimation/terrain_estimator.cpp Suppress unused distance parameter in predict step.
src/lib/tecs/TECS.cpp Suppress unused pitch parameter in TECS update.
src/lib/rc/sbus.cpp Mark legacy/optional parameters maybe-unused in RC parsing/config.
src/lib/rc/ghst.cpp Suppress unused timestamp parameter in parse.
src/lib/rc/dsm.cpp Suppress unused frame drop counter parameter in DSM input.
src/lib/rc/crsf.cpp Suppress unused timestamp parameter in parse.
src/lib/parameters/parameters.cpp Suppress unused parameters in stubbed flash helpers/callbacks and default args.
src/lib/npfg/DirectionalGuidance.cpp Suppress unused parameters in guidance helpers.
src/lib/motion_planning/PositionSmoothing.cpp Suppress unused position parameter in internal L1 helper.
src/lib/mixer_module/functions/FunctionServos.hpp Suppress unused function selector parameter.
src/lib/mixer_module/functions/FunctionProviderBase.hpp Suppress unused parameters in default virtual implementations.
src/lib/mixer_module/functions/FunctionParachute.hpp Suppress unused context/function parameters in simple provider.
src/lib/mixer_module/functions/FunctionManualRC.hpp Suppress unused context parameter in allocator.
src/lib/mixer_module/functions/FunctionLandingGearWheel.hpp Suppress unused function parameter in provider.
src/lib/mixer_module/functions/FunctionLandingGear.hpp Suppress unused function parameter in provider.
src/lib/mixer_module/functions/FunctionICEngineControl.hpp Suppress unused context parameter in allocator.
src/lib/mixer_module/functions/FunctionGripper.hpp Suppress unused function parameter in provider.
src/lib/mixer_module/functions/FunctionGimbal.hpp Suppress unused context parameter in allocator.
src/lib/mixer_module/functions/FunctionConstantMin.hpp Suppress unused context/function parameters in constant provider.
src/lib/mixer_module/functions/FunctionConstantMax.hpp Suppress unused context/function parameters in constant provider.
src/lib/mixer_module/functions/FunctionActuatorSet.hpp Suppress unused context parameter in allocator.
src/lib/matrix/matrix/SquareMatrix.hpp Mark defaulted rank parameter maybe-unused in 1x1 inverse specialization.
src/lib/drivers/device/Device.hpp Suppress unused parameters in base-class stubbed virtual methods.
src/lib/drivers/device/CDev.hpp Suppress unused parameters in default ioctl override.
src/lib/controllib/controllib_test/controllib_test_main.cpp Suppress unused CLI args in test entrypoint.
src/lib/control_allocation/control_allocation/ControlAllocation.cpp Suppress unused update_normalization_scale parameter.
src/lib/control_allocation/actuator_effectiveness/ActuatorEffectiveness.hpp Suppress unused parameters in default virtual stub.
src/lib/cdev/test/cdevtest_example.cpp Suppress unused CLI args and unused handle parameter in test example.
src/lib/cdev/posix/cdev_platform.cpp Suppress unused constructor/method parameters and register_driver fops/mode.
src/lib/cdev/CDev.hpp Suppress unused parameters in base-class stubbed virtual methods.
src/include/unit_test.h Suppress unused argc/argv in C unit test macro wrapper.
src/drivers/tone_alarm/ToneAlarm.cpp Suppress unused ISR arg and unused CLI args in task spawn.
src/drivers/osd/msp_osd/MspV1.cpp Suppress unused message_type parameter.
src/drivers/gps/gps.cpp Suppress unused argc in task spawn overload.
src/drivers/gnss/septentrio/septentrio.cpp Suppress unused argc in task spawn overload.
platforms/posix/src/px4/generic/generic/tone_alarm/ToneAlarmInterface.cpp Suppress unused frequency parameter in sim stub.
platforms/posix/src/px4/common/tasks.cpp Suppress unused pid parameter.
platforms/posix/src/px4/common/px4_sem.cpp Suppress unused parameters in stub implementation.
platforms/posix/src/px4/common/px4_posix_impl.cpp Suppress unused argc/argv in init.
platforms/posix/src/px4/common/print_load.cpp Suppress unused print_state parameter.
platforms/posix/src/px4/common/main.cpp Suppress unused signal number parameter.
platforms/posix/src/px4/common/drv_hrt.cpp Suppress unused ISR argument.
platforms/common/work_queue/work_thread.c Cast unused argc/argv to void in worker threads (C).
platforms/common/work_queue/hrt_thread.c Cast unused argc/argv to void in HRT thread (C).
platforms/common/uORB/uORBDeviceNode.cpp Suppress unused file handle parameter in write.
platforms/common/uORB/uORB_tests/uORBTest_UnitTest.cpp Suppress unused CLI args in test thread entrypoints.
platforms/common/shutdown.cpp Suppress unused shutdown worker argument.
platforms/common/module.cpp Suppress unused category/min/max parameters in usage helpers.
platforms/common/apps.cpp.in Suppress unused CLI args in builtin apps entrypoints.
boards/px4/sitl/src/board_shutdown.cpp Suppress unused callback/status parameters in SITL stubs.
.clang-tidy Re-enable misc-unused-parameters by removing its exclusion.

@github-actions
Copy link
Copy Markdown

No broken links found in changed files.

@kuralme
Copy link
Copy Markdown
Contributor Author

kuralme commented Apr 10, 2026

I didnt meant to add the label

@mrpollo
Copy link
Copy Markdown
Contributor

mrpollo commented Apr 10, 2026

@kuralme I think you have to clean your branch, its pulling tons of unrelated changes

Signed-off-by: kuralme <kuralme@protonmail.com>

reenabled message param tagged as [[maybe_unused]]

Signed-off-by: kuralme <kuralme@protonmail.com>
@kuralme kuralme force-pushed the clang-tidy-fix/misc-unused-parameters branch from 6899c1e to bd33675 Compare April 10, 2026 22:37
@mrpollo mrpollo requested a review from Copilot April 11, 2026 01:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 164 out of 164 changed files in this pull request and generated 2 comments.

Comment on lines 528 to 532
int
Geofence::loadFromFile(const char *filename)
Geofence::loadFromFile(const char * /*filename*/)
{
FILE *fp;
char line[120];
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Geofence::loadFromFile(const char *filename) now explicitly marks filename unused, but the implementation still always opens GEOFENCE_FILENAME (see fopen(GEOFENCE_FILENAME, "r") a few lines below). This makes the filename argument (and callers like Navigator::load_fence_from_file(const char *filename)) ineffective and contradicts the API contract documented in geofence.h. Consider using the passed-in filename for fopen() (and log/return an error including that path), or remove the parameter and update callers/docs accordingly.

Copilot uses AI. Check for mistakes.
Comment on lines 87 to 91
bool SrvBase::create_replier(uxrStreamId input_stream_id,
uxrObjectId participant_id, uint16_t index, const char *client_namespace, const char *service_name_simple,
const char *service_type_name_simple, uint16_t queue_depth)
const char *service_type_name_simple, uint16_t /*queue_depth*/)
{
// request and reply names
Copy link

Copilot AI Apr 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SrvBase::create_replier(...) takes a queue_depth argument, and callers compute it (e.g. based on orb_get_queue_size(...)), but the function currently ignores it and hardcodes uxrQoS_t.depth = 1. This defeats the intent of sizing the DDS replier history/queue and can cause avoidable sample drops under bursty traffic. Suggest wiring queue_depth into qos.depth (with a reasonable upper bound if needed) or removing the parameter and simplifying callers if depth must always be 1.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants