Alexandre Oliva oliva@dcc.unicamp.br writes:
On Aug 31, 1999, Nick Burrett nick@dsvr.net wrote:
Alexandre Oliva oliva@dcc.unicamp.br writes:
+++ gcc/p/rts/file.c Sun Aug 29 15:56:11 1999 @@ -887,7 +887,7 @@ _p_f_write (File, Buf, Size)
[snip]
- ssize_t result =
- size_t result =
[snip]
- if (result < 0)
- if (result == (size_t)-1)
You cannot do this. size_t may be unsigned.
That's the reason why I'm explicitly casting -1 to that type.
Also fwrite returned zero on error
That's not covered in the original code. Since I've never heard of fwrite returning less than -1, I think it is as correct as the original code.
I'm suggesting that perhaps you stumbled across a proper bug. According to the man pages fwrite returns 0 on error and >0 on success. This is why I originally suggested that your fix may be not quite correct.
We'll come up with a proper solution if you want.
Cheers,
Nick.