Re: [PATCH 7/7] conf: Rework virDomainDeviceDefPostParseCommon()

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

 



On Fri, Feb 15, 2019 at 12:55:52PM +0100, Andrea Bolognani wrote:
Now that we've moved all the actual code into helper
functions, we can turn it into a switch statement.

Signed-off-by: Andrea Bolognani <abologna@xxxxxxxxxx>
---
src/conf/domain_conf.c | 77 +++++++++++++++++++++++++++++++-----------
1 file changed, 58 insertions(+), 19 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 7f66fa27ff..ffdc027983 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4966,33 +4966,72 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefPtr dev,
                                  unsigned int parseFlags ATTRIBUTE_UNUSED,
                                  virDomainXMLOptionPtr xmlopt)
{
-    if (dev->type == VIR_DOMAIN_DEVICE_CHR)
-        return virDomainChrDefPostParse(dev->data.chr, def);
+    int ret = -1;


With the preparatory patches adding an exit point in every if, I
expected the 'return's to stay.

-    if (dev->type == VIR_DOMAIN_DEVICE_RNG)
-        return virDomainRNGDefPostParse(dev->data.rng);
+    switch ((virDomainDeviceType)dev->type) {

[...]

+    case VIR_DOMAIN_DEVICE_NONE:
+        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+                       _("unexpected VIR_DOMAIN_DEVICE_NONE"));
+        break;
+
+    case VIR_DOMAIN_DEVICE_LAST:
+    default:
+        virReportEnumRangeError(virDomainDeviceType, dev->type);
+        break;
+    }
+
+    return ret;

But I'm not sure how some tools would handle the (lack of) presence
of this return.

Either way:
Reviewed-by: Ján Tomko <jtomko@xxxxxxxxxx>

Jano

}

Attachment: signature.asc
Description: PGP signature


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

  Powered by Linux