]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: systemd: use g_new0
authorJán Tomko <jtomko@redhat.com>
Mon, 5 Oct 2020 17:09:00 +0000 (19:09 +0200)
committerJán Tomko <jtomko@redhat.com>
Tue, 6 Oct 2020 10:31:34 +0000 (12:31 +0200)
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
src/util/virsystemd.c

index 8456085476e79c7b3827c1639d6b603c35df9ffa..8373ee6509b5a9f864c701da629bfcdbc163ce66 100644 (file)
@@ -364,8 +364,7 @@ int virSystemdCreateMachine(const char *name,
     if (g_atomic_int_get(&hasCreateWithNetwork)) {
         g_autoptr(virError) error = NULL;
 
-        if (VIR_ALLOC(error) < 0)
-            return -1;
+        error = g_new0(virError, 1);
 
         guuid = g_variant_new_fixed_array(G_VARIANT_TYPE("y"),
                                           uuid, 16, sizeof(unsigned char));
@@ -495,8 +494,7 @@ int virSystemdTerminateMachine(const char *name)
     if (!(conn = virGDBusGetSystemBus()))
         return -1;
 
-    if (VIR_ALLOC(error) < 0)
-        return -1;
+    error = g_new0(virError, 1);
 
     /*
      * The systemd DBus API we're invoking has the
@@ -655,14 +653,8 @@ virSystemdActivationAddFD(virSystemdActivationPtr act,
     virSystemdActivationEntryPtr ent = virHashLookup(act->fds, name);
 
     if (!ent) {
-        if (VIR_ALLOC(ent) < 0)
-            return -1;
-
-        if (VIR_ALLOC_N(ent->fds, 1) < 0) {
-            virSystemdActivationEntryFree(ent);
-            return -1;
-        }
-
+        ent = g_new0(virSystemdActivationEntry, 1);
+        ent->fds = g_new0(int, 1);
         ent->fds[ent->nfds++] = fd;
 
         VIR_DEBUG("Record first FD %d with name %s", fd, name);
@@ -902,8 +894,7 @@ virSystemdActivationNew(virSystemdActivationMap *map,
     const char *fdnames;
 
     VIR_DEBUG("Activated with %d FDs", nfds);
-    if (VIR_ALLOC(act) < 0)
-        return NULL;
+    act = g_new0(virSystemdActivation, 1);
 
     if (!(act->fds = virHashCreate(10, virSystemdActivationEntryFree)))
         goto error;