[PATCH 02/20] public API: prefer unsigned int for flags

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

 



Most APIs use 'unsigned int flags'; but a few stragglers were using
a signed value.  In particular, the vir*GetXMLDesc APIs were
split-brain, with inconsistent choice of types.  Although it is
an API break to use 'int' instead of 'unsigned int', it is ABI
compatible (pre-compiled apps will have no difference in behavior),
and generally apps can be recompiled without any issue (only rare
apps that compiled with extremely high warning levels, or which
pass libvirt API around as typed function pointers, would have to
make any code changes to deal with the change).

The migrate APIs use 'unsigned long flags', which can't be changed,
due to ABI constraints.

This patch intentionally touches only the public API, to prove the
claim that most existing code (including driver callbacks and virsh)
still compiles just fine in spite of the type change.

* include/libvirt/libvirt.h.in (virConnectOpenAuth)
(virDomainCoreDump, virDomainGetXMLDesc, virNetworkGetXMLDesc)
(virNWFilterGetXMLDesc): Use unsigned int for flags.
* src/libvirt.c (virConnectOpenAuth, virDomainCoreDump)
(virDomainGetXMLDesc, virNetworkGetXMLDesc)
(virNWFilterGetXMLDesc, do_open): Update accordingly.
---
 include/libvirt/libvirt.h.in |   10 +++++-----
 src/libvirt.c                |   12 ++++++------
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in
index 8e20f75..a22c1c9 100644
--- a/include/libvirt/libvirt.h.in
+++ b/include/libvirt/libvirt.h.in
@@ -851,7 +851,7 @@ virConnectPtr           virConnectOpen          (const char *name);
 virConnectPtr           virConnectOpenReadOnly  (const char *name);
 virConnectPtr           virConnectOpenAuth      (const char *name,
                                                  virConnectAuthPtr auth,
-                                                 int flags);
+                                                 unsigned int flags);
 int                     virConnectRef           (virConnectPtr conn);
 int                     virConnectClose         (virConnectPtr conn);
 const char *            virConnectGetType       (virConnectPtr conn);
@@ -961,7 +961,7 @@ int                    virDomainManagedSaveRemove(virDomainPtr dom,
  */
 int                     virDomainCoreDump       (virDomainPtr domain,
                                                  const char *to,
-                                                 int flags);
+                                                 unsigned int flags);

 /*
  * Screenshot of current domain console
@@ -1115,7 +1115,7 @@ typedef enum {
 } virDomainXMLFlags;

 char *                  virDomainGetXMLDesc     (virDomainPtr domain,
-                                                 int flags);
+                                                 unsigned int flags);


 char *                  virConnectDomainXMLFromNative(virConnectPtr conn,
@@ -1471,7 +1471,7 @@ int                     virNetworkGetUUID       (virNetworkPtr network,
 int                     virNetworkGetUUIDString (virNetworkPtr network,
                                                  char *buf);
 char *                  virNetworkGetXMLDesc    (virNetworkPtr network,
-                                                 int flags);
+                                                 unsigned int flags);
 char *                  virNetworkGetBridgeName (virNetworkPtr network);

 int                     virNetworkGetAutostart  (virNetworkPtr network,
@@ -2790,7 +2790,7 @@ int                     virNWFilterGetUUID       (virNWFilterPtr nwfilter,
 int                     virNWFilterGetUUIDString (virNWFilterPtr nwfilter,
                                                   char *buf);
 char *                  virNWFilterGetXMLDesc    (virNWFilterPtr nwfilter,
-                                                  int flags);
+                                                  unsigned int flags);


 int virDomainOpenConsole(virDomainPtr dom,
diff --git a/src/libvirt.c b/src/libvirt.c
index 5e1451c..7e70caa 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -955,7 +955,7 @@ error:
 static virConnectPtr
 do_open (const char *name,
          virConnectAuthPtr auth,
-         int flags)
+         unsigned int flags)
 {
     int i, res;
     virConnectPtr ret;
@@ -1269,7 +1269,7 @@ error:
 virConnectPtr
 virConnectOpenAuth(const char *name,
                    virConnectAuthPtr auth,
-                   int flags)
+                   unsigned int flags)
 {
     virConnectPtr ret = NULL;
     if (!initialized)
@@ -2365,7 +2365,7 @@ error:
  * Returns 0 in case of success and -1 in case of failure.
  */
 int
-virDomainCoreDump(virDomainPtr domain, const char *to, int flags)
+virDomainCoreDump(virDomainPtr domain, const char *to, unsigned int flags)
 {
     virConnectPtr conn;

@@ -3359,7 +3359,7 @@ error:
  *         the caller must free() the returned value.
  */
 char *
-virDomainGetXMLDesc(virDomainPtr domain, int flags)
+virDomainGetXMLDesc(virDomainPtr domain, unsigned int flags)
 {
     virConnectPtr conn;

@@ -8449,7 +8449,7 @@ error:
  *         the caller must free() the returned value.
  */
 char *
-virNetworkGetXMLDesc(virNetworkPtr network, int flags)
+virNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags)
 {
     virConnectPtr conn;
     VIR_DEBUG("network=%p, flags=%x", network, flags);
@@ -14217,7 +14217,7 @@ error:
  *         the caller must free() the returned value.
  */
 char *
-virNWFilterGetXMLDesc(virNWFilterPtr nwfilter, int flags)
+virNWFilterGetXMLDesc(virNWFilterPtr nwfilter, unsigned int flags)
 {
     virConnectPtr conn;
     VIR_DEBUG("nwfilter=%p, flags=%x", nwfilter, flags);
-- 
1.7.4.4

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