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(a)redhat.com>
---
src/qemu/qemu_backup.c | 2 +-
src/util/virutil.c | 2 +-
tests/qemuhotplugmock.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/qemu/qemu_backup.c b/src/qemu/qemu_backup.c
index 8dc9d2504d..dae9300567 100644
--- a/src/qemu/qemu_backup.c
+++ b/src/qemu/qemu_backup.c
@@ -64,7 +64,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");
diff --git a/src/util/virutil.c b/src/util/virutil.c
index 04f882fda7..ff664ea778 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -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;
diff --git a/tests/qemuhotplugmock.c b/tests/qemuhotplugmock.c
index d2324913cf..29fac8a598 100644
--- a/tests/qemuhotplugmock.c
+++ b/tests/qemuhotplugmock.c
@@ -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 */
--
2.25.4