diff --git a/Userland/Libraries/LibC/stdio.cpp b/Userland/Libraries/LibC/stdio.cpp index a4d372e6d03..5c6247bc085 100644 --- a/Userland/Libraries/LibC/stdio.cpp +++ b/Userland/Libraries/LibC/stdio.cpp @@ -631,12 +631,10 @@ char* fgets(char* buffer, int size, FILE* stream) int fgetc(FILE* stream) { VERIFY(stream); - char ch; - size_t nread = fread(&ch, sizeof(char), 1, stream); + unsigned char ch; + size_t nread = fread(&ch, sizeof(unsigned char), 1, stream); if (nread == 1) { - // Note: We do this static_cast because otherwise when casting a char that contains - // 0xFF results in an int containing -1, so an explicit cast is required here. - return static_cast(ch & 0xff); + return ch; } return EOF; } @@ -644,8 +642,8 @@ int fgetc(FILE* stream) int fgetc_unlocked(FILE* stream) { VERIFY(stream); - char ch; - size_t nread = fread_unlocked(&ch, sizeof(char), 1, stream); + unsigned char ch; + size_t nread = fread_unlocked(&ch, sizeof(unsigned char), 1, stream); if (nread == 1) return ch; return EOF;