From 18d561c7a45f180901e0b5f912f7ed15ecd8d3ac Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 6 Jul 2011 13:55:47 -0600 Subject: [PATCH] public API: prefer unsigned int for flags 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. (virDomainHasCurrentSnapshot): Use consistent spelling. * src/libvirt.c (virConnectOpenAuth, virDomainCoreDump) (virDomainGetXMLDesc, virNetworkGetXMLDesc) (virNWFilterGetXMLDesc, do_open): Update accordingly. --- include/libvirt/libvirt.h.in | 12 ++++++------ src/libvirt.c | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/libvirt/libvirt.h.in b/include/libvirt/libvirt.h.in index 8e20f75f0c..d5a710566c 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, @@ -2464,7 +2464,7 @@ virDomainSnapshotPtr virDomainSnapshotLookupByName(virDomainPtr domain, unsigned int flags); /* Check whether a domain has a snapshot which is currently used */ -int virDomainHasCurrentSnapshot(virDomainPtr domain, unsigned flags); +int virDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags); /* Get a handle to the current snapshot */ virDomainSnapshotPtr virDomainSnapshotCurrent(virDomainPtr domain, @@ -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 5e1451c7f9..7e70caa582 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); -- GitLab