Skip to content

Commit

Permalink
LibC: Make rewind() ignore errors as it should
Browse files Browse the repository at this point in the history
POSIX says that rewind() should ignore errors and reset the
stream's error indicator. So let's do that.
  • Loading branch information
gunnarbeutner authored and awesomekling committed Apr 29, 2021
1 parent 62ee003 commit 36ee8a8
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Userland/Libraries/LibC/stdio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,10 +873,8 @@ int fsetpos(FILE* stream, const fpos_t* pos)

void rewind(FILE* stream)
{
VERIFY(stream);
ScopedFileLock lock(stream);
int rc = stream->seek(0, SEEK_SET);
VERIFY(rc == 0);
fseek(stream, 0, SEEK_SET);
clearerr(stream);
}

ALWAYS_INLINE void stdout_putch(char*&, char ch)
Expand Down

0 comments on commit 36ee8a8

Please sign in to comment.