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

Ján Tomko jtomko at redhat.com
Fri Feb 15 13:38:49 UTC 2019


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 at redhat.com>
>---
> 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 at redhat.com>

Jano

> }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20190215/68c398c1/attachment-0001.sig>


More information about the libvir-list mailing list