From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23141 invoked by alias); 28 Feb 2020 19:23:37 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 23134 invoked by uid 89); 28 Feb 2020 19:23:37 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-106.4 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=HX-Languages-Length:1656 X-HELO: mout.kundenserver.de Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (212.227.17.24) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 28 Feb 2020 19:23:35 +0000 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MpUpW-1jkNEF1AVQ-00puPG; Fri, 28 Feb 2020 20:23:31 +0100 Received: by calimero.vinschen.de (Postfix, from userid 500) id 94271A819D3; Fri, 28 Feb 2020 20:23:30 +0100 (CET) Date: Fri, 28 Feb 2020 19:23:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Cc: =?utf-8?Q?=C3=85ke?= Rehnman Subject: Re: Incorrect behavior in TIOCINQ ioctl Message-ID: <20200228192330.GN4045@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com, =?utf-8?Q?=C3=85ke?= Rehnman References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="yhqQ34TVR4fE8mPU" Content-Disposition: inline In-Reply-To: X-SW-Source: 2020-02/txt/msg00270.txt.bz2 --yhqQ34TVR4fE8mPU Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1958 On Feb 27 22:38, =C3=85ke Rehnman wrote: > Hi, >=20 > I recently ran in to some troubles with the TIOCINQ ioctl. I am wondering= if > the cygwin implementation is correct... It seems if there were any existi= ng > framing overrun errors etc etc=C2=A0 before calling the TIOCINQ ioctl it = is > returning an error (EINVAL). Reading through linux implmentation of TIOCI= NQ > does simply return number of pending chars without any clearing or checki= ng > for errors. >=20 > I suggest the whole if (ev & CE_FRAME=C2=A0 ...... ) is removed. >=20 > Excerpt from fhandler_serial.cc: >=20 > /* ioctl: */ > int > fhandler_serial::ioctl (unsigned int cmd, void *buf) > { > . > . > =C2=A0 if (!ClearCommError (get_handle (), &ev, &st)) > =C2=A0=C2=A0=C2=A0 { > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 __seterrno (); > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 res =3D -1; > =C2=A0=C2=A0=C2=A0 } > . > . > . > =C2=A0=C2=A0=C2=A0=C2=A0 case TIOCINQ: > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ev & CE_FRAME || ev & CE_IOE || = ev & CE_OVERRUN || ev & CE_RXOVER > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 || ev & CE_RXPARITY) > =C2=A0=C2=A0=C2=A0 =C2=A0{ > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 set_errno (EINVAL);=C2=A0=C2=A0=C2=A0 /* = FIXME: Use correct errno */ > =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0 res =3D -1; > =C2=A0=C2=A0=C2=A0 =C2=A0} > =C2=A0=C2=A0=C2=A0=C2=A0 else > =C2=A0 =C2=A0 =C2=A0 =C2=A0 ipbuf =3D st.cbInQue; > =C2=A0=C2=A0=C2=A0=C2=A0 break; I'm not familiar with serial I/O and the code is pretty stable(*). - Is it a safe bet that ClearCommError returns valid values in st.cbInQue even if one of the error conditions occur? Maybe the right thing to do is to return 0 in certain error cases...? - Did you actually try if this fixes your problem? It's pretty simple to build the Cygwin DLL https://cygwin.com/faq.html#faq.programming.building-cygwin Corinna (*) euphemistically for "nobody looked into the code for a long time" --=20 Corinna Vinschen Cygwin Maintainer --yhqQ34TVR4fE8mPU Content-Type: application/pgp-signature; name="signature.asc" Content-length: 833 -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAl5ZaLIACgkQ9TYGna5E T6DDRA/9HwYFl/XnWKztbNxO4UN9vn3nvvETQSuzQ9E8ALcViMiZPB0xgW4XcLXW t34xCVwie/7zR15qV5lM51fof77Yp4zg0v3Qal5EnlIp8Eb+v63vmTOpafYhy4kE m+juaw6KMpcQ+YCCiT3mBh/2p9NWpadxY4Y5SYpiBwE0j/JsRJd5bgfyEaGPcQsW ZQq//gtcg4Zfud/hC/hz55nD7W9bKtNjZhobvP0e+odhTxEvCI3sxFQ6KOPQvVyQ uQHfgOZnDWlDRaQWcKnBFWqJLZLu7t1Ajvdr0R7emBwepZOyqVkRA0eJzN05x5hR 37brWwc2oFrG0fr8cKIGPqymYxVYFB0RnSO53pRNMJ76HgP5jzPzDQKS3l/cpn0J Lg2cLB6VOgPSFX+VUMS1fCHQwDhvDY0bxL7IE0lCSA+FzP2TUbpoGuSkhtwXkuXc XdDlEEqOWlDXfIBLu053ZXh+dArtjSO/PoyGd4NJn3gS5diPXsT88UqfnKRZ/PhH 04ys0aHuN/wVPS9TPdrGwOziH96ACUryx/zX2fCZ5tIZrUBoyymeFg+dxfvThhwz kPNg/HFio0OoiV63kinJRd3Ev4Yw2D5sOV4njexpdM/2kKra28KUz934YAEdPDvb Frcswxbh80ctvO9m6nwpEJmClFPcBPusdA3OTkXN2j5fSHbSa2E= =KgDs -----END PGP SIGNATURE----- --yhqQ34TVR4fE8mPU--