diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/fortify-headers.h | 6 | ||||
| -rw-r--r-- | include/stdlib.h | 1 | ||||
| -rw-r--r-- | include/string.h | 1 |
3 files changed, 8 insertions, 0 deletions
diff --git a/include/fortify-headers.h b/include/fortify-headers.h index 67c4792..1581076 100644 --- a/include/fortify-headers.h +++ b/include/fortify-headers.h | |||
| @@ -73,6 +73,12 @@ | |||
| 73 | #define __format(...) | 73 | #define __format(...) |
| 74 | #endif | 74 | #endif |
| 75 | 75 | ||
| 76 | #if __has_attribute (__diagnose_if) | ||
| 77 | #define __warning_if(cond, msg) __attribute__ ((__diagnose_if (cond, msg, "warning"))) | ||
| 78 | #else | ||
| 79 | #define __warning_if(cond, msg) | ||
| 80 | #endif | ||
| 81 | |||
| 76 | #endif | 82 | #endif |
| 77 | 83 | ||
| 78 | #endif | 84 | #endif |
diff --git a/include/stdlib.h b/include/stdlib.h index 38015d4..aeed102 100644 --- a/include/stdlib.h +++ b/include/stdlib.h | |||
| @@ -39,6 +39,7 @@ extern "C" { | |||
| 39 | /* FIXME clang */ | 39 | /* FIXME clang */ |
| 40 | #if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__) | 40 | #if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__) |
| 41 | #undef realpath | 41 | #undef realpath |
| 42 | __warning_if(__p == NULL, "'realpath' called with path set to `NULL`; did you invert the arguments?") | ||
| 42 | _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) | 43 | _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) |
| 43 | { | 44 | { |
| 44 | #ifndef PATH_MAX | 45 | #ifndef PATH_MAX |
diff --git a/include/string.h b/include/string.h index cf0be60..987b50c 100644 --- a/include/string.h +++ b/include/string.h | |||
| @@ -71,6 +71,7 @@ _FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d, | |||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | __access(write_only, 1, 3) | 73 | __access(write_only, 1, 3) |
| 74 | __warning_if(__c != 0 && __n == 0, "'memset' will set `0` bytes; did you invert the arguments?") | ||
| 74 | _FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n) | 75 | _FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n) |
| 75 | { | 76 | { |
| 76 | size_t __b = __bos(__d, 0); | 77 | size_t __b = __bos(__d, 0); |
