mirror of https://gitee.com/openkylin/libvirt.git
build: silence coverity false positives
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.
This commit is contained in:
parent
2ea9409a88
commit
44ebb18ec2
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue