From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51005) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIlaS-0006C7-9v for qemu-devel@nongnu.org; Tue, 03 Feb 2015 17:04:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YIlaO-0000Pf-J4 for qemu-devel@nongnu.org; Tue, 03 Feb 2015 17:04:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:52718) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YIlaO-0000PL-Bc for qemu-devel@nongnu.org; Tue, 03 Feb 2015 17:04:44 -0500 Message-ID: <54D145F7.6090500@redhat.com> Date: Tue, 03 Feb 2015 15:04:39 -0700 From: Eric Blake MIME-Version: 1.0 References: <1420031214-6053-1-git-send-email-den@openvz.org> <1420031214-6053-4-git-send-email-den@openvz.org> In-Reply-To: <1420031214-6053-4-git-send-email-den@openvz.org> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WmGHvnwaCTSMBCGOPJHwdTrPvGDXsLUbO" Subject: Re: [Qemu-devel] [PATCH 3/8] guest agent: guest-file-open: refactoring List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Denis V. Lunev" Cc: qemu-devel@nongnu.org, Simon Zolin , Michael Roth This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --WmGHvnwaCTSMBCGOPJHwdTrPvGDXsLUbO Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 12/31/2014 06:06 AM, Denis V. Lunev wrote: > From: Simon Zolin >=20 > Moved the code that sets non-blocking flag on fd into a separate functi= on. >=20 > Signed-off-by: Simon Zolin > Acked-by: Roman Kagan > Signed-off-by: Denis V. Lunev > CC: Michael Roth > --- > qga/commands-posix.c | 31 +++++++++++++++++++++++-------- > 1 file changed, 23 insertions(+), 8 deletions(-) >=20 > diff --git a/qga/commands-posix.c b/qga/commands-posix.c > index f6f3e3c..fd746db 100644 > --- a/qga/commands-posix.c > +++ b/qga/commands-posix.c > @@ -376,13 +376,33 @@ safe_open_or_create(const char *path, const char = *mode, Error **errp) > return NULL; > } > =20 > +static int guest_file_toggle_flags(int fd, long flags, bool set, Error= **err) > +{ Why is 'flags' a long? > + int ret, old_flags; > + > + old_flags =3D fcntl(fd, F_GETFL); > + if (old_flags =3D=3D -1) { > + error_set_errno(err, errno, QERR_QGA_COMMAND_FAILED, > + "failed to fetch filehandle flags"); > + return -1; > + } > + > + ret =3D fcntl(fd, F_SETFL, set ? (old_flags | flags) : (old_flags = & ~flags)); Bug. 'int | long' is a long, but on 64-bit platforms, passing a 'long' as the var-arg third argument of fcntl where the interface expects 'int' is liable to corrupt things depending on endianness. You MUST pass an 'int' for F_SETFL. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --WmGHvnwaCTSMBCGOPJHwdTrPvGDXsLUbO Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJU0UX3AAoJEKeha0olJ0NqirgH/RpZeUawmsg8ql/buYJh2DuY x1/+5ewlYGeQYEtkVz+IybT96aqd1c8dSNHFuEkeYCwMC5KINeTtKyxQpetgxl3M AWRJCk0D6wqfkwGNW91GdbFAR3zcnkSBYzrI+pZXw/oabaYcAfctl3wmfop97R5g KCO84hwKjA1gSiUBpRhU0rL4xGfhS7hOvoZZmZd+UWk0+S+fuxZoP38Aaf0Vtj/E rWWIZ2rBoeDk00QRlZw15nKCH9aPpekRM9nMFtfpMH9qCn6LACjQDCo6bI2ku/MV xuqygIJzYgStXYMRDHVnVOBZ0boRcqQycVXY2P7mItD3D6+/guiI7JVjU9kQsJY= =qs6W -----END PGP SIGNATURE----- --WmGHvnwaCTSMBCGOPJHwdTrPvGDXsLUbO--