Bug 6885 - unclear descriptions of __fwriting and __freading
Summary: unclear descriptions of __fwriting and __freading
Alias: None
Product: glibc
Classification: Unclassified
Component: manual (show other bugs)
Version: unspecified
: P2 minor
Target Milestone: ---
Assignee: Roland McGrath
Depends on:
Reported: 2008-09-13 18:29 UTC by Siward de Groot
Modified: 2014-07-02 07:41 UTC (History)
3 users (show)

See Also:
Last reconfirmed:
fweimer: security-


Note You need to log in before you can comment on or make changes to this bug.
Description Siward de Groot 2008-09-13 18:29:05 UTC
from text version of glibc manual, section 12.3 :

 int __fwriting( FILE* STREAM )
	 determines whether stream STREAM was last written to or whether it is opened
	 In this case return value is nonzero, otherwise it is zero.
	 This function is declared in `stdio_ext.h'.

this is a bit confusing.
description of __freading is similar, despite it providing some clue.
Comment 1 paxdiablo 2014-06-23 02:27:03 UTC
Not sure what the confusion is there? Perhaps you could clarify.

My reading is that, if you last wrote to a read/write (RW) file or if you've opened it write-only (whether you've written to it or not), you get back a true (non-zero) value.

All other cases give you false (0), including a RW file where you've neither read nor written yet.

Some may prefer to consider that a SchrodingerCat mode but the doco makes it quite clear here that __fwriting() returns false in that case.
Comment 2 Florian Weimer 2014-07-02 07:41:19 UTC
I agree that the quoted wording is clear enough, so closing.