Index | Thread | Search

From:
Todd C. Miller <millert@openbsd.org>
Subject:
Re: ftell
To:
enh <enh@google.com>
Cc:
OpenBSD Tech <tech@openbsd.org>
Date:
Thu, 09 Apr 2026 10:56:22 -0600

Download raw body.

Thread
  • enh:

    ftell

    • Todd C. Miller:

      ftell

On Thu, 09 Apr 2026 10:37:07 -0400, enh wrote:

> in ftell(), given:
>
> if (fp->_flags & __SWR)
>     __sflush(fp); /* may adjust seek offset on append stream */
>
> it seems like this is dead code because _p should always end up equal
> to _bf._base because we just flushed:
>
> } else if (fp->_flags & __SWR && fp->_p != NULL) {
>     /*
>      * Writing.  Any buffered characters cause the
>      * position to be greater than that in the
>      * underlying object.
>      */
>     pos += fp->_p - fp->_bf._base;
> }
>
> or am i missing something?

I think you are correct.  I don't see a way for fp->_p != fp->_bf._base
after the __sflush(fp).

 - todd