]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Resolve Coverity 'MISSING_BREAK'
authorJohn Ferlan <jferlan@redhat.com>
Wed, 1 May 2013 15:07:56 +0000 (11:07 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 8 May 2013 10:16:53 +0000 (06:16 -0400)
Recent commit '53531e16' resulted in a new Coverity warning regarding
a missing break in the ':' options processing. Adjust the commit to
avoid the issue.

tools/virsh.c

index 7ef0bda291de6cb3deb8c85b2d86ec31233f9df2..bb79245e56485c9dec31256072e3fd7d1ee3a370 100644 (file)
@@ -3053,12 +3053,15 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
             break;
         case ':':
             for (i = 0; opt[i].name != NULL; i++) {
-                if (opt[i].val == optopt) {
-                    vshError(ctl, _("option '-%c'/'--%s' requires an argument"),
-                             optopt, opt[i].name);
-                    exit(EXIT_FAILURE);
-                }
+                if (opt[i].val == optopt)
+                    break;
             }
+            if (opt[i].name)
+                vshError(ctl, _("option '-%c'/'--%s' requires an argument"),
+                         optopt, opt[i].name);
+            else
+                vshError(ctl, _("option '-%c' requires an argument"), optopt);
+            exit(EXIT_FAILURE);
         case '?':
             if (optopt)
                 vshError(ctl, _("unsupported option '-%c'. See --help."), optopt);