]> xenbits.xensource.com Git - libvirt.git/commitdiff
util: netdevbridge: Refactor error handling in virNetDevBridgeCreate
authorPeter Krempa <pkrempa@redhat.com>
Wed, 28 Jun 2017 12:14:53 +0000 (14:14 +0200)
committerPeter Krempa <pkrempa@redhat.com>
Wed, 28 Jun 2017 13:27:17 +0000 (15:27 +0200)
Replace the switch statement with a simpler if statement. This also
removes the fallthrough path that coverity was complaining about.

src/util/virnetdevbridge.c

index 11b03b426420095e9aecf9b0b12b9ccb48eb160d..cfb7ebae99c740a90f5eeaca916b16d09e24afee 100644 (file)
@@ -468,22 +468,17 @@ virNetDevBridgeCreate(const char *brname)
         if (resp->nlmsg_len < NLMSG_LENGTH(sizeof(*err)))
             goto malformed_resp;
 
-        switch (err->error) {
-        case 0:
-            break;
-        case -EOPNOTSUPP:
+        if (err->error < 0) {
 # if defined(HAVE_STRUCT_IFREQ) && defined(SIOCBRADDBR)
-            /* fallback to ioctl if netlink doesn't support creating
-             * bridges
-             */
-            rc = virNetDevBridgeCreateWithIoctl(brname);
-            goto cleanup;
+            if (err->error == -EOPNOTSUPP) {
+                /* fallback to ioctl if netlink doesn't support creating
+                 * bridges
+                 */
+                rc = virNetDevBridgeCreateWithIoctl(brname);
+                goto cleanup;
+            }
 # endif
-            /* intentionally fall through if virNetDevBridgeCreateWithIoctl()
-             * isn't available.
-             */
-            ATTRIBUTE_FALLTHROUGH;
-        default:
+
             virReportSystemError(-err->error,
                                  _("error creating bridge interface %s"),
                                  brname);