From: Don Slutz Subject: [PATCH v8 11/20] xenctx: Add error output if --all-vcpus (-C) and [VCPU] are both specified. Date: Thu, 27 Mar 2014 15:05:38 -0400 Message-ID: <1395947147-5262-12-git-send-email-dslutz@verizon.com> References: <1395947147-5262-1-git-send-email-dslutz@verizon.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1395947147-5262-1-git-send-email-dslutz@verizon.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Ian Campbell , Stefano Stabellini , George Dunlap , Ian Jackson , Don Slutz , Jan Beulich List-Id: xen-devel@lists.xenproject.org To do this correctly the program name must be remembered since argv is adjusted at the end of option parsing. Switch all uses of argv[0] to prog. Signed-off-by: Don Slutz --- v8: Renamed form "xenctx: Fixup options checking" New commit message. make the new copy const. tools/xentrace/xenctx.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c index 06b10f2..299ba5e 100644 --- a/tools/xentrace/xenctx.c +++ b/tools/xentrace/xenctx.c @@ -1004,6 +1004,7 @@ int main(int argc, char **argv) { int ch; int ret; + const char *prog = argv[0]; static const char *sopts = "fs:hak:SCn:b:l:Dt" #ifndef NO_TRANSLATION "m:" @@ -1073,7 +1074,7 @@ int main(int argc, char **argv) { fprintf(stderr, "%s: Unsupported value for --bytes-per-line '%s'. Needs to be 4 <= %d <= %d\n", - argv[0], optarg, xenctx.bytes_per_line, + prog, optarg, xenctx.bytes_per_line, MAX_BYTES_PER_LINE); exit(-1); } @@ -1088,7 +1089,7 @@ int main(int argc, char **argv) { fprintf(stderr, "%s: Unsupported value(%d) for --lines '%s'. Needs to be >= 0, < %d\n", - argv[0], xenctx.lines, optarg, INT_MAX); + prog, xenctx.lines, optarg, INT_MAX); exit(-1); } break; @@ -1110,7 +1111,7 @@ int main(int argc, char **argv) usage(); exit(-1); case '?': - fprintf(stderr, "%s --help for more options\n", argv[0]); + fprintf(stderr, "%s --help for more options\n", prog); exit(-1); } } @@ -1128,8 +1129,17 @@ int main(int argc, char **argv) exit(-1); } - if (argc == 2) + if ( argc == 2 ) + { + if ( xenctx.all_vcpus ) + { + fprintf(stderr, + "%s both --all-vcpus and [VCPU] is not supported\n", + prog); + exit(-1); + } vcpu = atoi(argv[1]); + } if (symbol_table) read_symbol_table(symbol_table); -- 1.8.4