[libvirt] [PATCH] build: use correct printf types for uid/gid

Fixes a build failure on cygwin: cc1: warnings being treated as errors security/security_dac.c: In function 'virSecurityDACSetProcessLabel': security/security_dac.c:862:5: error: format '%u' expects type 'unsigned int', but argument 7 has type 'uid_t' [-Wformat] security/security_dac.c:862:5: error: format '%u' expects type 'unsigned int', but argument 8 has type 'gid_t' [-Wformat] * src/security/security_dac.c (virSecurityDACSetProcessLabel) (virSecurityDACGenLabel): Use proper casts. --- Pushing under the build-breaker rule. See src/util/util.c for other cases where we do the same. src/security/security_dac.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index a67f5d6..a1aa0ef 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -859,7 +859,8 @@ virSecurityDACSetProcessLabel(virSecurityManagerPtr mgr, if (virSecurityDACGetIds(def, priv, &user, &group)) return -1; - VIR_DEBUG("Dropping privileges of DEF to %u:%u", user, group); + VIR_DEBUG("Dropping privileges of DEF to %u:%u", + (unsigned int) user, (unsigned int) group); if (virSetUIDGID(user, group) < 0) return -1; @@ -920,7 +921,9 @@ virSecurityDACGenLabel(virSecurityManagerPtr mgr, } break; case VIR_DOMAIN_SECLABEL_DYNAMIC: - if (virAsprintf(&seclabel->label, "%d:%d", priv->user, priv->group) < 0) { + if (virAsprintf(&seclabel->label, "%d:%d", + (unsigned int) priv->user, + (unsigned int) priv->group) < 0) { virReportOOMError(); return rc; } -- 1.7.11.7

On 22.10.2012 22:49, Eric Blake wrote:
Fixes a build failure on cygwin: cc1: warnings being treated as errors security/security_dac.c: In function 'virSecurityDACSetProcessLabel': security/security_dac.c:862:5: error: format '%u' expects type 'unsigned int', but argument 7 has type 'uid_t' [-Wformat] security/security_dac.c:862:5: error: format '%u' expects type 'unsigned int', but argument 8 has type 'gid_t' [-Wformat]
* src/security/security_dac.c (virSecurityDACSetProcessLabel) (virSecurityDACGenLabel): Use proper casts. ---
Pushing under the build-breaker rule. See src/util/util.c for other cases where we do the same.
src/security/security_dac.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/security/security_dac.c b/src/security/security_dac.c index a67f5d6..a1aa0ef 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -859,7 +859,8 @@ virSecurityDACSetProcessLabel(virSecurityManagerPtr mgr, if (virSecurityDACGetIds(def, priv, &user, &group)) return -1;
- VIR_DEBUG("Dropping privileges of DEF to %u:%u", user, group); + VIR_DEBUG("Dropping privileges of DEF to %u:%u", + (unsigned int) user, (unsigned int) group);
if (virSetUIDGID(user, group) < 0) return -1; @@ -920,7 +921,9 @@ virSecurityDACGenLabel(virSecurityManagerPtr mgr, } break; case VIR_DOMAIN_SECLABEL_DYNAMIC: - if (virAsprintf(&seclabel->label, "%d:%d", priv->user, priv->group) < 0) { + if (virAsprintf(&seclabel->label, "%d:%d", + (unsigned int) priv->user, + (unsigned int) priv->group) < 0) {
In fact, "%d" expects signed int.
virReportOOMError(); return rc; }

On 10/23/2012 03:25 AM, Michal Privoznik wrote:
- VIR_DEBUG("Dropping privileges of DEF to %u:%u", user, group); + VIR_DEBUG("Dropping privileges of DEF to %u:%u", + (unsigned int) user, (unsigned int) group);
if (virSetUIDGID(user, group) < 0) return -1; @@ -920,7 +921,9 @@ virSecurityDACGenLabel(virSecurityManagerPtr mgr, } break; case VIR_DOMAIN_SECLABEL_DYNAMIC: - if (virAsprintf(&seclabel->label, "%d:%d", priv->user, priv->group) < 0) { + if (virAsprintf(&seclabel->label, "%d:%d", + (unsigned int) priv->user, + (unsigned int) priv->group) < 0) {
In fact, "%d" expects signed int.
Bah, serves me right for fixing the compiler warning without actually looking at the code being fixed. I'll push the obvious followup that canonicalizes on %u, since half the code was already right. POSIX leaves it unspecified whether uid_t is signed or unsigned, but for this usage, we want an unsigned printout. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Michal Privoznik