From: Aleksei Vereshchagin Date: Tue, 4 Sep 2018 19:45:29 +0000 (+0300) Subject: More strict options handling X-Git-Tag: submit/tizen/20180911.125435~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=87094da7cdad1d9ad4a09ed765ba70247691502d;p=sdk%2Ftools%2Fprofctl.git More strict options handling --- diff --git a/profctl.c b/profctl.c index 5ddeb01..352cd76 100644 --- a/profctl.c +++ b/profctl.c @@ -209,18 +209,8 @@ static int process_option(int argc, char **argv) { int option_index; - switch (getopt_long(argc, argv, "-a:p:ve:o:it:wc:d:s:", + switch (getopt_long(argc, argv, "+a:p:ve:o:it:wc:d:s:", long_options, &option_index)) { - case 1: - if (appid == NULL) { - appid = optarg; - } else if (pname == NULL) { - pname = optarg; - } else { - log_error("extra argument %s", optarg); - exit(1); - } - break; case 'a': CheckValue(&appid, "appid"); break; case 'p': CheckValue(&pname, "pipe name"); break; case 'e': CheckValue(&ename, "exe name"); break; @@ -232,7 +222,13 @@ static int process_option(int argc, char **argv) case 'c': controlPort = atoi(optarg); break; case 'd': dataPort = atoi(optarg); break; case 's': statPort = atoi(optarg); break; + case '?': exit(1); default: + if (optind != argc) + { + log_error("extra argument %s", argv[optind]); + exit(1); + } return -1; } return 0;