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 7d4b7d880b1..53d98ba9a1b 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 1aade450b19..4ac7e4bdfb5 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 17a24d1041a..43df0cb8cce 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 7e5904d0504..d25d16fa15d 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 83086fd7c88..ea7178076b5 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 17b27290c28..1d590ae61ce 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 f8e3f2dc5f4..ab67bd25325 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 8e439bdac55..085ef1fed7c 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 405b3c987f5..4ff2cebfbc1 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 860b1af787f..6e99939d14b 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 96b40b23f07..41df96775c2 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 b450230c1a4..757e8ec521d 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 c60d70b9f85..9bb9393c5d0 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 9414225ca02..82bcbc66ff4 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 453d5f92128..2722766b017 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 c16e72ea0b2..33289dacb07 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 71b387b1e73..bd14863247a 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 8b41144f6f3..0a8d07fed9a 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 427df9739d3..34265d6a4e3 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 011567e577a..b4b7c33a20d 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 b8c14378218..3a0dfe4c3b6 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 40eb498b49a..dec1e1745d7 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 4910454bd97..5191a4de3ba 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 1082061f646..0db67d83ff0 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 ec297e7f0cd..437395b1f12 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 ee492f85a22..b36d56d6d79 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 259361be62c..d4692ea7d2a 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 74e1efd6ccb..defcff8e4ad 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}"); }