This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] Fix ftell with fdopen for all cases and fopen with a+ mode (#16532)
- From: Rich Felker <dalias at aerifal dot cx>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 19 Feb 2014 13:35:02 -0500
- Subject: Re: [PATCH v2] Fix ftell with fdopen for all cases and fopen with a+ mode (#16532)
- Authentication-results: sourceware.org; auth=none
- References: <20140218160649 dot GA20628 at spoyarek dot pnq dot redhat dot com> <20140218162735 dot GQ184 at brightrain dot aerifal dot cx> <20140218164449 dot GN27461 at spoyarek dot pnq dot redhat dot com> <20140219055053 dot GU184 at brightrain dot aerifal dot cx> <20140219072113 dot GR27461 at spoyarek dot pnq dot redhat dot com>
On Wed, Feb 19, 2014 at 12:51:13PM +0530, Siddhesh Poyarekar wrote:
> On Wed, Feb 19, 2014 at 12:50:53AM -0500, Rich Felker wrote:
> > I looked briefly at the patch and I don't see anything particularly
> > wrong about it; at least it doesn't seem to make anything worse and
> > looks like it fixes the particular issue. But I suspect you might end
> > up removing or at least rewriting/moving this logic in fixing #16605.
>
> You're right. I guess writes to the FILE pointer object should be
> forbidden in ftell altogether, since it does not serve any purpose.
I'm not sure what you mean by this. Certainly at least some writes are
required, e.g. obtaining the lock. But I think you can still cache the
offset as long as the FILE is currently reading or writing. One easy
way to know you can cache the offset is when the buffer is non-empty,
but there also seem to be some cases where you can cache it even when
the buffer is empty; I'm not sure if it's worth optimizing for those
too.
Rich