From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38830) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8ZjG-0004fI-6h for qemu-devel@nongnu.org; Thu, 02 Jun 2016 17:00:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b8ZjA-0008O1-DN for qemu-devel@nongnu.org; Thu, 02 Jun 2016 17:00:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54379) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b8ZjA-0008Nu-4w for qemu-devel@nongnu.org; Thu, 02 Jun 2016 17:00:28 -0400 References: <146485751812.31047.11608773464731615044.stgit@bahia.huguette.org> <146485754874.31047.6226537020118792004.stgit@bahia.huguette.org> From: Eric Blake Message-ID: <57509E6A.3090604@redhat.com> Date: Thu, 2 Jun 2016 15:00:26 -0600 MIME-Version: 1.0 In-Reply-To: <146485754874.31047.6226537020118792004.stgit@bahia.huguette.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="pjeb59WWRKlHkJtHwQ6lM4aEmcNAcfTCB" Subject: Re: [Qemu-devel] [PATCH 4/4] 9p: switch back to readdir() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: "Aneesh Kumar K.V" , qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --pjeb59WWRKlHkJtHwQ6lM4aEmcNAcfTCB Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/02/2016 02:52 AM, Greg Kurz wrote: > This patch changes the 9p code to use readdir() again instead of > readdir_r(), which is deprecated in glibc 2.24. >=20 > All the locking was put in place by a previous patch. >=20 > Signed-off-by: Greg Kurz > --- > +++ b/hw/9pfs/codir.c > @@ -17,8 +17,7 @@ > #include "qemu/coroutine.h" > #include "coth.h" > =20 > -int v9fs_co_readdir_r(V9fsPDU *pdu, V9fsFidState *fidp, struct dirent = *dent, > - struct dirent **result) > +int v9fs_co_readdir(V9fsPDU *pdu, V9fsFidState *fidp, struct dirent **= dent) > { > int err; > V9fsState *s =3D pdu->s; > @@ -28,11 +27,14 @@ int v9fs_co_readdir_r(V9fsPDU *pdu, V9fsFidState *f= idp, struct dirent *dent, > } > v9fs_co_run_in_worker( > { > - errno =3D 0; > - err =3D s->ops->readdir_r(&s->ctx, &fidp->fs, dent, result= ); > - if (!*result && errno) { > + struct dirent *entry; > + int old_errno =3D errno; > + > + entry =3D s->ops->readdir(&s->ctx, &fidp->fs); > + if (!entry && errno !=3D old_errno) { > err =3D -errno; Not safe. The only safe way to check errno after readdir() is to assign it to 0 before readdir(). > } else { > + *dent =3D entry; > err =3D 0; > } > }); --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --pjeb59WWRKlHkJtHwQ6lM4aEmcNAcfTCB 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/ iQEcBAEBCAAGBQJXUJ5qAAoJEKeha0olJ0Nqzt0H/0TYrj3yHTDrRq5hERvy+l5y WXD3gmCmt2QbT60kvQPj2Kf3TkYB2SGc4IO45DxVRCgljMhCy9peyh6l71kGL818 uAS3iMKFINUke3k1T+U9+Lbi5ZPfQBXGad6wklgLCQOdF902LFnW8S2YqwljzfB0 /t1ZIy8nspsVFmpy0WKFwO0uERx3cCJjaoCFrhYS9HwNzY7u9uuLZyB8RGk7le92 HvtoWIi0pqvoTKDvlue9Npms3C98xFAoIPUl3ealuNegqrdfFdfXiBLnkQBAOvMT HO9DrB5QuZiixSQwMVdDEXw/HZtQ69JOgNNueeMqPkkx5K4rjHzFvldgmOKG54U= =6MNV -----END PGP SIGNATURE----- --pjeb59WWRKlHkJtHwQ6lM4aEmcNAcfTCB--