push(@free_list, " VIR_FREE($1);");
push(@free_list_on_error, "VIR_FREE($1_p);");
push(@prepare_ret_list,
- "if (VIR_ALLOC($1_p) < 0) {\n" .
- " virReportOOMError();\n" .
+ "if (VIR_ALLOC($1_p) < 0)\n" .
" goto cleanup;\n" .
- " }\n" .
" \n" .
" if (VIR_STRDUP(*$1_p, $1) < 0)\n".
" goto cleanup;\n");
if ($single_ret_as_list) {
print " /* Allocate return buffer. */\n";
print " if (VIR_ALLOC_N(ret->$single_ret_list_name.${single_ret_list_name}_val," .
- " args->$single_ret_list_max_var) < 0) {\n";
- print " virReportOOMError();\n";
+ " args->$single_ret_list_max_var) < 0)\n";
print " goto cleanup;\n";
- print " }\n";
print "\n";
}
virObjectLock(client);
if (VIR_EXPAND_N(client->programs, client->nprograms, 1) < 0)
- goto no_memory;
+ goto error;
client->programs[client->nprograms-1] = virObjectRef(prog);
virObjectUnlock(client);
return 0;
-no_memory:
- virReportOOMError();
+error:
virObjectUnlock(client);
return -1;
}
virObjectLock(client);
if (VIR_EXPAND_N(client->streams, client->nstreams, 1) < 0)
- goto no_memory;
+ goto error;
client->streams[client->nstreams-1] = virObjectRef(st);
virObjectUnlock(client);
return 0;
-no_memory:
- virReportOOMError();
+error:
virObjectUnlock(client);
return -1;
}
return -1;
}
- if (VIR_REALLOC_N(thecall->msg->buffer, client->msg.bufferLength) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(thecall->msg->buffer, client->msg.bufferLength) < 0)
return -1;
- }
memcpy(thecall->msg->buffer, client->msg.buffer, client->msg.bufferLength);
memcpy(&thecall->msg->header, &client->msg.header, sizeof(client->msg.header));
/* Start by reading length word */
if (client->msg.bufferLength == 0) {
client->msg.bufferLength = 4;
- if (VIR_ALLOC_N(client->msg.buffer, client->msg.bufferLength) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(client->msg.buffer, client->msg.bufferLength) < 0)
return -ENOMEM;
- }
}
wantData = client->msg.bufferLength - client->msg.bufferOffset;
goto error;
}
- if (VIR_ALLOC(call) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(call) < 0)
goto error;
- }
if (virCondInit(&call->cond) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
return -1;
}
- if (!(call = virNetClientCallNew(msg, expectReply, nonBlock))) {
- virReportOOMError();
+ if (!(call = virNetClientCallNew(msg, expectReply, nonBlock)))
return -1;
- }
call->haveThread = true;
ret = virNetClientIO(client, call);
return -1;
}
- if (VIR_ALLOC_N(evdata, event->msg_len) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(evdata, event->msg_len) < 0)
return -1;
- }
if (virNetMessageDecodePayload(msg, event->msg_filter, evdata) < 0)
goto cleanup;
msg->header.serial = serial;
msg->header.proc = proc;
msg->nfds = noutfds;
- if (VIR_ALLOC_N(msg->fds, msg->nfds) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(msg->fds, msg->nfds) < 0)
goto error;
- }
for (i = 0; i < msg->nfds; i++)
msg->fds[i] = -1;
for (i = 0; i < msg->nfds; i++) {
case VIR_NET_OK:
if (infds && ninfds) {
*ninfds = msg->nfds;
- if (VIR_ALLOC_N(*infds, *ninfds) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(*infds, *ninfds) < 0)
goto error;
- }
for (i = 0; i < *ninfds; i++)
(*infds)[i] = -1;
for (i = 0; i < *ninfds; i++) {
goto cleanup;
}
- if (!(msg = virNetMessageNew(false))) {
- virReportOOMError();
+ if (!(msg = virNetMessageNew(false)))
goto cleanup;
- }
msg->header.prog = virNetClientProgramGetProgram(st->prog);
msg->header.vers = virNetClientProgramGetVersion(st->prog);
{
virNetMessagePtr msg;
- if (VIR_ALLOC(msg) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(msg) < 0)
return NULL;
- }
msg->tracked = tracked;
VIR_DEBUG("msg=%p tracked=%d", msg, tracked);
/* Extend our declared buffer length and carry
on reading the header + payload */
msg->bufferLength += len;
- if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0)
goto cleanup;
- }
VIR_DEBUG("Got length, now need %zu total (%u more)",
msg->bufferLength, len);
unsigned int len = 0;
msg->bufferLength = VIR_NET_MESSAGE_INITIAL + VIR_NET_MESSAGE_LEN_MAX;
- if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0)
return ret;
- }
msg->bufferOffset = 0;
/* Format the header. */
}
msg->nfds = numFDs;
- if (VIR_ALLOC_N(msg->fds, msg->nfds) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(msg->fds, msg->nfds) < 0)
goto cleanup;
- }
for (i = 0; i < msg->nfds; i++)
msg->fds[i] = -1;
msg->bufferLength = (msg->bufferLength - VIR_NET_MESSAGE_LEN_MAX) * 4 +
VIR_NET_MESSAGE_LEN_MAX;
- if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0)
goto error;
- }
xdrmem_create(&xdr, msg->buffer + msg->bufferOffset,
msg->bufferLength - msg->bufferOffset, XDR_ENCODE);
msg->bufferLength = msg->bufferOffset + len;
- if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0) {
- virReportOOMError();
+ if (VIR_REALLOC_N(msg->buffer, msg->bufferLength) < 0)
return -1;
- }
VIR_DEBUG("Increased message buffer length = %zu", msg->bufferLength);
}
} else {
rerr->code = VIR_ERR_INTERNAL_ERROR;
rerr->domain = VIR_FROM_RPC;
- if (VIR_ALLOC(rerr->message) == 0 &&
+ if (VIR_ALLOC_QUIET(rerr->message) == 0 &&
VIR_STRDUP_QUIET(*rerr->message,
_("Library function returned error but did not set virError")) < 0)
VIR_FREE(rerr->message);
if (srv->workers) {
virNetServerJobPtr job;
- if (VIR_ALLOC(job) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(job) < 0)
goto cleanup;
- }
job->client = client;
job->msg = msg;
if (virNetServerClientInit(client) < 0)
goto error;
- if (VIR_EXPAND_N(srv->clients, srv->nclients, 1) < 0) {
- virReportOOMError();
+ if (VIR_EXPAND_N(srv->clients, srv->nclients, 1) < 0)
goto error;
- }
srv->clients[srv->nclients-1] = client;
virObjectRef(client);
goto error;
if (VIR_EXPAND_N(srv->signals, srv->nsignals, 1) < 0)
- goto no_memory;
+ goto error;
if (VIR_ALLOC(sigdata) < 0)
- goto no_memory;
+ goto error;
sigdata->signum = signum;
sigdata->func = func;
virObjectUnlock(srv);
return 0;
-no_memory:
- virReportOOMError();
error:
VIR_FREE(sigdata);
virObjectUnlock(srv);
virObjectLock(srv);
if (VIR_EXPAND_N(srv->services, srv->nservices, 1) < 0)
- goto no_memory;
+ goto error;
if (mdnsEntryName) {
int port = virNetServerServiceGetPort(svc);
virObjectUnlock(srv);
return 0;
-no_memory:
- virReportOOMError();
error:
virObjectUnlock(srv);
return -1;
virObjectLock(srv);
if (VIR_EXPAND_N(srv->programs, srv->nprograms, 1) < 0)
- goto no_memory;
+ goto error;
srv->programs[srv->nprograms-1] = virObjectRef(prog);
virObjectUnlock(srv);
return 0;
-no_memory:
- virReportOOMError();
+error:
virObjectUnlock(srv);
return -1;
}
virNetServerClientFilterPtr *place;
int ret;
- if (VIR_ALLOC(filter) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(filter) < 0)
return -1;
- }
virObjectLock(client);
*/
confirm->bufferLength = 1;
if (VIR_ALLOC_N(confirm->buffer, confirm->bufferLength) < 0) {
- virReportOOMError();
virNetMessageFree(confirm);
return -1;
}
if (!(client->rx = virNetMessageNew(true)))
goto error;
client->rx->bufferLength = VIR_NET_MESSAGE_LEN_MAX;
- if (VIR_ALLOC_N(client->rx->buffer, client->rx->bufferLength) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(client->rx->buffer, client->rx->bufferLength) < 0)
goto error;
- }
client->nrequests = 1;
PROBE(RPC_SERVER_CLIENT_NEW,
if (!(groupname = virGetGroupName(gid)))
goto cleanup;
if (virAsprintf(&processid, "%llu",
- (unsigned long long)pid) < 0) {
- virReportOOMError();
+ (unsigned long long)pid) < 0)
goto cleanup;
- }
if (virAsprintf(&processtime, "%llu",
- timestamp) < 0) {
- virReportOOMError();
+ timestamp) < 0)
goto cleanup;
- }
}
#if WITH_SASL
client->rx->bufferLength = VIR_NET_MESSAGE_LEN_MAX;
if (VIR_ALLOC_N(client->rx->buffer,
client->rx->bufferLength) < 0) {
- virReportOOMError();
client->wantClose = true;
} else {
client->nrequests++;
virNetMessageClear(msg);
msg->bufferLength = VIR_NET_MESSAGE_LEN_MAX;
if (VIR_ALLOC_N(msg->buffer, msg->bufferLength) < 0) {
- virReportOOMError();
virNetMessageFree(msg);
return;
}
{
AvahiWatch *w;
virEventHandleType hEvents;
- if (VIR_ALLOC(w) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(w) < 0)
return NULL;
- }
w->fd = fd;
w->revents = 0;
struct timeval now;
long long nowms, thenms, timeout;
VIR_DEBUG("Add timeout TV %p", tv);
- if (VIR_ALLOC(t) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(t) < 0)
return NULL;
- }
if (gettimeofday(&now, NULL) < 0) {
virReportSystemError(errno, "%s",
static AvahiPoll *virNetServerMDNSCreatePoll(void)
{
AvahiPoll *p;
- if (VIR_ALLOC(p) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(p) < 0)
return NULL;
- }
p->userdata = NULL;
virNetServerMDNSGroupPtr group;
VIR_DEBUG("Adding group '%s'", name);
- if (VIR_ALLOC(group) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(group) < 0)
return NULL;
- }
if (VIR_STRDUP(group->name, name) < 0) {
VIR_FREE(group);
virNetServerMDNSEntryPtr entry;
VIR_DEBUG("Adding entry %s %d to group %s", type, port, group->name);
- if (VIR_ALLOC(entry) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC(entry) < 0)
return NULL;
- }
entry->port = port;
if (VIR_STRDUP(entry->type, type) < 0) {
goto error;
}
- if (VIR_ALLOC_N(arg, dispatcher->arg_len) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(arg, dispatcher->arg_len) < 0)
goto error;
- }
- if (VIR_ALLOC_N(ret, dispatcher->ret_len) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(ret, dispatcher->ret_len) < 0)
goto error;
- }
if (virNetMessageDecodePayload(msg, dispatcher->arg_filter, arg) < 0)
goto error;
svc->nsocks = 1;
if (VIR_ALLOC_N(svc->socks, svc->nsocks) < 0)
- goto no_memory;
+ goto error;
if (virNetSocketNewListenUNIX(path,
mask,
return svc;
-no_memory:
- virReportOOMError();
error:
virObjectUnref(svc);
return NULL;
svc->nsocks = 1;
if (VIR_ALLOC_N(svc->socks, svc->nsocks) < 0)
- goto no_memory;
+ goto error;
if (virNetSocketNewListenFD(fd,
&svc->socks[0]) < 0)
return svc;
-no_memory:
- virReportOOMError();
error:
virObjectUnref(svc);
return NULL;
}
svc->nsocks = n;
- if (VIR_ALLOC_N(svc->socks, svc->nsocks) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(svc->socks, svc->nsocks) < 0)
goto error;
- }
for (i = 0; i < svc->nsocks; i++) {
virJSONValuePtr child = virJSONValueArrayGet(socks, i);
VIR_DEBUG("%p f=%d f=%d", &addr, runp->ai_family, addr.data.sa.sa_family);
- if (VIR_EXPAND_N(socks, nsocks, 1) < 0) {
- virReportOOMError();
+ if (VIR_EXPAND_N(socks, nsocks, 1) < 0)
goto error;
- }
if (!(socks[nsocks-1] = virNetSocketNew(&addr, NULL, false, fd, -1, 0)))
goto error;
if (sock->saslDecoded == NULL) {
ssize_t encodedLen = virNetSASLSessionGetMaxBufSize(sock->saslSession);
char *encoded;
- if (VIR_ALLOC_N(encoded, encodedLen) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(encoded, encodedLen) < 0)
return -1;
- }
encodedLen = virNetSocketReadWire(sock, encoded, encodedLen);
if (encodedLen <= 0) {
keyhash,
sess->hostname, sess->port,
"y", "n") < 0) {
- virReportOOMError();
VIR_FREE(keyhash);
return -1;
}
if (virAsprintf((char **)&retr_passphrase.prompt,
_("Passphrase for key '%s'"),
- priv->filename) < 0) {
- virReportOOMError();
+ priv->filename) < 0)
return -1;
- }
if (sess->cred->cb(&retr_passphrase, 1, sess->cred->cbdata)) {
virReportError(VIR_ERR_SSH, "%s",
VIR_STRDUP(pass, password) < 0)
goto error;
- if (!(auth = virNetSSHSessionAuthMethodNew(sess))) {
- virReportOOMError();
+ if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
goto error;
- }
auth->username = user;
auth->password = pass;
if (VIR_STRDUP(user, username) < 0)
goto error;
- if (!(auth = virNetSSHSessionAuthMethodNew(sess))) {
- virReportOOMError();
+ if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
goto error;
- }
auth->username = user;
auth->method = VIR_NET_SSH_AUTH_AGENT;
VIR_STRDUP(pass, password) < 0)
goto error;
- if (!(auth = virNetSSHSessionAuthMethodNew(sess))) {
- virReportOOMError();
+ if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
goto error;
- }
auth->username = user;
auth->password = pass;
if (VIR_STRDUP(user, username) < 0)
goto error;
- if (!(auth = virNetSSHSessionAuthMethodNew(sess))) {
- virReportOOMError();
+ if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
goto error;
- }
auth->username = user;
auth->tries = tries;
return -1;
}
- if (VIR_ALLOC_N(buffer, size) < 0) {
- virReportOOMError();
+ if (VIR_ALLOC_N(buffer, size) < 0)
return -1;
- }
status = gnutls_x509_crt_get_key_purpose_oid(cert, i, buffer, &size, &purposeCritical);
if (status < 0) {
VIR_DEBUG("Told to use TLS credentials in %s", pkipath);
if ((virAsprintf(cacert, "%s/%s", pkipath,
"cacert.pem")) < 0)
- goto out_of_memory;
+ goto error;
if ((virAsprintf(cacrl, "%s/%s", pkipath,
"cacrl.pem")) < 0)
- goto out_of_memory;
+ goto error;
if ((virAsprintf(key, "%s/%s", pkipath,
isServer ? "serverkey.pem" : "clientkey.pem")) < 0)
- goto out_of_memory;
+ goto error;
if ((virAsprintf(cert, "%s/%s", pkipath,
isServer ? "servercert.pem" : "clientcert.pem")) < 0)
- goto out_of_memory;
+ goto error;
} else if (tryUserPkiPath) {
/* Check to see if $HOME/.pki contains at least one of the
* files and if so, use that
userdir = virGetUserDirectory();
if (!userdir)
- goto out_of_memory;
+ goto error;
if (virAsprintf(&user_pki_path, "%s/.pki/libvirt", userdir) < 0)
- goto out_of_memory;
+ goto error;
VIR_DEBUG("Trying to find TLS user credentials in %s", user_pki_path);
if ((virAsprintf(cacert, "%s/%s", user_pki_path,
"cacert.pem")) < 0)
- goto out_of_memory;
+ goto error;
if ((virAsprintf(cacrl, "%s/%s", user_pki_path,
"cacrl.pem")) < 0)
- goto out_of_memory;
+ goto error;
if ((virAsprintf(key, "%s/%s", user_pki_path,
isServer ? "serverkey.pem" : "clientkey.pem")) < 0)
- goto out_of_memory;
+ goto error;
if ((virAsprintf(cert, "%s/%s", user_pki_path,
isServer ? "servercert.pem" : "clientcert.pem")) < 0)
- goto out_of_memory;
+ goto error;
/*
* If some of the files can't be found, fallback
return 0;
-out_of_memory:
- virReportOOMError();
error:
VIR_FREE(*cacert);
VIR_FREE(*cacrl);