This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Re: STDIO - proposed fix for fread()
- From: Jonathan Larmour <jifl at eCosCentric dot com>
- To: Gary Thomas <gary at mlbassoc dot com>
- Cc: eCos patches <ecos-patches at sources dot redhat dot com>
- Date: Thu, 06 Mar 2003 19:41:01 +0000
- Subject: Re: STDIO - proposed fix for fread()
- References: <1046972536.18776.3194.camel@hermes.chez-thomas.org>
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.
+#include <cyg/fileio/fileio.h>
Probably need not include this.
You should also probably do a clearerr() first before anything else.
You may as well do a CYG_TEST_CHECK of the fclose() and fseek() return
codes too. Maybe also quickly check fprintf returns >0 too. This is a test
after all so we may as well be thorough :-).
And instead of CYG_TEST_FAIL("..."); return; throughout, you should use
CYG_TEST_FAIL_FINISH().
Other than that, good stuff! Go for it.
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