From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 55963 invoked by alias); 1 Dec 2017 17:19:25 -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 55955 invoked by uid 89); 1 Dec 2017 17:19:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: =?ISO-8859-1?Q?No, score=-99.0 required=5.0 tests=AWL,BAYES_50,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=intentionally, buffered=c2, screwed, fflush.=c2?= X-HELO: drew.franken.de Received: from mail-n.franken.de (HELO drew.franken.de) (193.175.24.27) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 01 Dec 2017 17:19:23 +0000 Received: from aqua.hirmke.de (aquarius.franken.de [193.175.24.89]) (Authenticated sender: aquarius) by mail-n.franken.de (Postfix) with ESMTPSA id E7557721E281C for ; Fri, 1 Dec 2017 18:19:18 +0100 (CET) Received: from calimero.vinschen.de (calimero.vinschen.de [192.168.129.6]) by aqua.hirmke.de (Postfix) with ESMTP id CA6B85E01A4 for ; Fri, 1 Dec 2017 18:19:14 +0100 (CET) Received: by calimero.vinschen.de (Postfix, from userid 500) id 46E7FA81808; Fri, 1 Dec 2017 18:19:17 +0100 (CET) Date: Fri, 01 Dec 2017 17:19:00 -0000 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: fseek(...,SEEK_CUR) calls _fflush_r(ptr, fp) in read only mode Message-ID: <20171201171917.GB4325@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <1470375482.5430561.1512147734234.ref@mail.yahoo.com> <1470375482.5430561.1512147734234@mail.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="hQiwHBbRI9kgIhsi" Content-Disposition: inline In-Reply-To: <1470375482.5430561.1512147734234@mail.yahoo.com> User-Agent: Mutt/1.9.1 (2017-09-22) X-SW-Source: 2017-12/txt/msg00010.txt.bz2 --hQiwHBbRI9kgIhsi Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1301 On Dec 1 17:02, Xiaofeng Liu via cygwin wrote: > In ftello.c, it intentionally skipped fflush for read mode: > https://github.com/openunix/cygwin/blob/master/newlib/libc/stdio/ftello.c= #L121 >=20 > /* Find offset of underlying I/O object, then adjust for buffered=C2=A0 = =C2=A0 =C2=A0bytes.=C2=A0 Flush a write stream, since the offset may be alt= ered if=C2=A0 =C2=A0 =C2=A0the stream is appending.=C2=A0 Do not flush a re= ad stream, since we=C2=A0 =C2=A0 =C2=A0must not lose the ungetc buffer.=C2= =A0 */=C2=A0 if (fp->_flags & __SWR)=C2=A0 =C2=A0 _fflush_r (ptr, fp); > But in fseeko.c, when fseek(..., SEEK_CUR) requires to get the current po= sition first. But it calls _fflush_r(ptr, fp) in read mode, which screwed u= p the current position after fflush.=C2=A0 > https://github.com/openunix/cygwin/blob/master/newlib/libc/stdio/fseeko.c= #L174 >=20 >=20 > For my job, if I skip _fflush_r for read only mode in fseek(..., SEEK_CUR= ), the job runs OK.=C2=A0 > Considering fseek(..., SEEK_CUR) is a basic call, could my understanding = be wrong?=C2=A0 Please provide a simple, self-contained testcase. It might clear up the problem. Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --hQiwHBbRI9kgIhsi Content-Type: application/pgp-signature; name="signature.asc" Content-length: 819 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJaIY8VAAoJEPU2Bp2uRE+g3ikP/ROAZmkfKyZQiiZZsDG4L0TK bvuc4ih8kkGT+4QLmsCZxyBkuJTDMmV41HOeULcOR44rDT79cSYuOpljGCF8hYN8 MYP+mQtHalelPNasu25+r3OWe+dbIo5EIuSoyxDJ8T0NT6j4uuNcSAw0q62Ab6zA HNB/xx/qBwL11o+v11Z5AQ9SY3TD6iiuOdVoh1IeoxnDa1sGprkFEXdw4MmXRHMN FtUDKJGbG0dCoDnU/eZ9lccdkvkb7wsvkIAQDrh1QDlRG2BBcDc0ACstREDf/jIc UYoMusVh+mDSc8eeLeWm2+JQQhJukTJwRgwExmMbZQKa0tiHahv6HL5oTzsjlhHX e6Xk+6XeNPKxDKIJkcrnhBxbYe9CpKvqyHL81TNiUMRPqQX/YtpHPr/Du5fTmyb/ p2Bjcy2UBYAK2mtxfLRpW7Br11IgpDAcfGuJEfPXRgyAo5dLPgt6+B7r6v/xcV5K Sa0QKGnqthOmjwZvpBrZ0j014GmpLN0Het20YKnnpSdvCiwjmYG0xOZYDtlyTvRt TqQ9d0l2j5+wyRIYw7oQacA1Y1uz21nENhGC2NTYrNmk6phjNXG8X7gDPyhT7mMK oq5xzNzI9nQRu7cdo23kj5mdOv+iGil6wWf5ERWMkz/q/mO2O7R5I1JJIN+kAA5l elFrNwEw8wumacj183Bx =+LrV -----END PGP SIGNATURE----- --hQiwHBbRI9kgIhsi--