[dbus PATCH v2 2/9] Abandon usage of all *TypeToString functions in connect.c

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

 



Converting ENUMS to str can be user friendly though
it can be problematic in matters of backward compatibility.

In particular when some ENUM in libvirt API will introduce a
new constant, libvirt-dbus will fail with:

size of array ‘_GStaticAssertCompileTimeAssertion_5’ is negative

So using ints is preferable to avoid the previous issue.

Signed-off-by: Katerina Koukiou <kkoukiou@xxxxxxxxxx>
---
 data/org.libvirt.Connect.xml |  2 +-
 src/connect.c                | 18 +-----------------
 2 files changed, 2 insertions(+), 18 deletions(-)

diff --git a/data/org.libvirt.Connect.xml b/data/org.libvirt.Connect.xml
index ee7bfdc..7249fa4 100644
--- a/data/org.libvirt.Connect.xml
+++ b/data/org.libvirt.Connect.xml
@@ -37,7 +37,7 @@
         value="See https://libvirt.org/html/libvirt-libvirt-host.html#virConnectCompareCPU"/>
       <arg name="xmlDesc" type="s" direction="in"/>
       <arg name="flags" type="u" direction="in"/>
-      <arg name="compareResult" type="s" direction="out"/>
+      <arg name="compareResult" type="u" direction="out"/>
     </method>
     <method name="DomainCreateXML">
       <annotation name="org.gtk.GDBus.DocString"
diff --git a/src/connect.c b/src/connect.c
index 5e577e4..e21bfab 100644
--- a/src/connect.c
+++ b/src/connect.c
@@ -6,13 +6,6 @@
 
 #include <glib/gprintf.h>
 
-VIRT_DBUS_ENUM_DECL(virtDBusConnectCPUCompareResult)
-VIRT_DBUS_ENUM_IMPL(virtDBusConnectCPUCompareResult,
-                    VIR_CPU_COMPARE_LAST,
-                    "incompatible",
-                    "identical",
-                    "superset")
-
 static gint virtDBusConnectCredType[] = {
     VIR_CRED_AUTHNAME,
     VIR_CRED_ECHOPROMPT,
@@ -263,7 +256,6 @@ virtDBusConnectCompareCPU(GVariant *inArgs,
     const gchar *xmlDesc;
     guint flags;
     gint compareResult;
-    const gchar* compareResultStr;
 
     g_variant_get(inArgs, "(&su)", &xmlDesc, &flags);
 
@@ -274,15 +266,7 @@ virtDBusConnectCompareCPU(GVariant *inArgs,
     if (compareResult < 0)
         return virtDBusUtilSetLastVirtError(error);
 
-    compareResultStr = virtDBusConnectCPUCompareResultTypeToString(compareResult);
-    if (!compareResultStr) {
-        g_set_error(error, VIRT_DBUS_ERROR, VIRT_DBUS_ERROR_LIBVIRT,
-                    "Can't format virCPUCompareResult '%d' to string.",
-                    compareResult);
-        return;
-    }
-
-    *outArgs = g_variant_new("(s)", compareResultStr);
+    *outArgs = g_variant_new("(u)", compareResult);
 }
 
 static void
-- 
2.15.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]

  Powered by Linux