[libvirt PATCH v3 14/51] conf: Use virTristateXXX in virPCIDeviceAddress

Tim Wiederhake twiederh at redhat.com
Fri Mar 19 15:57:11 UTC 2021


Signed-off-by: Tim Wiederhake <twiederh at redhat.com>
---
 src/conf/device_conf.c | 16 +++++++++-------
 src/util/virpci.h      |  2 +-
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c
index 714ac50762..0dd60985e9 100644
--- a/src/conf/device_conf.c
+++ b/src/conf/device_conf.c
@@ -246,13 +246,15 @@ virPCIDeviceAddressParseXML(xmlNodePtr node,
         return -1;
     }
 
-    if (multi &&
-        ((addr->multi = virTristateSwitchTypeFromString(multi)) <= 0)) {
-        virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
-                       _("Unknown value '%s' for <address> 'multifunction' attribute"),
-                       multi);
-        return -1;
-
+    if (multi) {
+        int value;
+        if ((value = virTristateSwitchTypeFromString(multi)) <= 0) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
+                           _("Unknown value '%s' for <address> 'multifunction' attribute"),
+                           multi);
+            return -1;
+        }
+        addr->multi = value;
     }
     if (!virPCIDeviceAddressIsEmpty(addr) && !virPCIDeviceAddressIsValid(addr, true))
         return -1;
diff --git a/src/util/virpci.h b/src/util/virpci.h
index 9b37a12883..2c86642ea7 100644
--- a/src/util/virpci.h
+++ b/src/util/virpci.h
@@ -65,7 +65,7 @@ struct _virPCIDeviceAddress {
     unsigned int bus;
     unsigned int slot;
     unsigned int function;
-    int multi; /* virTristateSwitch */
+    virTristateSwitch multi;
     int extFlags; /* enum virPCIDeviceAddressExtensionFlags */
     virZPCIDeviceAddress zpci;
     /* Don't forget to update virPCIDeviceAddressCopy if needed. */
-- 
2.26.2




More information about the libvir-list mailing list