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 | 2 +-
src/network/bridge_driver.c | 22 ++++++++++++----------
src/openvz/openvz_driver.c | 2 +-
src/util/command.c | 8 +++++---
src/util/storage_file.c | 2 +-
5 files changed, 20 insertions(+), 16 deletions(-)
diff --git a/src/conf/domain_audit.c b/src/conf/domain_audit.c
index 963eecb..9d89c94 100644
--- a/src/conf/domain_audit.c
+++ b/src/conf/domain_audit.c
@@ -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;
}
diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c
index 0a60bb8..c7d2dfd 100644
--- a/src/network/bridge_driver.c
+++ b/src/network/bridge_driver.c
@@ -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;
}
diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c
index df2079e..b9dc712 100644
--- a/src/openvz/openvz_driver.c
+++ b/src/openvz/openvz_driver.c
@@ -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);
diff --git a/src/util/command.c b/src/util/command.c
index 475eb62..26fcb28 100644
--- a/src/util/command.c
+++ b/src/util/command.c
@@ -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;
}
diff --git a/src/util/storage_file.c b/src/util/storage_file.c
index 68e82a9..f33ea74 100644
--- a/src/util/storage_file.c
+++ b/src/util/storage_file.c
@@ -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;
}
--
1.7.4.4