From 97f3ad35517e0d02c0149637d1bb10713c52b057 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Mon, 14 Sep 2015 13:51:31 +0200 Subject: migration: Use g_new() & friends where that makes obvious sense g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer, for two reasons. One, it catches multiplication overflowing size_t. Two, it returns T * rather than void *, which lets the compiler catch more type errors. This commit only touches allocations with size arguments of the form sizeof(T). Same Coccinelle semantic patch as in commit b45c03f. Signed-off-by: Markus Armbruster Message-Id: <1442231491-23352-1-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake Reviewed-by: zhanghailiang Reviewed-by: Amit Shah Signed-off-by: Amit Shah --- migration/qemu-file-unix.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'migration/qemu-file-unix.c') diff --git a/migration/qemu-file-unix.c b/migration/qemu-file-unix.c index adfe91add1..bf7a0e4a2b 100644 --- a/migration/qemu-file-unix.c +++ b/migration/qemu-file-unix.c @@ -194,7 +194,7 @@ QEMUFile *qemu_fdopen(int fd, const char *mode) return NULL; } - s = g_malloc0(sizeof(QEMUFileSocket)); + s = g_new0(QEMUFileSocket, 1); s->fd = fd; if (mode[0] == 'r') { @@ -228,7 +228,7 @@ QEMUFile *qemu_fopen_socket(int fd, const char *mode) return NULL; } - s = g_malloc0(sizeof(QEMUFileSocket)); + s = g_new0(QEMUFileSocket, 1); s->fd = fd; if (mode[0] == 'w') { qemu_set_block(s->fd); -- cgit 1.4.1