]> xenbits.xensource.com Git - libvirt.git/commitdiff
Avoid Coverity DEADCODE warning
authorJohn Ferlan <jferlan@redhat.com>
Fri, 18 Oct 2013 10:43:47 +0000 (06:43 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 24 Oct 2013 10:40:18 +0000 (06:40 -0400)
Commit '922b7fda' resulted in two DEADCODE warnings from Coverity in
remoteDispatchAuthPolkit and virAccessDriverPolkitFormatProcess.
Commit '604ae657' modified the daemon.c code to remove the deadcode
issue, but did not do so for viracessdriverpolkit.c. This just mimics
the same changes

src/access/viraccessdriverpolkit.c

index ff8258306a5897280d4c8b71a62394c508467927..c32573900cf5b7d7acb99286e1a48f5e674dcedb 100644 (file)
@@ -76,8 +76,9 @@ virAccessDriverPolkitFormatProcess(const char *actionid)
     const char *callerTime = NULL;
     const char *callerUid = NULL;
     char *ret = NULL;
-    bool supportsuid = false;
+#ifndef PKCHECK_SUPPORTS_UID
     static bool polkitInsecureWarned;
+#endif
 
     if (!identity) {
         virAccessError(VIR_ERR_ACCESS_DENIED,
@@ -109,19 +110,17 @@ virAccessDriverPolkitFormatProcess(const char *actionid)
     }
 
 #ifdef PKCHECK_SUPPORTS_UID
-    supportsuid = true;
-#endif
-    if (supportsuid) {
-        if (virAsprintf(&ret, "%s,%s,%s", callerPid, callerTime, callerUid) < 0)
-            goto cleanup;
-    } else {
-        if (!polkitInsecureWarned) {
-            VIR_WARN("No support for caller UID with pkcheck. This deployment is known to be insecure.");
-            polkitInsecureWarned = true;
-        }
-        if (virAsprintf(&ret, "%s,%s", callerPid, callerTime) < 0)
-            goto cleanup;
+    if (virAsprintf(&ret, "%s,%s,%s", callerPid, callerTime, callerUid) < 0)
+        goto cleanup;
+#else
+    if (!polkitInsecureWarned) {
+        VIR_WARN("No support for caller UID with pkcheck. "
+                 "This deployment is known to be insecure.");
+        polkitInsecureWarned = true;
     }
+    if (virAsprintf(&ret, "%s,%s", callerPid, callerTime) < 0)
+        goto cleanup;
+#endif
 
 cleanup:
     virObjectUnref(identity);