[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v9 11/18] xenctx: Add error output if --all-vcpus (-C) and [VCPU] are both specified.



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 <dslutz@xxxxxxxxxxx>
Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
v9:
  Moved hunk from #12 that should have been here.
  Added : to error message

 tools/xentrace/xenctx.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/tools/xentrace/xenctx.c b/tools/xentrace/xenctx.c
index ca3662e..caa2991 100644
--- a/tools/xentrace/xenctx.c
+++ b/tools/xentrace/xenctx.c
@@ -1003,6 +1003,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:"
@@ -1055,7 +1056,7 @@ int main(int argc, char **argv)
             {
                 fprintf(stderr,
                         "%s: Unsupported value(%d) for --display-stack-pages 
'%s'. Needs to be >= 1\n",
-                        argv[0], xenctx.nr_stack_pages, optarg);
+                        prog, xenctx.nr_stack_pages, optarg);
                 exit(-1);
             }
             break;
@@ -1072,7 +1073,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);
             }
@@ -1087,7 +1088,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;
@@ -1109,7 +1110,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);
         }
     }
@@ -1127,8 +1128,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


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.