Skip to content

Commit f92a679

Browse files
committed
stdio stuff
1 parent a169268 commit f92a679

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

libc/src/stdio/fclose.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,15 @@
2828
/**
2929
*
3030
*/
31-
int fclose(FILE* stream) {
31+
int fclose(FILE* stream)
32+
{
33+
if(!stream)
34+
return EOF;
3235

3336
// close file
3437
int res = __fclose_static(stream);
35-
if (res != 0) {
38+
if(res != 0)
39+
{
3640
return EOF;
3741
}
3842

libc/src/stdio/ferror.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,19 @@
2424
/**
2525
*
2626
*/
27-
int ferror(FILE* stream) {
27+
int ferror(FILE* stream)
28+
{
29+
if(!stream)
30+
return EOF;
2831

2932
g_mutex_acquire(stream->lock);
3033
int res;
31-
if (stream->impl_error) {
34+
if(stream->impl_error)
35+
{
3236
res = stream->impl_error(stream);
33-
} else {
37+
}
38+
else
39+
{
3440
errno = ENOTSUP;
3541
res = EOF;
3642
}

libc/src/stdio/fread.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
/**
2727
*
2828
*/
29-
size_t fread(const void* ptr, size_t size, size_t nmemb, FILE* stream) {
29+
size_t fread(const void* ptr, size_t size, size_t nmemb, FILE* stream)
30+
{
31+
if(!stream)
32+
return EOF;
3033

3134
g_mutex_acquire(stream->lock);
3235
size_t len = __fread_unlocked(ptr, size, nmemb, stream);

0 commit comments

Comments
 (0)