render / rpms / libvirt

Forked from rpms/libvirt 10 months ago
Clone
3e5111
From 403371cc06cd9ac36bbe7e7a2e046de82c09e762 Mon Sep 17 00:00:00 2001
3e5111
Message-Id: <403371cc06cd9ac36bbe7e7a2e046de82c09e762@dist-git>
3e5111
From: Erik Skultety <eskultet@redhat.com>
3e5111
Date: Thu, 18 May 2017 14:02:47 +0200
3e5111
Subject: [PATCH] nodedev: Make use of the compile-time missing enum in switch
3e5111
 error
3e5111
3e5111
So udevGetDeviceDetails was one those functions using an enum in a
3e5111
switch, but since it had a 'default' case, compiler didn't warn about an
3e5111
unhandled enum. Moreover, the error about an unsupported device type
3e5111
reported in the default case is unnecessary, since by the time we get
3e5111
there, udevGetDeviceType (which was called before) already made sure
3e5111
that any unrecognized device types had been handled properly.
3e5111
3e5111
https://bugzilla.redhat.com/show_bug.cgi?id=1452072
3e5111
3e5111
Signed-off-by: Erik Skultety <eskultet@redhat.com>
3e5111
(cherry picked from commit 364c912cf384d2fb7575ba2f71a041297210e0e2)
3e5111
Signed-off-by: Erik Skultety <eskultet@redhat.com>
3e5111
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
3e5111
---
3e5111
 src/node_device/node_device_udev.c | 45 +++++++++++++-------------------------
3e5111
 1 file changed, 15 insertions(+), 30 deletions(-)
3e5111
3e5111
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
3e5111
index bcae444d8..591da8db2 100644
3e5111
--- a/src/node_device/node_device_udev.c
3e5111
+++ b/src/node_device/node_device_udev.c
3e5111
@@ -1043,50 +1043,35 @@ udevGetDeviceType(struct udev_device *device,
3e5111
 static int udevGetDeviceDetails(struct udev_device *device,
3e5111
                                 virNodeDeviceDefPtr def)
3e5111
 {
3e5111
-    int ret = 0;
3e5111
-
3e5111
     switch (def->caps->data.type) {
3e5111
-    case VIR_NODE_DEV_CAP_SYSTEM:
3e5111
-        /* There's no libudev equivalent of system, so ignore it. */
3e5111
-        break;
3e5111
     case VIR_NODE_DEV_CAP_PCI_DEV:
3e5111
-        ret = udevProcessPCI(device, def);
3e5111
-        break;
3e5111
+        return udevProcessPCI(device, def);
3e5111
     case VIR_NODE_DEV_CAP_USB_DEV:
3e5111
-        ret = udevProcessUSBDevice(device, def);
3e5111
-        break;
3e5111
+        return udevProcessUSBDevice(device, def);
3e5111
     case VIR_NODE_DEV_CAP_USB_INTERFACE:
3e5111
-        ret = udevProcessUSBInterface(device, def);
3e5111
-        break;
3e5111
+        return udevProcessUSBInterface(device, def);
3e5111
     case VIR_NODE_DEV_CAP_NET:
3e5111
-        ret = udevProcessNetworkInterface(device, def);
3e5111
-        break;
3e5111
+        return udevProcessNetworkInterface(device, def);
3e5111
     case VIR_NODE_DEV_CAP_SCSI_HOST:
3e5111
-        ret = udevProcessSCSIHost(device, def);
3e5111
-        break;
3e5111
+        return udevProcessSCSIHost(device, def);
3e5111
     case VIR_NODE_DEV_CAP_SCSI_TARGET:
3e5111
-        ret = udevProcessSCSITarget(device, def);
3e5111
-        break;
3e5111
+        return udevProcessSCSITarget(device, def);
3e5111
     case VIR_NODE_DEV_CAP_SCSI:
3e5111
-        ret = udevProcessSCSIDevice(device, def);
3e5111
-        break;
3e5111
+        return udevProcessSCSIDevice(device, def);
3e5111
     case VIR_NODE_DEV_CAP_STORAGE:
3e5111
-        ret = udevProcessStorage(device, def);
3e5111
-        break;
3e5111
+        return udevProcessStorage(device, def);
3e5111
     case VIR_NODE_DEV_CAP_SCSI_GENERIC:
3e5111
-        ret = udevProcessSCSIGeneric(device, def);
3e5111
-        break;
3e5111
+        return udevProcessSCSIGeneric(device, def);
3e5111
     case VIR_NODE_DEV_CAP_DRM:
3e5111
-        ret = udevProcessDRMDevice(device, def);
3e5111
-        break;
3e5111
-    default:
3e5111
-        virReportError(VIR_ERR_INTERNAL_ERROR,
3e5111
-                       _("Unknown device type %d"), def->caps->data.type);
3e5111
-        ret = -1;
3e5111
+        return udevProcessDRMDevice(device, def);
3e5111
+    case VIR_NODE_DEV_CAP_SYSTEM:
3e5111
+    case VIR_NODE_DEV_CAP_FC_HOST:
3e5111
+    case VIR_NODE_DEV_CAP_VPORTS:
3e5111
+    case VIR_NODE_DEV_CAP_LAST:
3e5111
         break;
3e5111
     }
3e5111
 
3e5111
-    return ret;
3e5111
+    return 0;
3e5111
 }
3e5111
 
3e5111
 
3e5111
-- 
3e5111
2.13.0
3e5111