Compare commits

..

No commits in common. "2980ee3973cd51cc8cb1adfca12dba5a70f291fe" and "40b078e0a21ecb998702b895d80550ffb698414e" have entirely different histories.

2 changed files with 7 additions and 9 deletions

View File

@ -21,7 +21,7 @@ void show_motd()
}
char buf[4096];
size_t nread = fread(buf, 1, sizeof(buf) - 1, fp);
size_t nread = fread(buf, sizeof(buf) - 1, 1, fp);
if (ferror(fp))
{
perror("fread");

View File

@ -127,15 +127,15 @@ extern "C"
size_t fread(void* buf, size_t size, size_t nmemb, FILE* stream)
{
size_t rsize = size * nmemb;
ssize_t status = read(stream->f_fd, buf, rsize);
ssize_t status =
read(stream->f_fd, buf,
size * nmemb); // FIXME: This function should use file_read_buf() to not conflict with fgets().
if (status < 0)
{
stream->f_err = 1;
return 0;
}
if (status == 0 && rsize) stream->f_eof = 1;
if (status == 0) return (size_t)status;
if (status == 0) stream->f_eof = 1;
return (size_t)status / size;
}
@ -281,15 +281,13 @@ extern "C"
size_t fwrite(const void* buf, size_t size, size_t nmemb, FILE* stream)
{
size_t rsize = size * nmemb;
ssize_t status = write(stream->f_fd, buf, rsize);
ssize_t status = write(stream->f_fd, buf, size * nmemb);
if (status < 0)
{
stream->f_err = 1;
return 0;
}
if (status == 0 && rsize) stream->f_eof = 1;
if (status == 0) return (size_t)status;
if (status == 0) stream->f_eof = 1;
return (size_t)status / size;
}