diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/fortify-headers.h | 8 | ||||
| -rw-r--r-- | include/string.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/include/fortify-headers.h b/include/fortify-headers.h index 88a0875..3e2140f 100644 --- a/include/fortify-headers.h +++ b/include/fortify-headers.h | |||
| @@ -99,6 +99,14 @@ | |||
| 99 | #define __diagnose_as_builtin(...) | 99 | #define __diagnose_as_builtin(...) |
| 100 | #endif | 100 | #endif |
| 101 | 101 | ||
| 102 | #if __has_attribute (__diagnose_if) | ||
| 103 | #define __warning_if(cond, msg) __attribute__ ((__diagnose_if (cond, msg, "warning"))) | ||
| 104 | #define __error_if(cond, msg) __attribute__ ((__diagnose_if (cond, msg, "error"))) | ||
| 105 | #else | ||
| 106 | #define __warning_if(cond, msg) | ||
| 107 | #define __error_if(cond, msg) | ||
| 108 | #endif | ||
| 109 | |||
| 102 | #endif /* __has_attribute */ | 110 | #endif /* __has_attribute */ |
| 103 | 111 | ||
| 104 | /* | 112 | /* |
diff --git a/include/string.h b/include/string.h index 2c11e5e..342bde0 100644 --- a/include/string.h +++ b/include/string.h | |||
| @@ -75,6 +75,7 @@ _FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d, | |||
| 75 | 75 | ||
| 76 | __access(write_only, 1, 3) | 76 | __access(write_only, 1, 3) |
| 77 | __diagnose_as_builtin(__builtin_memset, 1, 2, 3) | 77 | __diagnose_as_builtin(__builtin_memset, 1, 2, 3) |
| 78 | __warning_if(__c != 0 && __n == 0, "'memset' will set `0` bytes; did you invert the arguments?") | ||
| 78 | _FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n) | 79 | _FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n) |
| 79 | { | 80 | { |
| 80 | size_t __b = __bos(__d, 0); | 81 | size_t __b = __bos(__d, 0); |
