From 2e824bbeea8787a3166ce47cad90e622a3678b25 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Tue, 17 Mar 2015 13:37:01 -0400 Subject: [PATCH] fix incorrect argc < 1 check for no arguments -requiring arguments should be argc < 2 --- src/drivers/ardrone_interface/ardrone_interface.c | 3 ++- src/drivers/hott/hott_sensors/hott_sensors.cpp | 2 +- src/drivers/hott/hott_telemetry/hott_telemetry.cpp | 2 +- src/drivers/md25/md25_main.cpp | 3 ++- src/drivers/roboclaw/roboclaw_main.cpp | 3 ++- src/examples/fixedwing_control/main.c | 2 +- .../flow_position_estimator/flow_position_estimator_main.c | 2 +- src/examples/matlab_csv_serial/matlab_csv_serial.c | 2 +- src/examples/publisher/publisher_start_nuttx.cpp | 2 +- src/examples/px4_daemon_app/px4_daemon_app.c | 2 +- src/examples/rover_steering_control/main.cpp | 2 +- src/examples/subscriber/subscriber_start_nuttx.cpp | 2 +- .../attitude_estimator_ekf/attitude_estimator_ekf_main.cpp | 3 ++- .../attitude_estimator_so3/attitude_estimator_so3_main.cpp | 3 ++- src/modules/commander/commander.cpp | 2 +- .../ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp | 2 +- src/modules/fixedwing_backside/fixedwing_backside_main.cpp | 3 ++- src/modules/fw_att_control/fw_att_control_main.cpp | 3 ++- src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp | 3 ++- src/modules/land_detector/land_detector_main.cpp | 2 +- src/modules/mc_att_control/mc_att_control_main.cpp | 3 ++- .../mc_att_control_start_nuttx.cpp | 2 +- src/modules/mc_pos_control/mc_pos_control_main.cpp | 2 +- .../mc_pos_control_start_nuttx.cpp | 2 +- .../position_estimator_inav/position_estimator_inav_main.c | 2 +- src/modules/segway/segway_main.cpp | 3 ++- src/modules/sensors/sensors.cpp | 2 +- src/modules/vtol_att_control/vtol_att_control_main.cpp | 2 +- 28 files changed, 38 insertions(+), 28 deletions(-) diff --git a/src/drivers/ardrone_interface/ardrone_interface.c b/src/drivers/ardrone_interface/ardrone_interface.c index 7d4b7d880b..53d98ba9a1 100644 --- a/src/drivers/ardrone_interface/ardrone_interface.c +++ b/src/drivers/ardrone_interface/ardrone_interface.c @@ -108,8 +108,9 @@ usage(const char *reason) */ int ardrone_interface_main(int argc, char *argv[]) { - if (argc < 1) + if (argc < 2) { usage("missing command"); + } if (!strcmp(argv[1], "start")) { diff --git a/src/drivers/hott/hott_sensors/hott_sensors.cpp b/src/drivers/hott/hott_sensors/hott_sensors.cpp index 1aade450b1..4ac7e4bdfb 100644 --- a/src/drivers/hott/hott_sensors/hott_sensors.cpp +++ b/src/drivers/hott/hott_sensors/hott_sensors.cpp @@ -197,7 +197,7 @@ hott_sensors_thread_main(int argc, char *argv[]) int hott_sensors_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { errx(1, "missing command\n%s", commandline_usage); } diff --git a/src/drivers/hott/hott_telemetry/hott_telemetry.cpp b/src/drivers/hott/hott_telemetry/hott_telemetry.cpp index 17a24d1041..43df0cb8cc 100644 --- a/src/drivers/hott/hott_telemetry/hott_telemetry.cpp +++ b/src/drivers/hott/hott_telemetry/hott_telemetry.cpp @@ -223,7 +223,7 @@ hott_telemetry_thread_main(int argc, char *argv[]) int hott_telemetry_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { errx(1, "missing command\n%s", commandline_usage); } diff --git a/src/drivers/md25/md25_main.cpp b/src/drivers/md25/md25_main.cpp index 7e5904d050..d25d16fa15 100644 --- a/src/drivers/md25/md25_main.cpp +++ b/src/drivers/md25/md25_main.cpp @@ -97,8 +97,9 @@ usage(const char *reason) int md25_main(int argc, char *argv[]) { - if (argc < 1) + if (argc < 2) { usage("missing command"); + } if (!strcmp(argv[1], "start")) { diff --git a/src/drivers/roboclaw/roboclaw_main.cpp b/src/drivers/roboclaw/roboclaw_main.cpp index 83086fd7c8..ea7178076b 100644 --- a/src/drivers/roboclaw/roboclaw_main.cpp +++ b/src/drivers/roboclaw/roboclaw_main.cpp @@ -92,8 +92,9 @@ static void usage() int roboclaw_main(int argc, char *argv[]) { - if (argc < 1) + if (argc < 2) { usage(); + } if (!strcmp(argv[1], "start")) { diff --git a/src/examples/fixedwing_control/main.c b/src/examples/fixedwing_control/main.c index 17b27290c2..1d590ae61c 100644 --- a/src/examples/fixedwing_control/main.c +++ b/src/examples/fixedwing_control/main.c @@ -418,7 +418,7 @@ usage(const char *reason) */ int ex_fixedwing_control_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { usage("missing command"); } diff --git a/src/examples/flow_position_estimator/flow_position_estimator_main.c b/src/examples/flow_position_estimator/flow_position_estimator_main.c index f8e3f2dc5f..ab67bd2532 100644 --- a/src/examples/flow_position_estimator/flow_position_estimator_main.c +++ b/src/examples/flow_position_estimator/flow_position_estimator_main.c @@ -99,7 +99,7 @@ static void usage(const char *reason) */ int flow_position_estimator_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { usage("missing command"); } diff --git a/src/examples/matlab_csv_serial/matlab_csv_serial.c b/src/examples/matlab_csv_serial/matlab_csv_serial.c index 8e439bdac5..085ef1fed7 100644 --- a/src/examples/matlab_csv_serial/matlab_csv_serial.c +++ b/src/examples/matlab_csv_serial/matlab_csv_serial.c @@ -91,7 +91,7 @@ static void usage(const char *reason) */ int matlab_csv_serial_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { usage("missing command"); } diff --git a/src/examples/publisher/publisher_start_nuttx.cpp b/src/examples/publisher/publisher_start_nuttx.cpp index 405b3c987f..4ff2cebfbc 100644 --- a/src/examples/publisher/publisher_start_nuttx.cpp +++ b/src/examples/publisher/publisher_start_nuttx.cpp @@ -54,7 +54,7 @@ extern int main(int argc, char **argv); extern "C" __EXPORT int publisher_main(int argc, char *argv[]); int publisher_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { errx(1, "usage: publisher {start|stop|status}"); } diff --git a/src/examples/px4_daemon_app/px4_daemon_app.c b/src/examples/px4_daemon_app/px4_daemon_app.c index 860b1af787..6e99939d14 100644 --- a/src/examples/px4_daemon_app/px4_daemon_app.c +++ b/src/examples/px4_daemon_app/px4_daemon_app.c @@ -88,7 +88,7 @@ usage(const char *reason) */ int px4_daemon_app_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { usage("missing command"); } diff --git a/src/examples/rover_steering_control/main.cpp b/src/examples/rover_steering_control/main.cpp index 96b40b23f0..41df96775c 100644 --- a/src/examples/rover_steering_control/main.cpp +++ b/src/examples/rover_steering_control/main.cpp @@ -412,7 +412,7 @@ usage(const char *reason) */ int rover_steering_control_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { usage("missing command"); } diff --git a/src/examples/subscriber/subscriber_start_nuttx.cpp b/src/examples/subscriber/subscriber_start_nuttx.cpp index b450230c1a..757e8ec521 100644 --- a/src/examples/subscriber/subscriber_start_nuttx.cpp +++ b/src/examples/subscriber/subscriber_start_nuttx.cpp @@ -54,7 +54,7 @@ extern int main(int argc, char **argv); extern "C" __EXPORT int subscriber_main(int argc, char *argv[]); int subscriber_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { errx(1, "usage: subscriber {start|stop|status}"); } diff --git a/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp b/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp index c60d70b9f8..9bb9393c5d 100755 --- a/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp +++ b/src/modules/attitude_estimator_ekf/attitude_estimator_ekf_main.cpp @@ -118,8 +118,9 @@ usage(const char *reason) */ int attitude_estimator_ekf_main(int argc, char *argv[]) { - if (argc < 1) + if (argc < 2) { usage("missing command"); + } if (!strcmp(argv[1], "start")) { diff --git a/src/modules/attitude_estimator_so3/attitude_estimator_so3_main.cpp b/src/modules/attitude_estimator_so3/attitude_estimator_so3_main.cpp index 9414225ca0..82bcbc66ff 100755 --- a/src/modules/attitude_estimator_so3/attitude_estimator_so3_main.cpp +++ b/src/modules/attitude_estimator_so3/attitude_estimator_so3_main.cpp @@ -136,8 +136,9 @@ usage(const char *reason) */ int attitude_estimator_so3_main(int argc, char *argv[]) { - if (argc < 1) + if (argc < 2) { usage("missing command"); + } if (!strcmp(argv[1], "start")) { diff --git a/src/modules/commander/commander.cpp b/src/modules/commander/commander.cpp index 453d5f9212..2722766b01 100644 --- a/src/modules/commander/commander.cpp +++ b/src/modules/commander/commander.cpp @@ -261,7 +261,7 @@ void answer_command(struct vehicle_command_s &cmd, enum VEHICLE_CMD_RESULT resul int commander_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { usage("missing command"); } diff --git a/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp b/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp index c16e72ea0b..33289dacb0 100644 --- a/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp +++ b/src/modules/ekf_att_pos_estimator/ekf_att_pos_estimator_main.cpp @@ -1516,7 +1516,7 @@ int AttitudePositionEstimatorEKF::trip_nan() int ekf_att_pos_estimator_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { errx(1, "usage: ekf_att_pos_estimator {start|stop|status|logging}"); } diff --git a/src/modules/fixedwing_backside/fixedwing_backside_main.cpp b/src/modules/fixedwing_backside/fixedwing_backside_main.cpp index 71b387b1e7..bd14863247 100644 --- a/src/modules/fixedwing_backside/fixedwing_backside_main.cpp +++ b/src/modules/fixedwing_backside/fixedwing_backside_main.cpp @@ -97,8 +97,9 @@ usage(const char *reason) int fixedwing_backside_main(int argc, char *argv[]) { - if (argc < 1) + if (argc < 2) { usage("missing command"); + } if (!strcmp(argv[1], "start")) { diff --git a/src/modules/fw_att_control/fw_att_control_main.cpp b/src/modules/fw_att_control/fw_att_control_main.cpp index 8b41144f6f..0a8d07fed9 100644 --- a/src/modules/fw_att_control/fw_att_control_main.cpp +++ b/src/modules/fw_att_control/fw_att_control_main.cpp @@ -1134,8 +1134,9 @@ FixedwingAttitudeControl::start() int fw_att_control_main(int argc, char *argv[]) { - if (argc < 1) + if (argc < 2) { errx(1, "usage: fw_att_control {start|stop|status}"); + } if (!strcmp(argv[1], "start")) { diff --git a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp index 427df9739d..34265d6a4e 100644 --- a/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp +++ b/src/modules/fw_pos_control_l1/fw_pos_control_l1_main.cpp @@ -1638,8 +1638,9 @@ FixedwingPositionControl::start() int fw_pos_control_l1_main(int argc, char *argv[]) { - if (argc < 1) + if (argc < 2) { errx(1, "usage: fw_pos_control_l1 {start|stop|status}"); + } if (!strcmp(argv[1], "start")) { diff --git a/src/modules/land_detector/land_detector_main.cpp b/src/modules/land_detector/land_detector_main.cpp index 011567e577..b4b7c33a20 100644 --- a/src/modules/land_detector/land_detector_main.cpp +++ b/src/modules/land_detector/land_detector_main.cpp @@ -178,7 +178,7 @@ static int land_detector_start(const char *mode) int land_detector_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { goto exiterr; } diff --git a/src/modules/mc_att_control/mc_att_control_main.cpp b/src/modules/mc_att_control/mc_att_control_main.cpp index b8c1437821..3a0dfe4c3b 100644 --- a/src/modules/mc_att_control/mc_att_control_main.cpp +++ b/src/modules/mc_att_control/mc_att_control_main.cpp @@ -922,8 +922,9 @@ MulticopterAttitudeControl::start() int mc_att_control_main(int argc, char *argv[]) { - if (argc < 1) + if (argc < 2) { errx(1, "usage: mc_att_control {start|stop|status}"); + } if (!strcmp(argv[1], "start")) { diff --git a/src/modules/mc_att_control_multiplatform/mc_att_control_start_nuttx.cpp b/src/modules/mc_att_control_multiplatform/mc_att_control_start_nuttx.cpp index 40eb498b49..dec1e1745d 100644 --- a/src/modules/mc_att_control_multiplatform/mc_att_control_start_nuttx.cpp +++ b/src/modules/mc_att_control_multiplatform/mc_att_control_start_nuttx.cpp @@ -54,7 +54,7 @@ extern int main(int argc, char **argv); extern "C" __EXPORT int mc_att_control_m_main(int argc, char *argv[]); int mc_att_control_m_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { errx(1, "usage: mc_att_control_m {start|stop|status}"); } diff --git a/src/modules/mc_pos_control/mc_pos_control_main.cpp b/src/modules/mc_pos_control/mc_pos_control_main.cpp index 4910454bd9..5191a4de3b 100644 --- a/src/modules/mc_pos_control/mc_pos_control_main.cpp +++ b/src/modules/mc_pos_control/mc_pos_control_main.cpp @@ -1440,7 +1440,7 @@ MulticopterPositionControl::start() int mc_pos_control_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { errx(1, "usage: mc_pos_control {start|stop|status}"); } diff --git a/src/modules/mc_pos_control_multiplatform/mc_pos_control_start_nuttx.cpp b/src/modules/mc_pos_control_multiplatform/mc_pos_control_start_nuttx.cpp index 1082061f64..0db67d83ff 100644 --- a/src/modules/mc_pos_control_multiplatform/mc_pos_control_start_nuttx.cpp +++ b/src/modules/mc_pos_control_multiplatform/mc_pos_control_start_nuttx.cpp @@ -54,7 +54,7 @@ extern int main(int argc, char **argv); extern "C" __EXPORT int mc_pos_control_m_main(int argc, char *argv[]); int mc_pos_control_m_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { errx(1, "usage: mc_pos_control_m {start|stop|status}"); } diff --git a/src/modules/position_estimator_inav/position_estimator_inav_main.c b/src/modules/position_estimator_inav/position_estimator_inav_main.c index ec297e7f0c..437395b1f1 100644 --- a/src/modules/position_estimator_inav/position_estimator_inav_main.c +++ b/src/modules/position_estimator_inav/position_estimator_inav_main.c @@ -134,7 +134,7 @@ static void usage(const char *reason) */ int position_estimator_inav_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { usage("missing command"); } diff --git a/src/modules/segway/segway_main.cpp b/src/modules/segway/segway_main.cpp index ee492f85a2..b36d56d6d7 100644 --- a/src/modules/segway/segway_main.cpp +++ b/src/modules/segway/segway_main.cpp @@ -92,8 +92,9 @@ usage(const char *reason) int segway_main(int argc, char *argv[]) { - if (argc < 1) + if (argc < 2) { usage("missing command"); + } if (!strcmp(argv[1], "start")) { diff --git a/src/modules/sensors/sensors.cpp b/src/modules/sensors/sensors.cpp index 259361be62..d4692ea7d2 100644 --- a/src/modules/sensors/sensors.cpp +++ b/src/modules/sensors/sensors.cpp @@ -2252,7 +2252,7 @@ Sensors::start() int sensors_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { errx(1, "usage: sensors {start|stop|status}"); } diff --git a/src/modules/vtol_att_control/vtol_att_control_main.cpp b/src/modules/vtol_att_control/vtol_att_control_main.cpp index 74e1efd6cc..defcff8e4a 100644 --- a/src/modules/vtol_att_control/vtol_att_control_main.cpp +++ b/src/modules/vtol_att_control/vtol_att_control_main.cpp @@ -877,7 +877,7 @@ VtolAttitudeControl::start() int vtol_att_control_main(int argc, char *argv[]) { - if (argc < 1) { + if (argc < 2) { errx(1, "usage: vtol_att_control {start|stop|status}"); }