]> git.proxmox.com Git - mirror_qemu.git/commitdiff
linux-user/syscall: Replace g_malloc0 + memcpy with g_memdup
authorThomas Huth <thuth@redhat.com>
Fri, 9 Oct 2015 15:56:38 +0000 (17:56 +0200)
committerMichael Tokarev <mjt@tls.msk.ru>
Fri, 6 Nov 2015 12:42:38 +0000 (15:42 +0300)
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.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
linux-user/syscall.c

index 8bfb24f05bc1fbad6951fecc70ef51ae5e4bc1a1..6c64ba63db6437937a40ea154a5ad9afc2ae4f1b 100644 (file)
@@ -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);