[PATCH] nodedev: Shorten match condition

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

 



Just a cleanup I stumbled upon in one of my older branches I did when
browsing through some code and forgot to send it.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
 src/conf/node_device_conf.c | 41 +++++++++++++++--------------------------
 1 file changed, 15 insertions(+), 26 deletions(-)

diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c
index c04739f90121..0c9c348e3793 100644
--- a/src/conf/node_device_conf.c
+++ b/src/conf/node_device_conf.c
@@ -1798,37 +1798,26 @@ virNodeDeviceCapMatch(virNodeDeviceObjPtr devobj,
     return false;
 }

-#define MATCH(FLAG) (flags & (FLAG))
+#define MATCH(FLAG) ((flags & (VIR_CONNECT_LIST_NODE_DEVICES_CAP_ ## FLAG)) && \
+                     virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_ ## FLAG))
 static bool
 virNodeDeviceMatch(virNodeDeviceObjPtr devobj,
                    unsigned int flags)
 {
     /* filter by cap type */
-    if (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_CAP)) {
-        if (!((MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SYSTEM) &&
-               virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_SYSTEM))        ||
-              (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_PCI_DEV) &&
-               virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_PCI_DEV))       ||
-              (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_DEV) &&
-               virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_USB_DEV))       ||
-              (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_INTERFACE) &&
-               virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_USB_INTERFACE)) ||
-              (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_NET) &&
-               virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_NET))           ||
-              (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_HOST) &&
-               virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_SCSI_HOST))     ||
-              (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_TARGET) &&
-               virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_SCSI_TARGET))   ||
-              (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI) &&
-               virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_SCSI))          ||
-              (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE) &&
-               virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_STORAGE))       ||
-              (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST) &&
-               virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_FC_HOST))       ||
-              (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS) &&
-               virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_VPORTS))        ||
-              (MATCH(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC) &&
-               virNodeDeviceCapMatch(devobj, VIR_NODE_DEV_CAP_SCSI_GENERIC))))
+    if (flags & VIR_CONNECT_LIST_NODE_DEVICES_FILTERS_CAP) {
+        if (!(MATCH(SYSTEM)        ||
+              MATCH(PCI_DEV)       ||
+              MATCH(USB_DEV)       ||
+              MATCH(USB_INTERFACE) ||
+              MATCH(NET)           ||
+              MATCH(SCSI_HOST)     ||
+              MATCH(SCSI_TARGET)   ||
+              MATCH(SCSI)          ||
+              MATCH(STORAGE)       ||
+              MATCH(FC_HOST)       ||
+              MATCH(VPORTS)        ||
+              MATCH(SCSI_GENERIC)))
             return false;
     }

-- 
2.7.3

--
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]