From e8d274cebb9b40f9116868a5229d6db81f64ab64 Mon Sep 17 00:00:00 2001 From: Kris Burney <burneykb@iastate.edu> Date: Sun, 4 Dec 2016 01:11:01 -0600 Subject: [PATCH] Adding argc checking to getpid and setpid --- groundStation/src/cli/cli_getpid.c | 7 ++++++- groundStation/src/cli/cli_setpid.c | 5 +++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/groundStation/src/cli/cli_getpid.c b/groundStation/src/cli/cli_getpid.c index c95ad1248..c57d42a52 100644 --- a/groundStation/src/cli/cli_getpid.c +++ b/groundStation/src/cli/cli_getpid.c @@ -42,7 +42,7 @@ int cli_getpid(struct backend_conn * conn, int argc, char **argv) { } } - if(needHelp) { + if (needHelp) { printf("Getpid gets the p, i , or d constant values of any single controller\n"); printf("Usage Syntax : \n\t./Cli getpid controller [options...]\n"); printf("Symlink Usage Syntax : \n\t./getpid controller [options...]\n\n"); @@ -57,6 +57,11 @@ int cli_getpid(struct backend_conn * conn, int argc, char **argv) { return 0; } + if (argc < 2) { + printf("Incorrect Usage, run './cli getpid --help' for correct usage.\n"); + return 1; + } + int result; if(getAll) { pid_data.controller = PID_ROLL; diff --git a/groundStation/src/cli/cli_setpid.c b/groundStation/src/cli/cli_setpid.c index cbe6f9332..f9c54c063 100644 --- a/groundStation/src/cli/cli_setpid.c +++ b/groundStation/src/cli/cli_setpid.c @@ -73,6 +73,11 @@ int cli_setpid(struct backend_conn * conn, int argc, char **argv) { return 0; } + if (argc < 2) { + printf("Incorrect Usage, run './cli setpid --help' for correct usage.\n"); + return 1; + } + if (setRoll) { pid_data.controller = PID_ROLL; } else if (setYaw) { -- GitLab