From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45163) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkGyW-0004dH-RR for qemu-devel@nongnu.org; Thu, 08 Oct 2015 15:35:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkGyV-0006LL-Eb for qemu-devel@nongnu.org; Thu, 08 Oct 2015 15:35:36 -0400 From: Thomas Huth Date: Thu, 8 Oct 2015 21:35:16 +0200 Message-Id: <1444332916-16476-6-git-send-email-thuth@redhat.com> In-Reply-To: <1444332916-16476-1-git-send-email-thuth@redhat.com> References: <1444332916-16476-1-git-send-email-thuth@redhat.com> Subject: [Qemu-devel] [PATCH 5/5] linux-user/syscall: Replace g_malloc0 + memcpy with g_memdup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Riku Voipio No need to use g_malloc0 to zero the memory if we memcpy to the whole buffer afterwards anyway. Actually, there is even a function which combines both steps, g_memdup, so let's use this function here instead. Cc: Riku Voipio Signed-off-by: Thomas Huth --- linux-user/syscall.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 98b5766..f2ada0a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5325,8 +5325,7 @@ static abi_long do_open_by_handle_at(abi_long mount_fd, abi_long handle, return -TARGET_EFAULT; } - fh = g_malloc0(total_size); - memcpy(fh, target_fh, total_size); + fh = g_memdup(target_fh, total_size); fh->handle_bytes = size; fh->handle_type = tswap32(target_fh->handle_type); -- 1.8.3.1