[PATCH v1 22/37] Adapt to VIR_ALLOC and virAsprintf in src/rpc/*

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 src/rpc/gendispatch.pl        |  8 ++------
 src/rpc/virnetclient.c        | 26 ++++++++------------------
 src/rpc/virnetclientprogram.c | 12 +++---------
 src/rpc/virnetclientstream.c  |  4 +---
 src/rpc/virnetmessage.c       | 24 ++++++------------------
 src/rpc/virnetserver.c        | 23 +++++++----------------
 src/rpc/virnetserverclient.c  | 19 ++++---------------
 src/rpc/virnetservermdns.c    | 20 +++++---------------
 src/rpc/virnetserverprogram.c |  8 ++------
 src/rpc/virnetserverservice.c | 12 +++---------
 src/rpc/virnetsocket.c        |  8 ++------
 src/rpc/virnetsshsession.c    | 21 +++++----------------
 src/rpc/virnettlscontext.c    | 26 +++++++++++---------------
 13 files changed, 59 insertions(+), 152 deletions(-)

diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index fdf5a79..de2d82c 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -661,10 +661,8 @@ elsif ($mode eq "server") {
                     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");
@@ -932,10 +930,8 @@ elsif ($mode eq "server") {
             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";
             }
 
diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c
index fed2c87..bc282f8 100644
--- a/src/rpc/virnetclient.c
+++ b/src/rpc/virnetclient.c
@@ -875,15 +875,14 @@ int virNetClientAddProgram(virNetClientPtr client,
     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;
 }
@@ -895,15 +894,14 @@ int virNetClientAddStream(virNetClientPtr client,
     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;
 }
@@ -981,10 +979,8 @@ virNetClientCallDispatchReply(virNetClientPtr client)
         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));
@@ -1233,10 +1229,8 @@ virNetClientIOReadMessage(virNetClientPtr client)
     /* 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;
@@ -1888,10 +1882,8 @@ virNetClientCallNew(virNetMessagePtr msg,
         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",
@@ -1964,10 +1956,8 @@ static int virNetClientSendInternal(virNetClientPtr client,
         return -1;
     }
 
-    if (!(call = virNetClientCallNew(msg, expectReply, nonBlock))) {
-        virReportOOMError();
+    if (!(call = virNetClientCallNew(msg, expectReply, nonBlock)))
         return -1;
-    }
 
     call->haveThread = true;
     ret = virNetClientIO(client, call);
diff --git a/src/rpc/virnetclientprogram.c b/src/rpc/virnetclientprogram.c
index 1016f55..1c4e4ba 100644
--- a/src/rpc/virnetclientprogram.c
+++ b/src/rpc/virnetclientprogram.c
@@ -250,10 +250,8 @@ int virNetClientProgramDispatch(virNetClientProgramPtr prog,
         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;
@@ -297,10 +295,8 @@ int virNetClientProgramCall(virNetClientProgramPtr prog,
     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++) {
@@ -358,10 +354,8 @@ int virNetClientProgramCall(virNetClientProgramPtr prog,
     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++) {
diff --git a/src/rpc/virnetclientstream.c b/src/rpc/virnetclientstream.c
index b8c457e..b785392 100644
--- a/src/rpc/virnetclientstream.c
+++ b/src/rpc/virnetclientstream.c
@@ -373,10 +373,8 @@ int virNetClientStreamRecvPacket(virNetClientStreamPtr st,
             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);
diff --git a/src/rpc/virnetmessage.c b/src/rpc/virnetmessage.c
index f27a236..0424276 100644
--- a/src/rpc/virnetmessage.c
+++ b/src/rpc/virnetmessage.c
@@ -37,10 +37,8 @@ virNetMessagePtr virNetMessageNew(bool tracked)
 {
     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);
@@ -144,10 +142,8 @@ int virNetMessageDecodeLength(virNetMessagePtr msg)
     /* 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);
@@ -223,10 +219,8 @@ int virNetMessageEncodeHeader(virNetMessagePtr msg)
     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. */
@@ -322,10 +316,8 @@ int virNetMessageDecodeNumFDs(virNetMessagePtr msg)
     }
 
     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;
 
@@ -364,10 +356,8 @@ int virNetMessageEncodePayload(virNetMessagePtr msg,
         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);
@@ -445,10 +435,8 @@ int virNetMessageEncodePayloadRaw(virNetMessagePtr msg,
 
         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);
     }
diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c
index 9f56b03..c8b0ba4 100644
--- a/src/rpc/virnetserver.c
+++ b/src/rpc/virnetserver.c
@@ -221,10 +221,8 @@ static int virNetServerDispatchNewMessage(virNetServerClientPtr client,
     if (srv->workers) {
         virNetServerJobPtr job;
 
-        if (VIR_ALLOC(job) < 0) {
-            virReportOOMError();
+        if (VIR_ALLOC(job) < 0)
             goto cleanup;
-        }
 
         job->client = client;
         job->msg = msg;
@@ -267,10 +265,8 @@ static int virNetServerAddClient(virNetServerPtr srv,
     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);
 
@@ -933,10 +929,10 @@ int virNetServerAddSignalHandler(virNetServerPtr srv,
         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;
@@ -954,8 +950,6 @@ int virNetServerAddSignalHandler(virNetServerPtr srv,
     virObjectUnlock(srv);
     return 0;
 
-no_memory:
-    virReportOOMError();
 error:
     VIR_FREE(sigdata);
     virObjectUnlock(srv);
@@ -971,7 +965,7 @@ int virNetServerAddService(virNetServerPtr srv,
     virObjectLock(srv);
 
     if (VIR_EXPAND_N(srv->services, srv->nservices, 1) < 0)
-        goto no_memory;
+        goto error;
 
     if (mdnsEntryName) {
         int port = virNetServerServiceGetPort(svc);
@@ -992,8 +986,6 @@ int virNetServerAddService(virNetServerPtr srv,
     virObjectUnlock(srv);
     return 0;
 
-no_memory:
-    virReportOOMError();
 error:
     virObjectUnlock(srv);
     return -1;
@@ -1005,15 +997,14 @@ int virNetServerAddProgram(virNetServerPtr srv,
     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;
 }
diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c
index 2fc4838..83d5cf1 100644
--- a/src/rpc/virnetserverclient.c
+++ b/src/rpc/virnetserverclient.c
@@ -241,10 +241,8 @@ int virNetServerClientAddFilter(virNetServerClientPtr client,
     virNetServerClientFilterPtr *place;
     int ret;
 
-    if (VIR_ALLOC(filter) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(filter) < 0)
         return -1;
-    }
 
     virObjectLock(client);
 
@@ -316,7 +314,6 @@ virNetServerClientCheckAccess(virNetServerClientPtr client)
      */
     confirm->bufferLength = 1;
     if (VIR_ALLOC_N(confirm->buffer, confirm->bufferLength) < 0) {
-        virReportOOMError();
         virNetMessageFree(confirm);
         return -1;
     }
@@ -378,10 +375,8 @@ virNetServerClientNewInternal(virNetSocketPtr sock,
     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,
@@ -680,15 +675,11 @@ virNetServerClientCreateIdentity(virNetServerClientPtr client)
         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
@@ -1243,7 +1234,6 @@ readmore:
                 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++;
@@ -1346,7 +1336,6 @@ virNetServerClientDispatchWrite(virNetServerClientPtr client)
                     virNetMessageClear(msg);
                     msg->bufferLength = VIR_NET_MESSAGE_LEN_MAX;
                     if (VIR_ALLOC_N(msg->buffer, msg->bufferLength) < 0) {
-                        virReportOOMError();
                         virNetMessageFree(msg);
                         return;
                     }
diff --git a/src/rpc/virnetservermdns.c b/src/rpc/virnetservermdns.c
index 4b3c19a..85ae100 100644
--- a/src/rpc/virnetservermdns.c
+++ b/src/rpc/virnetservermdns.c
@@ -273,10 +273,8 @@ static AvahiWatch *virNetServerMDNSWatchNew(const AvahiPoll *api ATTRIBUTE_UNUSE
 {
     AvahiWatch *w;
     virEventHandleType hEvents;
-    if (VIR_ALLOC(w) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(w) < 0)
         return NULL;
-    }
 
     w->fd = fd;
     w->revents = 0;
@@ -338,10 +336,8 @@ static AvahiTimeout *virNetServerMDNSTimeoutNew(const AvahiPoll *api ATTRIBUTE_U
     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",
@@ -413,10 +409,8 @@ static void virNetServerMDNSTimeoutFree(AvahiTimeout *t)
 static AvahiPoll *virNetServerMDNSCreatePoll(void)
 {
     AvahiPoll *p;
-    if (VIR_ALLOC(p) < 0) {
-        virReportOOMError();
+    if (VIR_ALLOC(p) < 0)
         return NULL;
-    }
 
     p->userdata = NULL;
 
@@ -475,10 +469,8 @@ virNetServerMDNSGroupPtr virNetServerMDNSAddGroup(virNetServerMDNS *mdns,
     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);
@@ -519,10 +511,8 @@ virNetServerMDNSEntryPtr virNetServerMDNSAddEntry(virNetServerMDNSGroupPtr 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) {
diff --git a/src/rpc/virnetserverprogram.c b/src/rpc/virnetserverprogram.c
index 09d4d21..93a3fb1 100644
--- a/src/rpc/virnetserverprogram.c
+++ b/src/rpc/virnetserverprogram.c
@@ -408,14 +408,10 @@ virNetServerProgramDispatchCall(virNetServerProgramPtr prog,
         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;
diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c
index baf0ebe..53f78ab 100644
--- a/src/rpc/virnetserverservice.c
+++ b/src/rpc/virnetserverservice.c
@@ -175,7 +175,7 @@ virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
 
     svc->nsocks = 1;
     if (VIR_ALLOC_N(svc->socks, svc->nsocks) < 0)
-        goto no_memory;
+        goto error;
 
     if (virNetSocketNewListenUNIX(path,
                                   mask,
@@ -204,8 +204,6 @@ virNetServerServicePtr virNetServerServiceNewUNIX(const char *path,
 
     return svc;
 
-no_memory:
-    virReportOOMError();
 error:
     virObjectUnref(svc);
     return NULL;
@@ -237,7 +235,7 @@ virNetServerServicePtr virNetServerServiceNewFD(int fd,
 
     svc->nsocks = 1;
     if (VIR_ALLOC_N(svc->socks, svc->nsocks) < 0)
-        goto no_memory;
+        goto error;
 
     if (virNetSocketNewListenFD(fd,
                                 &svc->socks[0]) < 0)
@@ -257,8 +255,6 @@ virNetServerServicePtr virNetServerServiceNewFD(int fd,
 
     return svc;
 
-no_memory:
-    virReportOOMError();
 error:
     virObjectUnref(svc);
     return NULL;
@@ -310,10 +306,8 @@ virNetServerServicePtr virNetServerServiceNewPostExecRestart(virJSONValuePtr obj
     }
 
     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);
diff --git a/src/rpc/virnetsocket.c b/src/rpc/virnetsocket.c
index 27709d8..45dd8b4 100644
--- a/src/rpc/virnetsocket.c
+++ b/src/rpc/virnetsocket.c
@@ -297,10 +297,8 @@ int virNetSocketNewListenTCP(const char *nodename,
 
         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;
@@ -1435,10 +1433,8 @@ static ssize_t virNetSocketReadSASL(virNetSocketPtr sock, char *buf, size_t len)
     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) {
diff --git a/src/rpc/virnetsshsession.c b/src/rpc/virnetsshsession.c
index b6aedc8..77b5c88 100644
--- a/src/rpc/virnetsshsession.c
+++ b/src/rpc/virnetsshsession.c
@@ -378,7 +378,6 @@ virNetSSHCheckHostKey(virNetSSHSessionPtr sess)
                             keyhash,
                             sess->hostname, sess->port,
                             "y", "n") < 0) {
-                virReportOOMError();
                 VIR_FREE(keyhash);
                 return -1;
             }
@@ -635,10 +634,8 @@ virNetSSHAuthenticatePrivkey(virNetSSHSessionPtr sess,
 
     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",
@@ -966,10 +963,8 @@ virNetSSHSessionAuthAddPasswordAuth(virNetSSHSessionPtr sess,
         VIR_STRDUP(pass, password) < 0)
         goto error;
 
-    if (!(auth = virNetSSHSessionAuthMethodNew(sess))) {
-        virReportOOMError();
+    if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
         goto error;
-    }
 
     auth->username = user;
     auth->password = pass;
@@ -1004,10 +999,8 @@ virNetSSHSessionAuthAddAgentAuth(virNetSSHSessionPtr sess,
     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;
@@ -1047,10 +1040,8 @@ virNetSSHSessionAuthAddPrivKeyAuth(virNetSSHSessionPtr sess,
         VIR_STRDUP(pass, password) < 0)
         goto error;
 
-    if (!(auth = virNetSSHSessionAuthMethodNew(sess))) {
-        virReportOOMError();
+    if (!(auth = virNetSSHSessionAuthMethodNew(sess)))
         goto error;
-    }
 
     auth->username = user;
     auth->password = pass;
@@ -1088,10 +1079,8 @@ virNetSSHSessionAuthAddKeyboardAuth(virNetSSHSessionPtr sess,
     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;
diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
index 9b43a80..482c860 100644
--- a/src/rpc/virnettlscontext.c
+++ b/src/rpc/virnettlscontext.c
@@ -314,10 +314,8 @@ static int virNetTLSContextCheckCertKeyPurpose(gnutls_x509_crt_t cert,
             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) {
@@ -776,17 +774,17 @@ static int virNetTLSContextLocateCredentials(const char *pkipath,
         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
@@ -794,28 +792,28 @@ static int virNetTLSContextLocateCredentials(const char *pkipath,
         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
@@ -864,8 +862,6 @@ static int virNetTLSContextLocateCredentials(const char *pkipath,
 
     return 0;
 
-out_of_memory:
-    virReportOOMError();
 error:
     VIR_FREE(*cacert);
     VIR_FREE(*cacrl);
-- 
1.8.1.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]