]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: fix keepalive error msg
authorErik Skultety <eskultet@redhat.com>
Wed, 27 Aug 2014 14:20:29 +0000 (16:20 +0200)
committerEric Blake <eblake@redhat.com>
Wed, 27 Aug 2014 22:26:26 +0000 (16:26 -0600)
resolves https://bugzilla.redhat.com/show_bug.cgi?id=1132305:

The error message for an out-of-range argument was confusing:

virsh -k 9999999999
error: option --k requires a positive numeric argument

After this patch, it is:

error: Invalid value for option -k

Signed-off-by: Eric Blake <eblake@redhat.com>
tools/virsh.c

index 30a84c15916104708c4ce828324fc6e4b91c49ac..713c9a5fb69f1a5a0e800332eb9aaf4c2ebd39c2 100644 (file)
@@ -3470,18 +3470,32 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
             exit(EXIT_SUCCESS);
             break;
         case 'k':
-            if (virStrToLong_i(optarg, NULL, 0, &keepalive) < 0 ||
-                keepalive < 0) {
-                vshError(ctl, _("option %s requires a positive numeric argument"),
+            if (virStrToLong_i(optarg, NULL, 0, &keepalive) < 0) {
+                vshError(ctl,
+                         _("Invalid value for option %s"),
+                         longindex == -1 ? "-k" : "--keepalive-interval");
+                exit(EXIT_FAILURE);
+            }
+
+            if (keepalive < 0) {
+                vshError(ctl,
+                         _("option %s requires a positive integer argument"),
                          longindex == -1 ? "-k" : "--keepalive-interval");
                 exit(EXIT_FAILURE);
             }
             ctl->keepalive_interval = keepalive;
             break;
         case 'K':
-            if (virStrToLong_i(optarg, NULL, 0, &keepalive) < 0 ||
-                keepalive < 0) {
-                vshError(ctl, _("option %s requires a positive numeric argument"),
+            if (virStrToLong_i(optarg, NULL, 0, &keepalive) < 0) {
+                vshError(ctl,
+                         _("Invalid value for option %s"),
+                         longindex == -1 ? "-K" : "--keepalive-count");
+                exit(EXIT_FAILURE);
+            }
+
+            if (keepalive < 0) {
+                vshError(ctl,
+                         _("option %s requires a positive integer argument"),
                          longindex == -1 ? "-K" : "--keepalive-count");
                 exit(EXIT_FAILURE);
             }