Message ID | 1444406198-6521-5-git-send-email-thuth@redhat.com |
---|---|
State | New |
Headers | show |
On perjantaina 9. lokakuuta 2015 18.56.38 EEST, Thomas Huth wrote: > 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. Applied to linux-user, thanks > Signed-off-by: Thomas Huth <thuth@redhat.com> > Reviewed-by: Eric Blake <eblake@redhat.com> > --- > 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); >
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);