]> xenbits.xensource.com Git - libvirt.git/commitdiff
build: silence coverity false positives
authorEric Blake <eblake@redhat.com>
Tue, 2 Aug 2011 20:26:17 +0000 (14:26 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 2 Aug 2011 22:39:01 +0000 (16:39 -0600)
Coverity complained that 395 out of 409 virAsprintf calls are
checked, and therefore assumed that the remaining cases are bugs
waiting to happen.  But in each of these cases, a failed virAsprintf
will properly set the target string to NULL, and pass on that
failure to the caller, without wasting efforts to check the call.
Adding the ignore_value silences Coverity.

* src/conf/domain_audit.c (virDomainAuditGetRdev): Ignore
virAsprintf return value, when it behaves like we need.
* src/network/bridge_driver.c (networkDnsmasqLeaseFileNameDefault)
(networkRadvdConfigFileName, networkBridgeDummyNicName)
(networkRadvdPidfileBasename): Likewise.
* src/util/storage_file.c (absolutePathFromBaseFile): Likewise.
* src/openvz/openvz_driver.c (openvzGenerateContainerVethName):
Likewise.
* src/util/command.c (virCommandTranslateStatus): Likewise.

src/conf/domain_audit.c
src/network/bridge_driver.c
src/openvz/openvz_driver.c
src/util/command.c
src/util/storage_file.c

index 963eecb241ddb84a3732b888a06b752cf2c65231..9d89c940bfd559a35e05c76a15ba55c5bab73caa 100644 (file)
@@ -46,7 +46,7 @@ virDomainAuditGetRdev(const char *path)
         (S_ISCHR(sb.st_mode) || S_ISBLK(sb.st_mode))) {
         int maj = major(sb.st_rdev);
         int min = minor(sb.st_rdev);
-        virAsprintf(&ret, "%02X:%02X", maj, min);
+        ignore_value(virAsprintf(&ret, "%02X:%02X", maj, min));
     }
     return ret;
 }
index 0a60bb861a241518cec7a26c037b89b869c0c5fc..c7d2dfd4e0d645a48241d0d5d992cad34b532190 100644 (file)
@@ -60,6 +60,7 @@
 #include "dnsmasq.h"
 #include "util/network.h"
 #include "configmake.h"
+#include "ignore-value.h"
 
 #define NETWORK_PID_DIR LOCALSTATEDIR "/run/libvirt/network"
 #define NETWORK_STATE_DIR LOCALSTATEDIR "/lib/libvirt/network"
@@ -125,8 +126,8 @@ networkDnsmasqLeaseFileNameDefault(const char *netname)
 {
     char *leasefile;
 
-    virAsprintf(&leasefile, DNSMASQ_STATE_DIR "/%s.leases",
-                netname);
+    ignore_value(virAsprintf(&leasefile, DNSMASQ_STATE_DIR "/%s.leases",
+                             netname));
     return leasefile;
 }
 
@@ -139,7 +140,7 @@ networkRadvdPidfileBasename(const char *netname)
     /* this is simple but we want to be sure it's consistently done */
     char *pidfilebase;
 
-    virAsprintf(&pidfilebase, "%s-radvd", netname);
+    ignore_value(virAsprintf(&pidfilebase, "%s-radvd", netname));
     return pidfilebase;
 }
 
@@ -148,8 +149,8 @@ networkRadvdConfigFileName(const char *netname)
 {
     char *configfile;
 
-    virAsprintf(&configfile, RADVD_STATE_DIR "/%s-radvd.conf",
-                netname);
+    ignore_value(virAsprintf(&configfile, RADVD_STATE_DIR "/%s-radvd.conf",
+                             netname));
     return configfile;
 }
 
@@ -166,12 +167,13 @@ networkBridgeDummyNicName(const char *brname)
          * a possible numeric ending (eg virbr0, virbr1, etc), we grab
          * the first 8 and last 3 characters of the string.
          */
-         virAsprintf(&nicname, "%.*s%s%s",
-                     /* space for last 3 chars + "-nic" + NULL */
-                     (int)(IFNAMSIZ - (3 + sizeof(dummyNicSuffix))),
-                     brname, brname + strlen(brname) - 3, dummyNicSuffix);
+        ignore_value(virAsprintf(&nicname, "%.*s%s%s",
+                                 /* space for last 3 chars + "-nic" + NULL */
+                                 (int)(IFNAMSIZ - (3 + sizeof(dummyNicSuffix))),
+                                 brname, brname + strlen(brname) - 3,
+                                 dummyNicSuffix));
     } else {
-         virAsprintf(&nicname, "%s%s", brname, dummyNicSuffix);
+        ignore_value(virAsprintf(&nicname, "%s%s", brname, dummyNicSuffix));
     }
     return nicname;
 }
index df2079e49a98ba8165d3ab5be44919561f6d437f..b9dc712056ee3cc007751ec191e0f42f0c4f1cb6 100644 (file)
@@ -710,7 +710,7 @@ openvzGenerateContainerVethName(int veid)
         }
 
         /* set new name */
-        virAsprintf(&name, "eth%d", max + 1);
+        ignore_value(virAsprintf(&name, "eth%d", max + 1));
     }
 
     VIR_FREE(temp);
index 475eb62857e735c39a1c3bba2c7a9cb64871e01c..26fcb287f9e040ee480bf05d314f8b9dd258f443 100644 (file)
@@ -1543,11 +1543,13 @@ virCommandTranslateStatus(int status)
 {
     char *buf;
     if (WIFEXITED(status)) {
-        virAsprintf(&buf, _("exit status %d"), WEXITSTATUS(status));
+        ignore_value(virAsprintf(&buf, _("exit status %d"),
+                                 WEXITSTATUS(status)));
     } else if (WIFSIGNALED(status)) {
-        virAsprintf(&buf, _("fatal signal %d"), WTERMSIG(status));
+        ignore_value(virAsprintf(&buf, _("fatal signal %d"),
+                                 WTERMSIG(status)));
     } else {
-        virAsprintf(&buf, _("invalid value %d"), status);
+        ignore_value(virAsprintf(&buf, _("invalid value %d"), status));
     }
     return buf;
 }
index 68e82a9f2ccacc40aabe29fcda72eb009f271c23..f33ea74a929e6757e63b01f8d2c4f543132c6acf 100644 (file)
@@ -512,7 +512,7 @@ absolutePathFromBaseFile(const char *base_file, const char *path)
     if (d_len > INT_MAX)
         return NULL;
 
-    virAsprintf(&res, "%.*s/%s", (int) d_len, base_file, path);
+    ignore_value(virAsprintf(&res, "%.*s/%s", (int) d_len, base_file, path));
     return res;
 }