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