Mail Archives: djgpp-workers/2000/08/31/18:46:22
On Thu, 31 Aug 2000 22:05:50 +0200, you wrote:
> Jason Green wrote:
> > bail() will be called due to fseek outside file boundary, or fread
> > past eof; these are not failed system calls.
>
> Right, fseek() does not fail here. I don't know about fread.
AFAICT, fseek() only fails when seeking to before the start of file.
fread(), in effect, never fails. It just returns less bytes than you
asked for ;-).
The underlying cause could be a disk error, or just hitting eof. The
idea is you call feof() and/or ferror() to find out what happened. I
suspect if ferror() returns true then errno will have some meaningful
value.
> > If you know these
> > functions will always set errno=0 (no POSIX function is required to do
> > that) then your code would be safe.
>
> To be more exact, these functions do not alter errno at all, if they succeed.
> But this is OK too, unless some previous system function has failed, and this
> failure wasn't handled properly.
That is the risk with this approach.
> > Perhaps you
> > could mail the patch first, I'll re-run the tests I did, then you can
> > commit it.
>
> OK, I sent them in a separate mail.
I would change only one thing - for consistency:
--- src/debug/common/syms.c.bak Thu Aug 31 23:18:50 2000
+++ src/debug/common/syms.c Thu Aug 31 23:18:58 2000
@@ -569,7 +569,7 @@
FILE *fd = fopen(fname, "rb");
if (fd == 0)
{
- perror(fname);
+ bail(fname);
}
else
{
With the previous patches I posted, posible error messages were:
SYMIFY ERROR: unexpected end of file
SYMIFY ERROR: error reading from file
a:/foo: Permission denied (EACCES)
Under same conditions, with your patch plus the one above:
Symify error: unexpected end of file
Symify error: error reading from file: Permission denied (EACCES)
Symify error: a:/foo: Permission denied (EACCES)
Under same conditions, unmodified symify would:
Give misleading results, crash, GPF, lock-up reading a: drive.
So I say - commit the modified bail() plus the above patch.
--
[please cc all replies, thanks]
- Raw text -