]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: check if specified debug level is in range
authorJán Tomko <jtomko@redhat.com>
Thu, 26 Jul 2012 14:05:51 +0000 (16:05 +0200)
committerEric Blake <eblake@redhat.com>
Thu, 26 Jul 2012 14:21:04 +0000 (08:21 -0600)
.mailmap
tools/virsh.c

index 367315963c575e17ddc639a6a99e2c1cea22a719..9b0209e3fd619b2aedb3366a00c707eb95b6dddc 100644 (file)
--- a/.mailmap
+++ b/.mailmap
@@ -36,3 +36,4 @@
 Alex Jia <ajia@redhat.com>
 Royce Lv <lvroyce@linux.vnet.ibm.com>
 Daniel J Walsh <dwalsh@redhat.com>
+Ján Tomko <jtomko@redhat.com>
index 5658796424fd61313acdb9d7b6b52f6efeeda5d3..4f8ea941e98c4b320d4212ab22c3228237ba2e5c 100644 (file)
@@ -3073,7 +3073,7 @@ vshAllowedEscapeChar(char c)
 static bool
 vshParseArgv(vshControl *ctl, int argc, char **argv)
 {
-    int arg, len;
+    int arg, len, debug;
     struct option opt[] = {
         {"debug", required_argument, NULL, 'd'},
         {"help", no_argument, NULL, 'h'},
@@ -3093,10 +3093,15 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
     while ((arg = getopt_long(argc, argv, "+d:hqtc:vVrl:e:", opt, NULL)) != -1) {
         switch (arg) {
         case 'd':
-            if (virStrToLong_i(optarg, NULL, 10, &ctl->debug) < 0) {
+            if (virStrToLong_i(optarg, NULL, 10, &debug) < 0) {
                 vshError(ctl, "%s", _("option -d takes a numeric argument"));
                 exit(EXIT_FAILURE);
             }
+            if (debug < VSH_ERR_DEBUG || debug > VSH_ERR_ERROR)
+                vshError(ctl, _("ignoring debug level %d out of range [%d-%d]"),
+                         debug, VSH_ERR_DEBUG, VSH_ERR_ERROR);
+            else
+                ctl->debug = debug;
             break;
         case 'h':
             vshUsage();