WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] xl: fixup command line handling for several commands

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] xl: fixup command line handling for several commands
From: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date: Wed, 28 Sep 2011 14:37:59 +0100
Cc: Ian Campbell <ian.campbell@xxxxxxxxxx>
Delivery-date: Wed, 28 Sep 2011 06:39:07 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.6.4
# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1317217065 -3600
# Node ID 945b1d50724b3d68c562859a0e38f6ee4d9fe612
# Parent  b099e064f9970f27bf7dbf24b97715371240bb4c
xl: fixup command line handling for several commands.

def_getopt already checks for a minimum number of arguments for us.

"xl save" simply need to use the correct argument for that value,
contrary to the change I made in 23876:b113d626cfaf

"xl block-list" does not need to check for at least 2 arguments, since
it's already been done by def_getopt.

"xl network-list" would previous accept zero arguments and just print
the table header. Insist on a domain argument.

Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

diff -r b099e064f997 -r 945b1d50724b tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c  Wed Sep 28 14:18:19 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c  Wed Sep 28 14:37:45 2011 +0100
@@ -2921,7 +2921,7 @@ int main_save(int argc, char **argv)
     int checkpoint = 0;
     int opt;
 
-    while ((opt = def_getopt(argc, argv, "c", "save", 1)) != -1) {
+    while ((opt = def_getopt(argc, argv, "c", "save", 2)) != -1) {
         switch (opt) {
         case 0: case 2:
             return opt;
@@ -2931,7 +2931,7 @@ int main_save(int argc, char **argv)
         }
     }
 
-    if (argc-optind < 2 || argc-optind > 3) {
+    if (argc-optind > 3) {
         help("save");
         return 2;
     }
@@ -4080,7 +4080,7 @@ int main_networklist(int argc, char **ar
     libxl_nicinfo *nics;
     unsigned int nb, i;
 
-    if ((opt = def_getopt(argc, argv, "", "network-list", 0)) != -1)
+    if ((opt = def_getopt(argc, argv, "", "network-list", 1)) != -1)
         return opt;
 
     /*      Idx  BE   MAC   Hdl  Sta  evch txr/rxr  BE-path */
@@ -4151,10 +4151,6 @@ int main_blockattach(int argc, char **ar
 
     if ((opt = def_getopt(argc, argv, "", "block-attach", 2)) != -1)
         return opt;
-    if ((argc-optind < 2)) {
-        help("block-attach");
-        return 2;
-    }
 
     if (domain_qualifier_to_domid(argv[optind], &fe_domid, 0) < 0) {
         fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>