X-Recipient: archive-cygwin AT delorie DOT com DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; q=dns; s= default; b=NvMUa6q2IACEyuLgc1b0p2OhGGdEy6p8aJLLYKS2ReJ845sZF6KZl dFhMbTZn6z0gPZJghxL8uyIcMHfcYSXjmO2PYJbRJDEact5aXRWge1q5OBLGpzp4 LIWZK3TnOpApF6cLW4rDpl3U0DUpLINMdIBiD3YYDbi7XhHAomRXfo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:reply-to :references:mime-version:content-type:in-reply-to; s=default; bh=yoCpPSzPOfvILGm6IzGdMR97hVo=; b=sQe2OGXkhmVrp8k3hcYo5OqqQ3el m2xJD2VYCC3QAfDekxcKRF6mM0NR5bmN8M6qlRHVQwHwXRtHJTTaNxkjGqj1plj9 W0JBU+jwUQYdq4wjEhsU6LKlzc1qNcrcezheayTIBXpcOJfu/C12troNIHvVvt29 tReJR5CMi7ApV/s= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 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 Date: Fri, 1 Dec 2017 18:19:17 +0100 From: Corinna Vinschen To: cygwin AT cygwin DOT 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 AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: <1470375482 DOT 5430561 DOT 1512147734234 DOT ref AT mail DOT yahoo DOT com> <1470375482 DOT 5430561 DOT 1512147734234 AT mail DOT yahoo DOT 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) --hQiwHBbRI9kgIhsi Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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" -----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--