]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
replace g_new() with g_new0() for consistency
authorLaine Stump <laine@redhat.com>
Thu, 25 Jun 2020 02:37:33 +0000 (22:37 -0400)
committerLaine Stump <laine@redhat.com>
Mon, 20 Jul 2020 23:08:07 +0000 (19:08 -0400)
g_new() is used in only 3 places. Switching them to g_new0() will do
no harm, reduces confusion, and helps me sleep better at night knowing
that all allocated memory is initialized to 0 :-) (Yes, I *know* that
in all three cases the associated memory is immediately assigned some
other value. Today.)

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/qemu/qemu_backup.c
src/util/virutil.c
tests/qemuhotplugmock.c

index b711f8f623d890b12a611708db44b29a3f41876c..a402730d38e25b6c3701acfe3d68116f508259f4 100644 (file)
@@ -65,7 +65,7 @@ qemuBackupPrepare(virDomainBackupDefPtr def)
 
     if (def->type == VIR_DOMAIN_BACKUP_TYPE_PULL) {
         if (!def->server) {
-            def->server = g_new(virStorageNetHostDef, 1);
+            def->server = g_new0(virStorageNetHostDef, 1);
 
             def->server->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
             def->server->name = g_strdup("localhost");
index 04f882fda75389ca07fcbfa2318580c8706fca64..ff664ea778e5901ef29b0d7ff33419b0fd22c080 100644 (file)
@@ -962,7 +962,7 @@ virGetGroupList(uid_t uid, gid_t gid, gid_t **list)
     if (uid != (uid_t)-1 &&
         virGetUserEnt(uid, &user, &primary, NULL, NULL, true) >= 0) {
         int nallocgrps = 10;
-        gid_t *grps = g_new(gid_t, nallocgrps);
+        gid_t *grps = g_new0(gid_t, nallocgrps);
 
         while (1) {
             int nprevallocgrps = nallocgrps;
index d2324913cf9cb26924d610faa64843b9c28bf854..29fac8a598d13e88ae0a93a40540af191cdde891 100644 (file)
@@ -57,7 +57,7 @@ virDevMapperGetTargets(const char *path,
     *devPaths = NULL;
 
     if (STREQ(path, "/dev/mapper/virt")) {
-        *devPaths = g_new(char *, 4);
+        *devPaths = g_new0(char *, 4);
         (*devPaths)[0] = g_strdup("/dev/block/8:0");  /* /dev/sda */
         (*devPaths)[1] = g_strdup("/dev/block/8:16"); /* /dev/sdb */
         (*devPaths)[2] = g_strdup("/dev/block/8:32"); /* /dev/sdc */