summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2024-01-31 16:07:01 -0500
committerJakob Kaivo <jkk@ung.org>2024-01-31 16:07:01 -0500
commite700c9df7679b7a4e5da0e8886ff22a4177f4bca (patch)
tree9ad9dccfd8237a7999f9546c4f00388306b1352b
parent34386fe72b733e12f5ab45bf1d4f5b59621c3a96 (diff)
check for undefined fopen()/freopen() modes
-rw-r--r--src/stdio/fopen.c2
-rw-r--r--src/stdio/freopen.c4
2 files changed, 6 insertions, 0 deletions
diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c
index 4c9eabd7..dfb4f27c 100644
--- a/src/stdio/fopen.c
+++ b/src/stdio/fopen.c
@@ -37,6 +37,8 @@ FILE * fopen(const char * restrict filename, const char * restrict mode)
return freopen(filename, mode, f);
}
+CHECK_2(FILE *, NULL, fopen, const char * restrict, const char * restrict)
+
/***
opens a file stream associated with the file ARGUMENT(filename).
diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c
index 050e556b..0fd0a2f8 100644
--- a/src/stdio/freopen.c
+++ b/src/stdio/freopen.c
@@ -23,6 +23,7 @@
/** reopen a file stream with a new file **/
+GCC_SSE_HACK
FILE * freopen(const char * restrict filename, const char * restrict mode, FILE * restrict stream)
{
struct {
@@ -69,6 +70,7 @@ FILE * freopen(const char * restrict filename, const char * restrict mode, FILE
}
if (openmode == -1) {
+ __undefined("\"%s\" is not a valid mode for fopen() or freopen()", mode);
#ifdef EINVAL
errno = EINVAL;
#endif
@@ -102,6 +104,8 @@ FILE * freopen(const char * restrict filename, const char * restrict mode, FILE
return stream;
}
+CHECK_3(FILE *, NULL, freopen, const char * restrict, const char * restrict, FILE * restrict)
+
/***
changes the file associated with ARGUMENT(stream) to
ARGUMENT(filename). The meaning of ARGUMENT(mode) is the same as with