Received: from eggs.gnu.org ([2001:4830:134:3::10]:33151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZkKgm-0006tn-Mu for qemu-devel@nongnu.org; Thu, 08 Oct 2015 19:34:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZkKgI-00081b-Tg for qemu-devel@nongnu.org; Thu, 08 Oct 2015 19:33:32 -0400 References: <1444332916-16476-1-git-send-email-thuth@redhat.com> <1444332916-16476-6-git-send-email-thuth@redhat.com> From: Eric Blake Message-ID: <5616FD27.9050207@redhat.com> Date: Thu, 8 Oct 2015 17:32:55 -0600 MIME-Version: 1.0 In-Reply-To: <1444332916-16476-6-git-send-email-thuth@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="BxrTmWkojvJqaR4kgkV5WKPGv3lThjxj8" Subject: Re: [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: Thomas Huth , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Riku Voipio This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --BxrTmWkojvJqaR4kgkV5WKPGv3lThjxj8 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/08/2015 01:35 PM, 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. >=20 > Cc: Riku Voipio > Signed-off-by: Thomas Huth > --- > linux-user/syscall.c | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) Reviewed-by: Eric Blake >=20 > 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 mou= nt_fd, abi_long handle, > return -TARGET_EFAULT; > } > =20 > - fh =3D g_malloc0(total_size); > - memcpy(fh, target_fh, total_size); > + fh =3D g_memdup(target_fh, total_size); > fh->handle_bytes =3D size; > fh->handle_type =3D tswap32(target_fh->handle_type); > =20 >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --BxrTmWkojvJqaR4kgkV5WKPGv3lThjxj8 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJWFv0oAAoJEKeha0olJ0NqA+kH/RY9mDmFqGMRjz3HgZiiHjn6 CVBskB1spdmSCQr6GgdwzvsgXr5/JG9+KWkH9OOxruLF0e3FXixFp2Fu9Gg9J3M1 mWuDFuHiQ522wqmoWE8r2I82dcuwjKzeNWn9z6TD8GoRN+mYeE707c9GYaGTEkpJ r/LIp0ge7PUxip3/BsXbDupt3emof2ZiI5zEk3uh4flJG5qywAFGU0nzzCh7ykIf sY8e+44SN7tvc3d6/GTuXpEgLfGUjLQDkqJHqatpJjEovKT9Z4zYvkALPyzBtQIW XlCTk+QtViJjc3n7F3+wmFQBVpgF/R56Ri6UK20rNiP+Wthv32LnsojXB2z/Idk= =kQwo -----END PGP SIGNATURE----- --BxrTmWkojvJqaR4kgkV5WKPGv3lThjxj8--