This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gshyam: 1.5.5.1 fgetc returns no error for bad file descriptor]


On Tue, Mar 09, 2004 at 05:49:14PM -0500, Jeff Johnston wrote:
>This is not totally surprising.  Newlib is not Posix-conformant.  A
>number of the I/O functions (e.g.  fgetc, fputc, fflush) do not
>directly set errno.  ANSI-90 does not dictate them to.  As simple as
>fixing this seems, work is required to properly set up calls to handle
>thread-specific errnos.  If the end-user is trying to push newlib
>through a Posix-conformance suite, then this won't be the only problem
>to face.

Thanks for the clarification, Jeff.

This sounds like something I should put in the cygwin FAQ.  Do you mind
if I add the above statement verbatim?

cgf


>-- Jeff J.
>
>Christopher Faylor wrote:
>>[reply-to set]
>>This observation, sent to the cygwin mailing list, is apparently correct.
>>fgetc doesn't set errno when trying to read from an fp that is only open
>>for writing.
>>
>>The attached test program results in this output:
>>
>>  fp 0xc30c4c, fd 4
>>  -1 = fgetc
>>  fgetc: No error
>>  -1 = read
>>  read: Bad file descriptor
>>
>>cgf
>>
>>----- Forwarded message from Ghanshyam <gshyam> -----
>>
>>From: Ghanshyam
>>To: cygwin
>>Subject: 1.5.5.1 fgetc returns no error for bad file descriptor
>>Date: Mon, 8 Mar 2004 20:11:37 +0000 (GMT)
>>
>>
>>Hi All,
>>    The 9th assertion of fgetc in "IEEE std 2003.1-1992 Test Methods for
>>Measuring Conformance to Posix-Part1 System Interface" document states:
>>    When the stream pointer argument addresses a file descriptor that
>>is not open for reading, then a call to fgetc()returns a value of 
>>EOF and sets errno to [EBADF].
>>The current implementation does not set any errno. It says "No error". 
>>
>>Regards,
>>ghanshyam
>>
>>----- End forwarded message -----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]