}
buf = base;
#else
- if (VIR_ALLOC_N(buf, buflen + alignMask) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(buf, buflen + alignMask) < 0)
goto cleanup;
- }
base = buf;
buf = (char *) (((intptr_t) base + alignMask) & ~alignMask);
#endif
goto cleanup;
if (virAsprintf(path, "%s/auth.conf", userdir) < 0)
- goto no_memory;
+ goto cleanup;
VIR_DEBUG("Checking for readability of '%s'", *path);
if (access(*path, R_OK) == 0)
VIR_FREE(userdir);
return ret;
-
-no_memory:
- virReportOOMError();
- goto cleanup;
}
{
virAuthConfigPtr auth;
- if (VIR_ALLOC(auth) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(auth) < 0)
goto error;
- }
if (VIR_STRDUP(auth->path, path) < 0)
goto error;
{
virAuthConfigPtr auth;
- if (VIR_ALLOC(auth) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(auth) < 0)
goto error;
- }
if (VIR_STRDUP(auth->path, path) < 0)
goto error;
if (!hostname)
hostname = "localhost";
- if (virAsprintf(&authgroup, "auth-%s-%s", service, hostname) < 0) {
- virReportOOMError();
+ if (virAsprintf(&authgroup, "auth-%s-%s", service, hostname) < 0)
goto cleanup;
- }
if (!virKeyFileHasGroup(auth->keyfile, authgroup)) {
ret = 0;
goto cleanup;
}
- if (virAsprintf(&credgroup, "credentials-%s", authcred) < 0) {
- virReportOOMError();
+ if (virAsprintf(&credgroup, "credentials-%s", authcred) < 0)
goto cleanup;
- }
if (!virKeyFileHasGroup(auth->keyfile, credgroup)) {
virReportError(VIR_ERR_CONF_SYNTAX,
if ((rc = virCgroupPartitionNeedsEscaping(*path)) <= 0)
return rc;
- if (VIR_INSERT_ELEMENT_QUIET(*path, 0, len, escape) < 0)
+ if (VIR_INSERT_ELEMENT(*path, 0, len, escape) < 0)
return -ENOMEM;
return 0;
if (VIR_REALLOC_N(tokens[i],
strlen(tokens[i]) + strlen(".partition") + 1) < 0) {
ret = -ENOMEM;
- virReportOOMError();
goto cleanup;
}
strcat(tokens[i], ".partition");
ret = virCgroupPartitionEscape(&(tokens[i]));
if (ret < 0) {
- if (ret == -ENOMEM)
- virReportOOMError();
goto cleanup;
}
}
}
if (virAsprintf(&opts,
- "mode=755,size=65536%s", mountopts) < 0) {
- virReportOOMError();
+ "mode=755,size=65536%s", mountopts) < 0)
goto cleanup;
- }
if (mount("tmpfs", root, "tmpfs", MS_NOSUID|MS_NODEV|MS_NOEXEC, opts) < 0) {
virReportSystemError(errno,
if (virAsprintf(&src, "%s%s%s",
oldroot,
group->controllers[i].mountPoint,
- group->controllers[i].placement) < 0) {
- virReportOOMError();
+ group->controllers[i].placement) < 0)
goto cleanup;
- }
VIR_DEBUG("Create mount point '%s'", group->controllers[i].mountPoint);
if (virFileMakePath(group->controllers[i].mountPoint) < 0) {
* results accumulated over a prior run of the same command. */
if (cmd->outbuf) {
outfd = cmd->outfd;
- if (VIR_REALLOC_N(*cmd->outbuf, 1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(*cmd->outbuf, 1) < 0)
ret = -1;
- }
}
if (cmd->errbuf) {
errfd = cmd->errfd;
- if (VIR_REALLOC_N(*cmd->errbuf, 1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(*cmd->errbuf, 1) < 0)
ret = -1;
- }
}
if (ret == -1)
goto cleanup;
else
errfd = -1;
} else {
- if (VIR_REALLOC_N(*buf, *len + done + 1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(*buf, *len + done + 1) < 0)
goto cleanup;
- }
memcpy(*buf + *len, data, done);
*len += done;
}
char *msg;
ssize_t len;
if (VIR_ALLOC_N(msg, 1024) < 0) {
- virReportOOMError();
VIR_FORCE_CLOSE(cmd->handshakeWait[0]);
return -1;
}
{
virConfPtr ret;
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ret) < 0)
return NULL;
- }
ret->filename = NULL;
ret->flags = 0;
if ((comm == NULL) && (name == NULL))
return NULL;
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ret) < 0)
return NULL;
- }
ret->name = name;
ret->value = value;
return NULL;
}
if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
virConfFreeList(lst);
VIR_FREE(str);
return NULL;
if (!cur) {
if (VIR_ALLOC(cur) < 0) {
- virReportOOMError();
virConfFreeValue(value);
return -1;
}
if (idx < 0) {
if (VIR_REALLOC_N(addnhostsfile->hosts, addnhostsfile->nhosts + 1) < 0)
- goto alloc_error;
+ goto error;
idx = addnhostsfile->nhosts;
if (VIR_ALLOC(addnhostsfile->hosts[idx].hostnames) < 0)
- goto alloc_error;
+ goto error;
if (VIR_STRDUP(addnhostsfile->hosts[idx].ip, ipstr) < 0)
goto error;
}
if (VIR_REALLOC_N(addnhostsfile->hosts[idx].hostnames, addnhostsfile->hosts[idx].nhostnames + 1) < 0)
- goto alloc_error;
+ goto error;
if (VIR_STRDUP(addnhostsfile->hosts[idx].hostnames[addnhostsfile->hosts[idx].nhostnames],
name) < 0)
return 0;
- alloc_error:
- virReportOOMError();
error:
VIR_FREE(ipstr);
return -1;
{
dnsmasqAddnHostsfile *addnhostsfile;
- if (VIR_ALLOC(addnhostsfile) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(addnhostsfile) < 0)
return NULL;
- }
addnhostsfile->hosts = NULL;
addnhostsfile->nhosts = 0;
if (virAsprintf(&addnhostsfile->path, "%s/%s.%s", config_dir, name,
- DNSMASQ_ADDNHOSTSFILE_SUFFIX) < 0) {
- virReportOOMError();
+ DNSMASQ_ADDNHOSTSFILE_SUFFIX) < 0)
goto error;
- }
return addnhostsfile;
{
char *ipstr = NULL;
if (VIR_REALLOC_N(hostsfile->hosts, hostsfile->nhosts + 1) < 0)
- goto alloc_error;
+ goto error;
if (!(ipstr = virSocketAddrFormat(ip)))
return -1;
if (name && id) {
if (virAsprintf(&hostsfile->hosts[hostsfile->nhosts].host,
"id:%s,%s,[%s]", id, name, ipstr) < 0)
- goto alloc_error;
+ goto error;
} else if (name && !id) {
if (virAsprintf(&hostsfile->hosts[hostsfile->nhosts].host,
"%s,[%s]", name, ipstr) < 0)
- goto alloc_error;
+ goto error;
} else if (!name && id) {
if (virAsprintf(&hostsfile->hosts[hostsfile->nhosts].host,
"id:%s,[%s]", id, ipstr) < 0)
- goto alloc_error;
+ goto error;
}
} else if (name && mac) {
if (virAsprintf(&hostsfile->hosts[hostsfile->nhosts].host, "%s,%s,%s",
mac, ipstr, name) < 0)
- goto alloc_error;
+ goto error;
} else if (name && !mac){
if (virAsprintf(&hostsfile->hosts[hostsfile->nhosts].host, "%s,%s",
name, ipstr) < 0)
- goto alloc_error;
+ goto error;
} else {
if (virAsprintf(&hostsfile->hosts[hostsfile->nhosts].host, "%s,%s",
mac, ipstr) < 0)
- goto alloc_error;
+ goto error;
}
VIR_FREE(ipstr);
return 0;
- alloc_error:
- virReportOOMError();
+ error:
VIR_FREE(ipstr);
return -1;
}
{
dnsmasqHostsfile *hostsfile;
- if (VIR_ALLOC(hostsfile) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(hostsfile) < 0)
return NULL;
- }
hostsfile->hosts = NULL;
hostsfile->nhosts = 0;
if (virAsprintf(&hostsfile->path, "%s/%s.%s", config_dir, name,
- DNSMASQ_HOSTSFILE_SUFFIX) < 0) {
- virReportOOMError();
+ DNSMASQ_HOSTSFILE_SUFFIX) < 0)
goto error;
- }
return hostsfile;
{
dnsmasqContext *ctx;
- if (VIR_ALLOC(ctx) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ctx) < 0)
return NULL;
- }
if (VIR_STRDUP(ctx->config_dir, config_dir) < 0)
goto error;
goto cleanup;
}
- if (virAsprintf(&complete, "%s\n%s", version, help) < 0) {
- virReportOOMError();
+ if (virAsprintf(&complete, "%s\n%s", version, help) < 0)
goto cleanup;
- }
ret = dnsmasqCapsSetFromBuffer(caps, complete);
return NULL;
if (!(caps = virObjectNew(dnsmasqCapsClass)))
return NULL;
- if (!(caps->flags = virBitmapNew(DNSMASQ_CAPS_LAST))) {
- virReportOOMError();
+ if (!(caps->flags = virBitmapNew(DNSMASQ_CAPS_LAST)))
goto error;
- }
if (VIR_STRDUP(caps->binaryPath, binaryPath ? binaryPath : DNSMASQ) < 0)
goto error;
return caps;
}
/* Setup the poll file handle data structs */
- if (VIR_ALLOC_N(fds, *nfds) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(fds, *nfds) < 0)
return NULL;
- }
*nfds = 0;
for (i = 0; i < eventLoop.handlesCount; i++) {
return NULL;
}
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ret) < 0)
return NULL;
- }
mode = fcntl(*fd, F_GETFL);
int fd = -1;
int ret = -1;
- if (virAsprintf(&newfile, "%s.new", path) < 0) {
- virReportOOMError();
+ if (virAsprintf(&newfile, "%s.new", path) < 0)
goto cleanup;
- }
if ((fd = open(newfile, O_WRONLY | O_CREAT | O_TRUNC, mode)) < 0) {
virReportSystemError(errno, _("cannot create file '%s'"),
if (!STRPREFIX(de->d_name, "loop"))
continue;
- if (virAsprintf(&looppath, "/dev/%s", de->d_name) < 0) {
- virReportOOMError();
+ if (virAsprintf(&looppath, "/dev/%s", de->d_name) < 0)
goto cleanup;
- }
VIR_DEBUG("Checking up on device %s", looppath);
if ((fd = open(looppath, O_RDWR)) < 0) {
int ret = -1;
if (virAsprintf(&path, SYSFS_BLOCK_DIR "/%s/pid",
- devname) < 0) {
- virReportOOMError();
+ devname) < 0)
return -1;
- }
if (access(path, F_OK) < 0) {
if (errno == ENOENT)
if (rv < 0)
goto cleanup;
if (rv == 0) {
- if (virAsprintf(&ret, "/dev/%s", de->d_name) < 0) {
- virReportOOMError();
+ if (virAsprintf(&ret, "/dev/%s", de->d_name) < 0)
goto cleanup;
- }
goto cleanup;
}
}
continue;
if (virAsprintf(&filepath, "%s/%s",
- dir, de->d_name) < 0) {
- virReportOOMError();
+ dir, de->d_name) < 0)
goto cleanup;
- }
if (lstat(filepath, &sb) < 0) {
virReportSystemError(errno, _("Cannot access '%s'"),
char *path;
if (ext == NULL) {
- if (virAsprintf(&path, "%s/%s", dir, name) < 0) {
- virReportOOMError();
- return NULL;
- }
+ ignore_value(virAsprintf(&path, "%s/%s", dir, name));
} else {
- if (virAsprintf(&path, "%s/%s%s", dir, name, ext) < 0) {
- virReportOOMError();
- return NULL;
- }
+ ignore_value(virAsprintf(&path, "%s/%s%s", dir, name, ext));
}
return path;
if (size <= 0)
size = 256;
- if (VIR_ALLOC(table) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(table) < 0)
return NULL;
- }
table->seed = virRandomBits(32);
table->size = size;
table->keyFree = keyFree;
if (VIR_ALLOC_N(table->table, size) < 0) {
- virReportOOMError();
VIR_FREE(table);
return NULL;
}
return -1;
if (VIR_ALLOC_N(table->table, size) < 0) {
- virReportOOMError();
table->table = oldtable;
return -1;
}
}
if (VIR_ALLOC(entry) < 0 || !(new_name = table->keyCopy(name))) {
- virReportOOMError();
VIR_FREE(entry);
return -1;
}
if (numElems < 0)
return NULL;
- if (VIR_ALLOC_N(iter.sortArray, numElems + 1)) {
- virReportOOMError();
+ if (VIR_ALLOC_N(iter.sortArray, numElems + 1))
return NULL;
- }
virHashForEach(table, virHashGetKeysIterator, &iter);
char *processid = NULL;
if (virAsprintf(&processid, "%llu",
- (unsigned long long)getpid()) < 0) {
- virReportOOMError();
+ (unsigned long long)getpid()) < 0)
goto cleanup;
- }
if (!(username = virGetUserName(getuid())))
goto cleanup;
req.runlevel = '0' + level;
if (vroot) {
- if (virAsprintf(&path, "%s/%s", vroot, VIR_INITCTL_FIFO) < 0) {
- virReportOOMError();
+ if (virAsprintf(&path, "%s/%s", vroot, VIR_INITCTL_FIFO) < 0)
return -1;
- }
} else {
if (VIR_STRDUP(path, VIR_INITCTL_FIFO) < 0)
return -1;
if (!netstr)
return NULL;
- if (virAsprintf(&ret, "%s/%d", netstr, prefix) < 0)
- virReportOOMError();
+ ignore_value(virAsprintf(&ret, "%s/%d", netstr, prefix));
VIR_FREE(netstr);
return ret;
if (port->start < port->end && port->end < 65536) {
if (virAsprintf(&portRangeStr, ":%u-%u",
- port->start, port->end) < 0) {
- virReportOOMError();
+ port->start, port->end) < 0)
goto cleanup;
- }
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid port range '%u-%u'."),
portRangeStr ? portRangeStr : "");
}
- if (r < 0) {
- virReportOOMError();
+ if (r < 0)
goto cleanup;
- }
virCommandAddArgList(cmd, "--jump", "SNAT",
"--to-source", natRangeStr, NULL);
{
virKeyFilePtr conf;
- if (VIR_ALLOC(conf) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(conf) < 0)
goto error;
- }
if (!(conf->groups = virHashCreate(10,
virKeyFileEntryFree)))
const char *resname)
{
char *ret;
- if (lockspace->dir) {
- if (virAsprintf(&ret, "%s/%s", lockspace->dir, resname) < 0) {
- virReportOOMError();
- return NULL;
- }
- } else {
- if (VIR_STRDUP(ret, resname) < 0)
- return NULL;
- }
-
+ if (lockspace->dir)
+ ignore_value(virAsprintf(&ret, "%s/%s", lockspace->dir, resname));
+ else
+ ignore_value(VIR_STRDUP(ret, resname));
return ret;
}
goto error;
if (!(res->path = virLockSpaceGetResourcePath(lockspace, resname)))
- goto no_memory;
+ goto error;
if (flags & VIR_LOCK_SPACE_ACQUIRE_AUTOCREATE) {
while (1) {
res->lockHeld = true;
if (VIR_EXPAND_N(res->owners, res->nOwners, 1) < 0)
- goto no_memory;
+ goto error;
res->owners[res->nOwners-1] = owner;
return res;
-no_memory:
- virReportOOMError();
error:
virLockSpaceResourceFree(res);
return NULL;
size_t j;
int m;
- if (VIR_ALLOC(res) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(res) < 0)
goto error;
- }
res->fd = -1;
if (!(tmp = virJSONValueObjectGetString(child, "name"))) {
res->nOwners = m;
if (VIR_ALLOC_N(res->owners, res->nOwners) < 0) {
- virReportOOMError();
virLockSpaceResourceFree(res);
goto error;
}
virJSONValuePtr resources;
virHashKeyValuePairPtr pairs = NULL, tmp;
- if (!object) {
- virReportOOMError();
+ if (!object)
return NULL;
- }
virMutexLock(&lockspace->lock);
virJSONValuePtr owners = NULL;
size_t i;
- if (!child) {
- virReportOOMError();
+ if (!child)
goto error;
- }
if (virJSONValueArrayAppend(resources, child) < 0) {
virJSONValueFree(child);
if ((res->flags & VIR_LOCK_SPACE_ACQUIRE_SHARED) &&
(flags & VIR_LOCK_SPACE_ACQUIRE_SHARED)) {
- if (VIR_EXPAND_N(res->owners, res->nOwners, 1) < 0) {
- virReportOOMError();
+ if (VIR_EXPAND_N(res->owners, res->nOwners, 1) < 0)
goto cleanup;
- }
res->owners[res->nOwners-1] = owner;
goto done;
if (virAsprintf(&path, "%s/%s",
stateDir,
- linkdev) < 0) {
- virReportOOMError();
+ linkdev) < 0)
return -1;
- }
virMacAddrFormat(&oldmac, macstr);
if (virFileWriteStr(path, macstr, O_CREAT|O_TRUNC|O_WRONLY) < 0) {
virReportSystemError(errno, _("Unable to preserve mac for %s"),
if (virAsprintf(&path, "%s/%s",
stateDir,
- linkdev) < 0) {
- virReportOOMError();
+ linkdev) < 0)
return -1;
- }
if (virFileReadAll(path, VIR_MAC_STRING_BUFLEN, &macstr) < 0)
return -1;
"ip", "link", "set", ifname, "netns", NULL, NULL
};
- if (virAsprintf(&pid, "%lld", (long long) pidInNs) == -1) {
- virReportOOMError();
+ if (virAsprintf(&pid, "%lld", (long long) pidInNs) == -1)
return -1;
- }
argv[5] = pid;
rc = virRun(argv, NULL);
const char *file)
{
- if (virAsprintf(pf_sysfs_device_link, NET_SYSFS "%s/%s",
- ifname, file) < 0) {
- virReportOOMError();
- return -1;
- }
-
- return 0;
+ return virAsprintf(pf_sysfs_device_link, NET_SYSFS "%s/%s", ifname, file);
}
static int
const char *file)
{
- if (virAsprintf(pf_sysfs_device_link, NET_SYSFS "%s/device/%s",
- ifname, file) < 0) {
- virReportOOMError();
- return -1;
- }
-
- return 0;
+ return virAsprintf(pf_sysfs_device_link, NET_SYSFS "%s/device/%s",
+ ifname, file);
}
/**
n_vfname) < 0)
goto cleanup;
- if (VIR_ALLOC_N(*vfname, *n_vfname) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(*vfname, *n_vfname) < 0)
goto cleanup;
- }
for (i = 0; i < *n_vfname; i++)
{
goto cleanup;
if (virAsprintf(&path, "%s/%s_vf%d",
- stateDir, pflinkdev, vf) < 0) {
- virReportOOMError();
+ stateDir, pflinkdev, vf) < 0)
goto cleanup;
- }
if (virAsprintf(&fileData, "%s\n%d\n",
- virMacAddrFormat(&oldmac, macstr), oldvlanid) < 0) {
- virReportOOMError();
+ virMacAddrFormat(&oldmac, macstr), oldvlanid) < 0)
goto cleanup;
- }
if (virFileWriteStr(path, fileData, O_CREAT|O_TRUNC|O_WRONLY) < 0) {
virReportSystemError(errno, _("Unable to preserve mac/vlan tag "
"for pf = %s, vf = %d"), pflinkdev, vf);
int ifindex = -1;
if (virAsprintf(&path, "%s/%s_vf%d",
- stateDir, pflinkdev, vf) < 0) {
- virReportOOMError();
+ stateDir, pflinkdev, vf) < 0)
return rc;
- }
if (virFileReadAll(path, 128, &fileData) < 0) {
goto cleanup;
return 0;
}
- if (VIR_ALLOC(*dest) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(*dest) < 0)
goto cleanup;
- }
if (src->in) {
- if (VIR_ALLOC((*dest)->in) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC((*dest)->in) < 0)
goto cleanup;
- }
memcpy((*dest)->in, src->in, sizeof(*src->in));
}
if (src->out) {
if (VIR_ALLOC((*dest)->out) < 0) {
- virReportOOMError();
VIR_FREE((*dest)->in);
goto cleanup;
}
virAsprintf(&floor, "%llukbps", bandwidth->in->floor) < 0 ||
virAsprintf(&ceil, "%llukbps", net_bandwidth->in->peak ?
net_bandwidth->in->peak :
- net_bandwidth->in->average) < 0) {
- virReportOOMError();
+ net_bandwidth->in->average) < 0)
goto cleanup;
- }
cmd = virCommandNew(TC);
virCommandAddArgList(cmd, "class", "add", "dev", brname, "parent", "1:1",
if (virAsprintf(&class_id, "1:%x", id) < 0 ||
virAsprintf(&qdisc_id, "%x:", id) < 0 ||
- virAsprintf(&filter_id, "%u", id) < 0) {
- virReportOOMError();
+ virAsprintf(&filter_id, "%u", id) < 0)
goto cleanup;
- }
cmd = virCommandNew(TC);
virCommandAddArgList(cmd, "qdisc", "del", "dev", brname,
if (virAsprintf(&rate, "%llukbps", new_rate) < 0 ||
virAsprintf(&ceil, "%llukbps", bandwidth->in->peak ?
bandwidth->in->peak :
- bandwidth->in->average) < 0) {
- virReportOOMError();
+ bandwidth->in->average) < 0)
goto cleanup;
- }
cmd = virCommandNew(TC);
virCommandAddArgList(cmd, "class", "change", "dev", ifname,
char *path = NULL;
int ret = -1;
- if (virAsprintf(&path, "%s/%s/bridge/%s", SYSFS_NET_DIR, brname, paramname) < 0) {
- virReportOOMError();
+ if (virAsprintf(&path, "%s/%s/bridge/%s", SYSFS_NET_DIR, brname, paramname) < 0)
return -1;
- }
if (virFileExists(path)) {
char valuestr[INT_BUFSIZE_BOUND(value)];
char *path = NULL;
int ret = -1;
- if (virAsprintf(&path, "%s/%s/bridge/%s", SYSFS_NET_DIR, brname, paramname) < 0) {
- virReportOOMError();
+ if (virAsprintf(&path, "%s/%s/bridge/%s", SYSFS_NET_DIR, brname, paramname) < 0)
return -1;
- }
if (virFileExists(path)) {
char *valuestr;
if (virtPortProfile && virNetlinkEventServiceIsRunning(NETLINK_ROUTE)) {
if (VIR_ALLOC(calld) < 0)
- goto memory_error;
+ goto error;
if (VIR_STRDUP(calld->cr_ifname, ifname) < 0)
goto error;
if (VIR_ALLOC(calld->virtPortProfile) < 0)
- goto memory_error;
+ goto error;
memcpy(calld->virtPortProfile, virtPortProfile, sizeof(*virtPortProfile));
virMacAddrSet(&calld->macaddress, macaddress);
if (VIR_STRDUP(calld->linkdev, linkdev) < 0)
return 0;
-memory_error:
- virReportOOMError();
error:
virNetlinkCallbackDataFree(calld);
return -1;
if (virAsprintf(&attachedmac_ex_id, "external-ids:attached-mac=\"%s\"",
macaddrstr) < 0)
- goto out_of_memory;
+ goto cleanup;
if (virAsprintf(&ifaceid_ex_id, "external-ids:iface-id=\"%s\"",
ifuuidstr) < 0)
- goto out_of_memory;
+ goto cleanup;
if (virAsprintf(&vmid_ex_id, "external-ids:vm-id=\"%s\"",
vmuuidstr) < 0)
- goto out_of_memory;
+ goto cleanup;
if (ovsport->profileID[0] != '\0') {
if (virAsprintf(&profile_ex_id, "external-ids:port-profile=\"%s\"",
ovsport->profileID) < 0)
- goto out_of_memory;
+ goto cleanup;
}
cmd = virCommandNew(OVSVSCTL);
virBufferAsprintf(&buf, "%d", virtVlan->tag[i]);
}
- if (virBufferError(&buf))
- goto out_of_memory;
+ if (virBufferError(&buf)) {
+ virReportOOMError();
+ goto cleanup;
+ }
virCommandAddArg(cmd, virBufferCurrentContent(&buf));
} else if (virtVlan->nTags) {
virCommandAddArgFormat(cmd, "tag=%d", virtVlan->tag[0]);
VIR_FREE(profile_ex_id);
virCommandFree(cmd);
return ret;
-
-out_of_memory:
- virReportOOMError();
- goto cleanup;
}
/**
int i;
for (i = 0; i <= IF_MAXUNIT; i++) {
char *newname;
- if (virAsprintf(&newname, *ifname, i) < 0) {
- virReportOOMError();
+ if (virAsprintf(&newname, *ifname, i) < 0)
goto cleanup;
- }
if (virNetDevExists(newname) == 0) {
newifname = newname;
if (tapfd) {
char *dev_path = NULL;
- if (virAsprintf(&dev_path, "/dev/%s", ifr.ifr_name) < 0) {
- virReportOOMError();
+ if (virAsprintf(&dev_path, "/dev/%s", ifr.ifr_name) < 0)
goto cleanup;
- }
if ((*tapfd = open(dev_path, O_RDWR)) < 0) {
virReportSystemError(errno,
do {
VIR_FREE(path);
++devNum;
- if (virAsprintf(&path, "/sys/class/net/veth%d/", devNum) < 0) {
- virReportOOMError();
+ if (virAsprintf(&path, "/sys/class/net/veth%d/", devNum) < 0)
return -1;
- }
VIR_DEBUG("Probe %s", path);
} while (virFileExists(path));
VIR_FREE(path);
- if (virAsprintf(veth, "veth%d", devNum) < 0) {
- virReportOOMError();
+ if (virAsprintf(veth, "veth%d", devNum) < 0)
return -1;
- }
return devNum;
}
if (!src || src->nTags == 0)
return 0;
- if (VIR_ALLOC_N(dst->tag, src->nTags) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(dst->tag, src->nTags) < 0)
return -1;
- }
dst->trunk = src->trunk;
dst->nTags = src->nTags;
}
/* at least one of the source profiles is non-empty */
- if (VIR_ALLOC(*result) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(*result) < 0)
return ret;
- }
/* start with the interface's profile. There are no pointers in a
* virtualPortProfile, so a shallow copy is sufficient.
VIR_INFO("starting netlink event service with protocol %d", protocol);
- if (VIR_ALLOC(srv) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(srv) < 0)
return -1;
- }
if (virMutexInit(&srv->lock) < 0) {
VIR_FREE(srv);
VIR_DEBUG("Used %zu handle slots, adding at least %d more",
srv->handlesAlloc, NETLINK_EVENT_ALLOC_EXTENT);
if (VIR_RESIZE_N(srv->handles, srv->handlesAlloc,
- srv->handlesCount, NETLINK_EVENT_ALLOC_EXTENT) < 0) {
- virReportOOMError();
+ srv->handlesCount, NETLINK_EVENT_ALLOC_EXTENT) < 0)
goto error;
- }
}
r = srv->handlesCount++;
return NULL;
}
- if (VIR_ALLOC(klass) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(klass) < 0)
goto error;
- }
klass->parent = parent;
if (VIR_STRDUP(klass->name, name) < 0)
if (VIR_ALLOC_VAR(obj,
char,
- klass->objectSize - sizeof(virObject)) < 0) {
- virReportOOMError();
+ klass->objectSize - sizeof(virObject)) < 0)
return NULL;
- }
obj->magic = klass->magic;
obj->klass = klass;
* device is a VF, we just assume FLR works
*/
- if (virAsprintf(&path, PCI_SYSFS "devices/%s/physfn", dev->name) < 0) {
- virReportOOMError();
+ if (virAsprintf(&path, PCI_SYSFS "devices/%s/physfn", dev->name) < 0)
return -1;
- }
found = virFileExists(path);
VIR_FREE(path);
{
VIR_FREE(*buffer);
- if (virAsprintf(buffer, PCI_SYSFS "drivers/%s", driver) < 0) {
- virReportOOMError();
- return -1;
- }
-
- return 0;
+ return virAsprintf(buffer, PCI_SYSFS "drivers/%s", driver);
}
static int
{
VIR_FREE(*buffer);
- if (virAsprintf(buffer, PCI_SYSFS "drivers/%s/%s", driver, file) < 0) {
- virReportOOMError();
- return -1;
- }
-
- return 0;
+ return virAsprintf(buffer, PCI_SYSFS "drivers/%s/%s", driver, file);
}
static int
{
VIR_FREE(*buffer);
- if (virAsprintf(buffer, PCI_SYSFS "devices/%s/%s", device, file) < 0) {
- virReportOOMError();
- return -1;
- }
-
- return 0;
+ return virAsprintf(buffer, PCI_SYSFS "devices/%s/%s", device, file);
}
char *vendor = NULL;
char *product = NULL;
- if (VIR_ALLOC(dev) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(dev) < 0)
return NULL;
- }
dev->domain = domain;
dev->bus = bus;
goto error;
}
if (virAsprintf(&dev->path, PCI_SYSFS "devices/%s/config",
- dev->name) < 0) {
- virReportOOMError();
+ dev->name) < 0)
goto error;
- }
if (access(dev->path, F_OK) != 0) {
virReportSystemError(errno,
{
virPCIDevicePtr copy;
- if (VIR_ALLOC(copy) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(copy) < 0)
return NULL;
- }
/* shallow copy to take care of most attributes */
*copy = *dev;
return -1;
}
- if (VIR_REALLOC_N(list->devs, list->count+1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(list->devs, list->count+1) < 0)
return -1;
- }
list->devs[list->count++] = dev;
struct dirent *ent;
if (virAsprintf(&pcidir, "/sys/bus/pci/devices/%04x:%02x:%02x.%x",
- dev->domain, dev->bus, dev->slot, dev->function) < 0) {
- virReportOOMError();
+ dev->domain, dev->bus, dev->slot, dev->function) < 0)
goto cleanup;
- }
if (!(dir = opendir(pcidir))) {
virReportSystemError(errno,
STRPREFIX(ent->d_name, "resource") ||
STREQ(ent->d_name, "rom") ||
STREQ(ent->d_name, "reset")) {
- if (virAsprintf(&file, "%s/%s", pcidir, ent->d_name) < 0) {
- virReportOOMError();
+ if (virAsprintf(&file, "%s/%s", pcidir, ent->d_name) < 0)
goto cleanup;
- }
if ((actor)(dev, file, opaque) < 0)
goto cleanup;
if (virAsprintf(&groupPath,
PCI_SYSFS "devices/%04x:%02x:%02x.%x/iommu_group/devices",
- orig->domain, orig->bus, orig->slot, orig->function) < 0) {
- virReportOOMError();
+ orig->domain, orig->bus, orig->slot, orig->function) < 0)
goto cleanup;
- }
if (!(groupDir = opendir(groupPath))) {
/* just process the original device, nothing more */
*copyAddr = *newDevAddr;
- if (VIR_APPEND_ELEMENT_QUIET(*addrList->iommuGroupDevices,
- *addrList->nIommuGroupDevices, copyAddr) < 0) {
- virReportOOMError();
+ if (VIR_APPEND_ELEMENT(*addrList->iommuGroupDevices,
+ *addrList->nIommuGroupDevices, copyAddr) < 0)
goto cleanup;
- }
ret = 0;
cleanup:
int ret = -1;
if (virAsprintf(&devName, "%.4x:%.2x:%.2x.%.1x", addr->domain,
- addr->bus, addr->slot, addr->function) < 0) {
- virReportOOMError();
+ addr->bus, addr->slot, addr->function) < 0)
goto cleanup;
- }
if (virPCIFile(&devPath, devName, "iommu_group") < 0)
goto cleanup;
goto cleanup;
}
if (virAsprintf(&groupDev, "/dev/vfio/%s",
- last_component(groupPath)) < 0) {
- virReportOOMError();
+ last_component(groupPath)) < 0)
goto cleanup;
- }
cleanup:
VIR_FREE(devPath);
VIR_FREE(groupPath);
}
config_address = last_component(device_path);
- if (VIR_ALLOC(*bdf) != 0) {
- virReportOOMError();
+ if (VIR_ALLOC(*bdf) != 0)
goto out;
- }
if (virPCIDeviceAddressParse(config_address, *bdf) != 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
if (VIR_REALLOC_N(*virtual_functions,
*num_virtual_functions + 1) < 0) {
- virReportOOMError();
VIR_FREE(config_addr);
goto error;
}
int ret = -1;
if (virAsprintf(&vf_sysfs_physfn_link, "%s/physfn",
- vf_sysfs_device_link) < 0) {
- virReportOOMError();
+ vf_sysfs_device_link) < 0)
return ret;
- }
ret = virFileExists(vf_sysfs_physfn_link);
int
virPCIGetSysfsFile(char *virPCIDeviceName, char **pci_sysfs_device_link)
{
- if (virAsprintf(pci_sysfs_device_link, PCI_SYSFS "devices/%s",
- virPCIDeviceName) < 0) {
- virReportOOMError();
- return -1;
- }
-
- return 0;
+ return virAsprintf(pci_sysfs_device_link, PCI_SYSFS "devices/%s",
+ virPCIDeviceName);
}
int
virPCIDeviceAddressGetSysfsFile(virPCIDeviceAddressPtr dev,
char **pci_sysfs_device_link)
{
- if (virAsprintf(pci_sysfs_device_link,
- PCI_SYSFS "devices/%04x:%02x:%02x.%x", dev->domain,
- dev->bus, dev->slot, dev->function) < 0) {
- virReportOOMError();
- return -1;
- }
-
- return 0;
+ return virAsprintf(pci_sysfs_device_link,
+ PCI_SYSFS "devices/%04x:%02x:%02x.%x", dev->domain,
+ dev->bus, dev->slot, dev->function);
}
/*
pa->end = end;
if (!(pa->bitmap = virBitmapNew((end-start)+1))) {
- virReportOOMError();
virObjectUnref(pa);
return NULL;
}
}
*map = virBitmapNew(maxcpu);
- if (!*map) {
- virReportOOMError();
+ if (!*map)
return -1;
- }
for (i = 0; i < maxcpu; i++)
if (CPU_ISSET_S(i, masklen, mask))
virBitmapPtr *map,
int maxcpu)
{
- if (!(*map = virBitmapNew(maxcpu))) {
- virReportOOMError();
+ if (!(*map = virBitmapNew(maxcpu)))
return -1;
- }
virBitmapSetAll(*map);
return 0;
if (virAsprintf(&nsfile, "/proc/%llu/ns/%s",
(unsigned long long)pid,
- ns[i]) < 0) {
- virReportOOMError();
+ ns[i]) < 0)
goto cleanup;
- }
if ((fd = open(nsfile, O_RDWR)) >= 0) {
if (VIR_EXPAND_N(*fdlist, *nfdlist, 1) < 0) {
VIR_FORCE_CLOSE(fd);
- virReportOOMError();
goto cleanup;
}
char **tokens = NULL;
if (virAsprintf(&filename, "/proc/%llu/stat",
- (unsigned long long)pid) < 0) {
- virReportOOMError();
+ (unsigned long long)pid) < 0)
return -1;
- }
if ((len = virFileReadAll(filename, 1024, &buf)) < 0)
goto cleanup;
return -1;
}
- if (virAsprintf(wwn, "5" "%s%09llx", oui,
- (unsigned long long)virRandomBits(36)) < 0) {
- virReportOOMError();
- return -1;
- }
-
- return 0;
+ return virAsprintf(wwn, "5" "%s%09llx", oui,
+ (unsigned long long)virRandomBits(36));
}
if (virAsprintf(&path,
SYSFS_SCSI_DEVICES "/%d:%d:%d:%d/scsi_generic",
- adapter_id, bus, target, unit) < 0) {
- virReportOOMError();
+ adapter_id, bus, target, unit) < 0)
return NULL;
- }
if (!(dir = opendir(path))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
if (virAsprintf(&path,
SYSFS_SCSI_DEVICES "/%d:%d:%d:%d/block",
- adapter_id, bus, target, unit) < 0) {
- virReportOOMError();
+ adapter_id, bus, target, unit) < 0)
return NULL;
- }
if (!(dir = opendir(path))) {
virReportError(VIR_ERR_INTERNAL_ERROR,
char *vendor = NULL;
char *model = NULL;
- if (VIR_ALLOC(dev) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(dev) < 0)
return NULL;
- }
dev->bus = bus;
dev->target = target;
if (virAsprintf(&dev->name, "%d:%d:%d:%d", dev->adapter,
dev->bus, dev->target, dev->unit) < 0 ||
- virAsprintf(&dev->sg_path, "/dev/%s", sg) < 0) {
- virReportOOMError();
+ virAsprintf(&dev->sg_path, "/dev/%s", sg) < 0)
goto cleanup;
- }
if (access(dev->sg_path, F_OK) != 0) {
virReportSystemError(errno,
if (virAsprintf(&vendor_path,
SYSFS_SCSI_DEVICES "/%s/vendor", dev->name) < 0 ||
virAsprintf(&model_path,
- SYSFS_SCSI_DEVICES "/%s/model", dev->name) < 0) {
- virReportOOMError();
+ SYSFS_SCSI_DEVICES "/%s/model", dev->name) < 0)
goto cleanup;
- }
if (virFileReadAll(vendor_path, 1024, &vendor) < 0)
goto cleanup;
virTrimSpaces(vendor, NULL);
virTrimSpaces(model, NULL);
- if (virAsprintf(&dev->id, "%s:%s", vendor, model) < 0) {
- virReportOOMError();
+ if (virAsprintf(&dev->id, "%s:%s", vendor, model) < 0)
goto cleanup;
- }
ret = dev;
cleanup:
return -1;
}
- if (VIR_REALLOC_N(list->devs, list->count + 1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(list->devs, list->count + 1) < 0)
return -1;
- }
list->devs[list->count++] = dev;
{
struct sexpr *ret;
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ret) < 0)
return NULL;
- }
ret->kind = SEXPR_NIL;
return ret;
}
if (withService) {
if (virAsprintf(&addrstr, "127.0.0.1%s0",
separator ? separator : ":") < 0)
- goto no_memory;
+ goto error;
} else {
if (VIR_STRDUP(addrstr, "127.0.0.1") < 0)
goto error;
if (withService) {
if (virAsprintf(&addrstr, "%s%s%s", host, separator, port) == -1)
- goto no_memory;
+ goto error;
} else {
if (VIR_STRDUP(addrstr, host) < 0)
goto error;
return addrstr;
-no_memory:
- virReportOOMError();
error:
return NULL;
}
return BACKING_STORE_INVALID;
if (size + 1 == 0)
return BACKING_STORE_INVALID;
- if (VIR_ALLOC_N(*res, size + 1) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(*res, size + 1) < 0)
return BACKING_STORE_ERROR;
- }
memcpy(*res, buf + offset, size);
(*res)[size] = '\0';
size_t len;
int ret = BACKING_STORE_ERROR;
- if (VIR_ALLOC_N(desc, STORAGE_MAX_HEAD + 1) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(desc, STORAGE_MAX_HEAD + 1) < 0)
goto cleanup;
- }
*res = NULL;
/*
return BACKING_STORE_OK;
if (offset + size > buf_size || offset + size < offset)
return BACKING_STORE_INVALID;
- if (VIR_ALLOC_N(*res, size + 1) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(*res, size + 1) < 0)
return BACKING_STORE_ERROR;
- }
memcpy(*res, buf + offset, size);
(*res)[size] = '\0';
start = ".";
d_len = 1;
}
- if (virAsprintf(&combined, "%.*s/%s", (int)d_len, start, path) < 0) {
- virReportOOMError();
+ if (virAsprintf(&combined, "%.*s/%s", (int)d_len, start, path) < 0)
goto cleanup;
- }
}
if (directory && !(*directory = mdir_name(combined))) {
if (len < QCOW2v3_HDR_SIZE)
return -1;
- if (!(feat = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST))) {
- virReportOOMError();
+ if (!(feat = virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST)))
return -1;
- }
/* todo: check for incompatible or autoclear features? */
bits = virReadBufInt64BE(buf + QCOW2v3_HDR_FEATURES_COMPATIBLE);
VIR_DEBUG("path=%s, fd=%d, format=%d", path, fd, format);
- if (VIR_ALLOC(meta) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(meta) < 0)
return NULL;
- }
if (fstat(fd, &sb) < 0) {
virReportSystemError(errno,
goto cleanup;
}
- if (VIR_ALLOC_N(buf, len) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(buf, len) < 0)
goto cleanup;
- }
if ((len = read(fd, buf, len)) < 0) {
virReportSystemError(errno, _("cannot read header '%s'"), path);
return VIR_STORAGE_FILE_DIR;
}
- if (VIR_ALLOC_N(head, len) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(head, len) < 0)
return -1;
- }
if (lseek(fd, 0, SEEK_SET) == (off_t)-1) {
virReportSystemError(errno, _("cannot set to start of '%s'"), path);
size_t len = tmp - remainder;
if (VIR_RESIZE_N(tokens, maxtokens, ntokens, 1) < 0)
- goto no_memory;
+ goto error;
if (VIR_STRNDUP(tokens[ntokens], remainder, len) < 0)
goto error;
}
if (*string) {
if (VIR_RESIZE_N(tokens, maxtokens, ntokens, 1) < 0)
- goto no_memory;
+ goto error;
if (VIR_STRDUP(tokens[ntokens], remainder) < 0)
goto error;
}
if (VIR_RESIZE_N(tokens, maxtokens, ntokens, 1) < 0)
- goto no_memory;
+ goto error;
tokens[ntokens++] = NULL;
return tokens;
-no_memory:
- virReportOOMError();
error:
for (i = 0; i < ntokens; i++)
VIR_FREE(tokens[i]);
eol = strchr(base, '\n');
cur = strchr(base, ':') + 1;
- if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) {
- virReportOOMError();
+ if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0)
goto error;
- }
processor = &ret->processor[ret->nprocessor - 1];
virSkipSpaces(&cur);
while ((tmp_base = strstr(tmp_base, "processor "))
&& (tmp_base = virSysinfoParseLine(tmp_base, "processor ",
&procline))) {
- if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) {
- virReportOOMError();
+ if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0)
goto cleanup;
- }
processor = &ret->processor[ret->nprocessor - 1];
if (VIR_STRDUP(processor->processor_manufacturer, manufacturer) < 0)
goto cleanup;
goto cleanup;
if (VIR_ALLOC(ret) < 0)
- goto no_memory;
+ goto error;
ret->type = VIR_SYSINFO_SMBIOS;
if (virSysinfoParseBIOS(outbuf, ret) < 0)
- goto no_memory;
+ goto error;
if (virSysinfoParseSystem(outbuf, ret) < 0)
- goto no_memory;
+ goto error;
ret->nprocessor = 0;
ret->processor = NULL;
if (virSysinfoParseProcessor(outbuf, ret) < 0)
- goto no_memory;
+ goto error;
ret->nmemory = 0;
ret->memory = NULL;
if (virSysinfoParseMemory(outbuf, ret) < 0)
- goto no_memory;
+ goto error;
cleanup:
VIR_FREE(outbuf);
return ret;
-no_memory:
- virReportOOMError();
-
+error:
virSysinfoDefFree(ret);
ret = NULL;
goto cleanup;
if (minWorkers > maxWorkers)
minWorkers = maxWorkers;
- if (VIR_ALLOC(pool) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(pool) < 0)
return NULL;
- }
pool->jobList.tail = pool->jobList.head = NULL;
pool->maxWorkers = maxWorkers;
for (i = 0; i < minWorkers; i++) {
- if (VIR_ALLOC(data) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(data) < 0)
goto error;
- }
data->pool = pool;
data->cond = &pool->cond;
goto error;
for (i = 0; i < prioWorkers; i++) {
- if (VIR_ALLOC(data) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(data) < 0)
goto error;
- }
data->pool = pool;
data->cond = &pool->prioCond;
data->priority = true;
if (pool->freeWorkers - pool->jobQueueDepth <= 0 &&
pool->nWorkers < pool->maxWorkers) {
- if (VIR_EXPAND_N(pool->workers, pool->nWorkers, 1) < 0) {
- virReportOOMError();
+ if (VIR_EXPAND_N(pool->workers, pool->nWorkers, 1) < 0)
goto error;
- }
if (VIR_ALLOC(data) < 0) {
pool->nWorkers--;
- virReportOOMError();
goto error;
}
}
}
- if (VIR_ALLOC(job) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(job) < 0)
goto error;
- }
job->data = jobData;
job->priority = priority;
{
char *ret;
- if (VIR_ALLOC_N(ret, VIR_TIME_STRING_BUFLEN) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(ret, VIR_TIME_STRING_BUFLEN) < 0)
return NULL;
- }
if (virTimeStringNowRaw(ret) < 0) {
virReportSystemError(errno, "%s",
{
char *ret;
- if (VIR_ALLOC_N(ret, VIR_TIME_STRING_BUFLEN) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(ret, VIR_TIME_STRING_BUFLEN) < 0)
return NULL;
- }
if (virTimeStringThenRaw(when, ret) < 0) {
virReportSystemError(errno, "%s",
if (dev) {
dev++;
if (virAsprintf(&path, "/sys/class/misc/%s/device/cancel",
- dev) < 0) {
- virReportOOMError();
+ dev) < 0)
goto cleanup;
- }
} else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("TPM device path %s is invalid"), devpath);
char *
virTypedParameterToString(virTypedParameterPtr param)
{
- char *value;
- int ret = -1;
+ char *value = NULL;
switch (param->type) {
case VIR_TYPED_PARAM_INT:
- if ((ret = virAsprintf(&value, "%d", param->value.i)) < 0)
- virReportOOMError();
+ ignore_value(virAsprintf(&value, "%d", param->value.i));
break;
case VIR_TYPED_PARAM_UINT:
- if ((ret = virAsprintf(&value, "%u", param->value.ui)) < 0)
- virReportOOMError();
+ ignore_value(virAsprintf(&value, "%u", param->value.ui));
break;
case VIR_TYPED_PARAM_LLONG:
- if ((ret = virAsprintf(&value, "%lld", param->value.l)) < 0)
- virReportOOMError();
+ ignore_value(virAsprintf(&value, "%lld", param->value.l));
break;
case VIR_TYPED_PARAM_ULLONG:
- if ((ret = virAsprintf(&value, "%llu", param->value.ul)) < 0)
- virReportOOMError();
+ ignore_value(virAsprintf(&value, "%llu", param->value.ul));
break;
case VIR_TYPED_PARAM_DOUBLE:
- if ((ret = virAsprintf(&value, "%g", param->value.d)) < 0)
- virReportOOMError();
+ ignore_value(virAsprintf(&value, "%g", param->value.d));
break;
case VIR_TYPED_PARAM_BOOLEAN:
- if ((ret = virAsprintf(&value, "%d", param->value.b)) < 0)
- virReportOOMError();
+ ignore_value(virAsprintf(&value, "%d", param->value.b));
break;
case VIR_TYPED_PARAM_STRING:
- ret = VIR_STRDUP(value, param->value.s);
+ ignore_value(VIR_STRDUP(value, param->value.s));
break;
default:
virReportError(VIR_ERR_INTERNAL_ERROR,
param->type, param->field);
}
- if (ret < 0)
- return NULL;
- else
- return value;
+ return value;
}
/* Assign name, type, and the appropriately typed arg to param; in the
}
old = param->value.s;
} else {
- if (VIR_EXPAND_N(*params, n, 1) < 0) {
- virReportOOMError();
+ if (VIR_EXPAND_N(*params, n, 1) < 0)
goto error;
- }
param = *params + n - 1;
}
if (!src || nparams <= 0)
return 0;
- if (VIR_ALLOC_N(*dst, nparams) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(*dst, nparams) < 0)
return -1;
- }
for (i = 0; i < nparams; i++) {
ignore_value(virStrcpyStatic((*dst)[i].field, src[i].field));
virResetLastError();
VIR_TYPED_PARAM_CHECK();
- if (VIR_RESIZE_N(*params, max, n, 1) < 0) {
- virReportOOMError();
+ if (VIR_RESIZE_N(*params, max, n, 1) < 0)
goto error;
- }
*maxparams = max;
if (virTypedParameterAssign(*params + n, name,
virResetLastError();
VIR_TYPED_PARAM_CHECK();
- if (VIR_RESIZE_N(*params, max, n, 1) < 0) {
- virReportOOMError();
+ if (VIR_RESIZE_N(*params, max, n, 1) < 0)
goto error;
- }
*maxparams = max;
if (virTypedParameterAssign(*params + n, name,
virResetLastError();
VIR_TYPED_PARAM_CHECK();
- if (VIR_RESIZE_N(*params, max, n, 1) < 0) {
- virReportOOMError();
+ if (VIR_RESIZE_N(*params, max, n, 1) < 0)
goto error;
- }
*maxparams = max;
if (virTypedParameterAssign(*params + n, name,
virResetLastError();
VIR_TYPED_PARAM_CHECK();
- if (VIR_RESIZE_N(*params, max, n, 1) < 0) {
- virReportOOMError();
+ if (VIR_RESIZE_N(*params, max, n, 1) < 0)
goto error;
- }
*maxparams = max;
if (virTypedParameterAssign(*params + n, name,
virResetLastError();
VIR_TYPED_PARAM_CHECK();
- if (VIR_RESIZE_N(*params, max, n, 1) < 0) {
- virReportOOMError();
+ if (VIR_RESIZE_N(*params, max, n, 1) < 0)
goto error;
- }
*maxparams = max;
if (virTypedParameterAssign(*params + n, name,
virResetLastError();
VIR_TYPED_PARAM_CHECK();
- if (VIR_RESIZE_N(*params, max, n, 1) < 0) {
- virReportOOMError();
+ if (VIR_RESIZE_N(*params, max, n, 1) < 0)
goto error;
- }
*maxparams = max;
if (virTypedParameterAssign(*params + n, name,
virResetLastError();
VIR_TYPED_PARAM_CHECK();
- if (VIR_RESIZE_N(*params, max, n, 1) < 0) {
- virReportOOMError();
+ if (VIR_RESIZE_N(*params, max, n, 1) < 0)
goto error;
- }
*maxparams = max;
if (VIR_STRDUP(str, value) < 0)
virResetLastError();
VIR_TYPED_PARAM_CHECK();
- if (VIR_RESIZE_N(*params, max, n, 1) < 0) {
- virReportOOMError();
+ if (VIR_RESIZE_N(*params, max, n, 1) < 0)
goto error;
- }
*maxparams = max;
if (virTypedParameterAssignFromStr(*params + n, name, type, value) < 0)
if (VIR_STRDUP(pname, name) < 0 || VIR_STRDUP(pvalue, value) < 0)
goto error;
- if (VIR_RESIZE_N(uri->params, uri->paramsAlloc, uri->paramsCount, 1) < 0) {
- virReportOOMError();
+ if (VIR_RESIZE_N(uri->params, uri->paramsAlloc, uri->paramsCount, 1) < 0)
goto error;
- }
uri->params[uri->paramsCount].name = pname;
uri->params[uri->paramsCount].value = pvalue;
return NULL;
}
- if (VIR_ALLOC(ret) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(ret) < 0)
goto error;
- }
if (VIR_STRDUP(ret->scheme, xmluri->scheme) < 0)
goto error;
if (xmluri.server != NULL &&
strchr(xmluri.server, ':') != NULL) {
- if (virAsprintf(&tmpserver, "[%s]", xmluri.server) < 0) {
- virReportOOMError();
+ if (virAsprintf(&tmpserver, "[%s]", xmluri.server) < 0)
return NULL;
- }
xmluri.server = tmpserver;
}
char *ignore = NULL;
tmp = virAsprintf(&filename, USB_SYSFS "/devices/%s/%s", d_name, f_name);
- if (tmp < 0) {
- virReportOOMError();
+ if (tmp < 0)
goto cleanup;
- }
if (virFileReadAll(filename, 1024, &buf) < 0)
goto cleanup;
{
virUSBDevicePtr dev;
- if (VIR_ALLOC(dev) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(dev) < 0)
return NULL;
- }
dev->bus = bus;
dev->dev = devno;
if (virAsprintf(&dev->path, "%s" USB_DEVFS "%03d/%03d",
vroot ? vroot : "",
dev->bus, dev->dev) < 0) {
- virReportOOMError();
virUSBDeviceFree(dev);
return NULL;
}
return -1;
}
- if (VIR_REALLOC_N(list->devs, list->count+1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(list->devs, list->count+1) < 0)
return -1;
- }
list->devs[list->count++] = dev;
buf = ((fds[i].fd == outfd) ? outbuf : errbuf);
size = (*buf ? strlen(*buf) : 0);
- if (VIR_REALLOC_N(*buf, size+got+1) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(*buf, size+got+1) < 0)
goto error;
- }
memmove(*buf+size, data, got);
(*buf)[size+got] = '\0';
}
offset = strlen(prefix);
- if (VIR_ALLOC_N(name, offset + i + 1)) {
- virReportOOMError();
+ if (VIR_ALLOC_N(name, offset + i + 1))
return NULL;
- }
strcpy(name, prefix);
name[offset + i] = '\0';
freeaddrinfo(info);
cleanup:
- if (result == NULL)
- virReportOOMError();
return result;
}
if (val < 0)
strbuflen = 1024;
- if (VIR_ALLOC_N(strbuf, strbuflen) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(strbuf, strbuflen) < 0)
return NULL;
- }
/*
* From the manpage (terrifying but true):
* The given name or uid was not found.
*/
while ((rc = getpwuid_r(uid, &pwbuf, strbuf, strbuflen, &pw)) == ERANGE) {
- if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0) {
- virReportOOMError();
+ if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0)
VIR_FREE(strbuf);
return NULL;
- }
}
if (rc != 0 || pw == NULL) {
virReportSystemError(rc,
if (val < 0)
strbuflen = 1024;
- if (VIR_ALLOC_N(strbuf, strbuflen) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(strbuf, strbuflen) < 0)
return NULL;
- }
/*
* From the manpage (terrifying but true):
*/
while ((rc = getgrgid_r(gid, &grbuf, strbuf, strbuflen, &gr)) == ERANGE) {
if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0) {
- virReportOOMError();
VIR_FREE(strbuf);
return NULL;
}
char *home = NULL;
if (path && path[0]) {
- if (virAsprintf(&ret, "%s/libvirt", path) < 0)
- goto no_memory;
+ ignore_value(virAsprintf(&ret, "%s/libvirt", path));
} else {
home = virGetUserEnt(geteuid(), VIR_USER_ENT_DIRECTORY);
- if (virAsprintf(&ret, "%s/%s/libvirt", home, xdgdefdir) < 0)
- goto no_memory;
+ ignore_value(virAsprintf(&ret, "%s/%s/libvirt", home, xdgdefdir));
}
- cleanup:
VIR_FREE(home);
return ret;
- no_memory:
- virReportOOMError();
- goto cleanup;
}
char *virGetUserConfigDirectory(void)
} else {
char *ret;
- if (virAsprintf(&ret, "%s/libvirt", path) < 0) {
- virReportOOMError();
- return NULL;
- }
-
+ ignore_value(virAsprintf(&ret, "%s/libvirt", path));
return ret;
}
}
if (val < 0)
strbuflen = 1024;
- if (VIR_ALLOC_N(strbuf, strbuflen) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(strbuf, strbuflen) < 0)
goto cleanup;
- }
while ((rc = getpwnam_r(name, &pwbuf, strbuf, strbuflen, &pw)) == ERANGE) {
- if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0) {
- virReportOOMError();
+ if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0)
goto cleanup;
- }
}
if (!pw) {
if (val < 0)
strbuflen = 1024;
- if (VIR_ALLOC_N(strbuf, strbuflen) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(strbuf, strbuflen) < 0)
goto cleanup;
- }
while ((rc = getgrnam_r(name, &grbuf, strbuf, strbuflen, &gr)) == ERANGE) {
- if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0) {
- virReportOOMError();
+ if (VIR_RESIZE_N(strbuf, strbuflen, strbuflen, strbuflen) < 0)
goto cleanup;
- }
}
if (!gr) {
bufsize = 16384;
if (VIR_ALLOC_N(buf, bufsize) < 0) {
- virReportOOMError();
err = ENOMEM;
goto error;
}
while ((rc = getpwuid_r(uid, &pwd, buf, bufsize,
&pwd_result)) == ERANGE) {
if (VIR_RESIZE_N(buf, bufsize, bufsize, bufsize) < 0) {
- virReportOOMError();
err = ENOMEM;
goto error;
}
return NULL;
}
- if (virAsprintf(&sysfs_path, "%s/%d:%d/queue/unpriv_sgio",
- sysfs_dir ? sysfs_dir : SYSFS_DEV_BLOCK_PATH,
- maj, min) < 0) {
- virReportOOMError();
- return NULL;
- }
-
+ ignore_value(virAsprintf(&sysfs_path, "%s/%d:%d/queue/unpriv_sgio",
+ sysfs_dir ? sysfs_dir : SYSFS_DEV_BLOCK_PATH,
+ maj, min));
return sysfs_path;
}
goto cleanup;
}
- if (virAsprintf(&val, "%d", unpriv_sgio) < 0) {
- virReportOOMError();
+ if (virAsprintf(&val, "%d", unpriv_sgio) < 0)
goto cleanup;
- }
if ((rc = virFileWriteStr(sysfs_path, val, 0)) < 0) {
virReportSystemError(-rc, _("failed to set %s"), sysfs_path);
if (virAsprintf(&sysfs_path, "%s/host%d/%s",
sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH,
- host, entry) < 0) {
- virReportOOMError();
+ host, entry) < 0)
goto cleanup;
- }
if (virFileReadAll(sysfs_path, 1024, &buf) < 0)
goto cleanup;
if (virAsprintf(&sysfs_path, "%s/host%d",
sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH,
- host) < 0) {
- virReportOOMError();
+ host) < 0)
return false;
- }
if (access(sysfs_path, F_OK) == 0)
ret = true;
"%s/host%d/%s",
sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH,
host,
- "vport_create") < 0) {
- virReportOOMError();
+ "vport_create") < 0)
return false;
- }
if (virAsprintf(&scsi_host_path,
"%s/host%d/%s",
sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_HOST_PATH,
host,
- "vport_create") < 0) {
- virReportOOMError();
+ "vport_create") < 0)
goto cleanup;
- }
if ((access(fc_host_path, F_OK) == 0) ||
(access(scsi_host_path, F_OK) == 0))
"%s/host%d/%s",
SYSFS_FC_HOST_PATH,
parent_host,
- operation_file) < 0) {
- virReportOOMError();
+ operation_file) < 0)
goto cleanup;
- }
if (!virFileExists(operation_path)) {
VIR_FREE(operation_path);
"%s/host%d/%s",
SYSFS_SCSI_HOST_PATH,
parent_host,
- operation_file) < 0) {
- virReportOOMError();
+ operation_file) < 0)
goto cleanup;
- }
if (!virFileExists(operation_path)) {
virReportError(VIR_ERR_OPERATION_INVALID,
if (virAsprintf(&vport_name,
"%s:%s",
wwpn,
- wwnn) < 0) {
- virReportOOMError();
+ wwnn) < 0)
goto cleanup;
- }
if (virFileWriteStr(operation_path, vport_name, 0) == 0)
ret = 0;
continue;
if (virAsprintf(&wwnn_path, "%s/%s/node_name", prefix,
- entry->d_name) < 0) {
- virReportOOMError();
+ entry->d_name) < 0)
goto cleanup;
- }
if (!virFileExists(wwnn_path)) {
VIR_FREE(wwnn_path);
}
if (virAsprintf(&wwpn_path, "%s/%s/port_name", prefix,
- entry->d_name) < 0) {
- virReportOOMError();
+ entry->d_name) < 0)
goto cleanup;
- }
if (!virFileExists(wwpn_path)) {
VIR_FREE(wwnn_buf);
ret = obj->nodesetval->nodeNr;
if (list != NULL && ret) {
if (VIR_ALLOC_N(*list, ret) < 0) {
- virReportOOMError();
ret = -1;
} else {
memcpy(*list, obj->nodesetval->nodeTab,