Commit 2c3b1fa
committed
Fix usages of
From `man 3 fread`:
> The function **fread()** does not distinguish between end-of-file and
> error; callers must use `feof(3)` and `ferror(3)` to determine which
> occurred.
> The function **fwrite()** returns a value less than _nitems_ only if a
> write error has occurred.
So we don't need to loop and check for `fwrite`, since it only returns
anything smaller than `size` if it failed. It also doesn't set `ferror`
so that's the wrong way to test for an error.
Also, while `man` says nothing about `errno`, the UNIX spec for `fread`
and `fwrite` says:
> Otherwise, if a read error occurs, the error indicator for the stream
> is set and _errno_ is set to indicate the error.
(See
[here](https://pubs.opengroup.org/onlinepubs/7908799/xsh/fread.html))
So I removed the TODO comment about it.fread and fwrite
1 parent 27ccae4 commit 2c3b1fa
1 file changed
+4
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1756 | 1756 | | |
1757 | 1757 | | |
1758 | 1758 | | |
1759 | | - | |
1760 | 1759 | | |
1761 | 1760 | | |
1762 | 1761 | | |
| |||
1769 | 1768 | | |
1770 | 1769 | | |
1771 | 1770 | | |
1772 | | - | |
1773 | | - | |
1774 | | - | |
1775 | | - | |
1776 | | - | |
1777 | | - | |
1778 | | - | |
1779 | | - | |
1780 | | - | |
| 1771 | + | |
| 1772 | + | |
| 1773 | + | |
| 1774 | + | |
1781 | 1775 | | |
1782 | 1776 | | |
1783 | 1777 | | |
| |||
2102 | 2096 | | |
2103 | 2097 | | |
2104 | 2098 | | |
2105 | | - | |
2106 | 2099 | | |
2107 | 2100 | | |
2108 | 2101 | | |
| |||
0 commit comments