Bug 6885

Summary: unclear descriptions of __fwriting and __freading
Product: glibc Reporter: Siward de Groot <siward>
Component: manualAssignee: Roland McGrath <roland>
Status: RESOLVED WORKSFORME    
Severity: minor CC: fweimer, glibc-bugs, lynneandallan
Priority: P2 Flags: fweimer: security-
Version: unspecified   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:

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
write-only.
	 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.