[PATCH 2/2] virsh: Resolve Coverity 'MISSING_BREAK'

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

 



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 | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index ac86608..6ffa0ba 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -3054,11 +3054,15 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
         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);
+                    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);
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]