[PATCH v2] Fix ftell with fdopen for all cases and fopen with a+ mode (#16532)
Rich Felker
dalias@aerifal.cx
Wed Feb 19 18:35:00 GMT 2014
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
More information about the Libc-alpha
mailing list