This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Re: STDIO - proposed fix for fread()
Gary Thomas wrote:
On Thu, 2003-03-06 at 12:41, Jonathan Larmour wrote:
Gary Thomas wrote:
The 'fread()' function works differently on eCos than it does on Linux.
Thusly, some programs which work fine on Linux fail on eCos. The
problem is that fread() sets ferror() when it gets to the end of the
file (as well as setting feof()). This patch fixes it, and also adds a
test for the condition.
Does it make sense? Shall I commit?
Well those programs are using unspecified behaviour so strictly they are
non-portable. Checking for ferror() without a reported error is as porr
practice as checking for errno without a reported error.
But we may as well probably deal with this although I'm not particularly
happy about adding a test for something that only non-portable programs
use. But still it's the least worst option :-).
If you could add a comment in the test saying as much that would be nice,
i.e. standard doesn't require it, but we'll be nice to programs anyway.
I'll add a comment, but I'm not convinced how wrong/non-portable this
usage is. The [Linux] man page for 'fread' explicitly states that it
does not distinguish between EOF and error conditions and that an
application must use feof() and ferror() to ferret it out.
Since some systems have an EEOF (not us admittedly) it would make sense
for a portable program to check feof() first before ferror(). The Linux
man pages obviously reflect Linux :-). But yes it will make programs
simpler to change eCos this way regardless.
+#include <cyg/fileio/fileio.h>
Probably need not include this.
This brought in the prototype for mount().
Oh, oops. In that case what is unistd.h for? Just checking there isn't a
dependency on something somewhere that isn't explicit.
Jifl
--
eCosCentric http://www.eCosCentric.com/ The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[ can rejoice because thorns have roses." -Lincoln ]-- Opinions==mine