[PATCH 1/3] conf: Verify metadata type right away

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

 



Verify the desired metadata type in the libvirt.c dispatcher rather than
in the bottom level executor function.
---
 src/conf/domain_conf.c | 10 ++--------
 src/libvirt.c          | 10 ++++++----
 2 files changed, 8 insertions(+), 12 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 70f1103..a2b0f23 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -19601,10 +19601,7 @@ virDomainObjGetMetadata(virDomainObjPtr vm,
             goto cleanup;
         break;

-    default:
-        virReportError(VIR_ERR_INVALID_ARG, "%s",
-                       _("unknown metadata type"));
-        goto cleanup;
+    case VIR_DOMAIN_METADATA_LAST:
         break;
     }

@@ -19683,10 +19680,7 @@ virDomainDefSetMetadata(virDomainDefPtr def,
         }
         break;

-    default:
-        virReportError(VIR_ERR_INVALID_ARG, "%s",
-                       _("unknown metadata type"));
-        goto cleanup;
+    case VIR_DOMAIN_METADATA_LAST:
         break;
     }

diff --git a/src/libvirt.c b/src/libvirt.c
index 316fdf0..6bf260a 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -10178,8 +10178,9 @@ virDomainSetMetadata(virDomainPtr domain,
             virCheckNonNullArgGoto(key, error);
         break;
     default:
-        /* For future expansion */
-        break;
+        virReportInvalidArg(type,
+                            _("unsupported metadata type '%d'"), type);
+        goto error;
     }

     if (conn->driver->domainSetMetadata) {
@@ -10255,8 +10256,9 @@ virDomainGetMetadata(virDomainPtr domain,
         virCheckNonNullArgGoto(uri, error);
         break;
     default:
-        /* For future expansion */
-        break;
+        virReportInvalidArg(type,
+                            _("unsupported metadata type '%d'"), type);
+        goto error;
     }

     conn = domain->conn;
-- 
2.0.0

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