summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/fortify-headers.h6
-rw-r--r--include/string.h3
2 files changed, 5 insertions, 4 deletions
diff --git a/include/fortify-headers.h b/include/fortify-headers.h
index 3eaed7c..bc7bf00 100644
--- a/include/fortify-headers.h
+++ b/include/fortify-headers.h
@@ -106,9 +106,9 @@
106#define __diagnose_as_builtin(...) 106#define __diagnose_as_builtin(...)
107#endif 107#endif
108 108
109#if __has_attribute (__diagnose_if) 109#if __has_attribute (diagnose_if)
110#define __warning_if(cond, msg) __attribute__ ((__diagnose_if (cond, msg, "warning"))) 110#define __warning_if(cond, msg) __attribute__ ((diagnose_if (cond, msg, "warning")))
111#define __error_if(cond, msg) __attribute__ ((__diagnose_if (cond, msg, "error"))) 111#define __error_if(cond, msg) __attribute__ ((diagnose_if (cond, msg, "error")))
112#else 112#else
113#define __warning_if(cond, msg) 113#define __warning_if(cond, msg)
114#define __error_if(cond, msg) 114#define __error_if(cond, msg)
diff --git a/include/string.h b/include/string.h
index be13cb4..010b7f2 100644
--- a/include/string.h
+++ b/include/string.h
@@ -43,6 +43,7 @@ __access(read_only, 2, 3)
43__diagnose_as_builtin(__builtin_memcpy, 1, 2, 3) 43__diagnose_as_builtin(__builtin_memcpy, 1, 2, 3)
44_FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od, 44_FORTIFY_FN(memcpy) void *memcpy(void * _FORTIFY_POS0 __od,
45 const void * _FORTIFY_POS0 __os, size_t __n) 45 const void * _FORTIFY_POS0 __os, size_t __n)
46__error_if((__bos(__od, 0) < __n), "'memcpy' called with `n` bigger than the size of `d`.")
46{ 47{
47 size_t __bd = __bos(__od, 0); 48 size_t __bd = __bos(__od, 0);
48 size_t __bs = __bos(__os, 0); 49 size_t __bs = __bos(__os, 0);
@@ -72,8 +73,8 @@ _FORTIFY_FN(memmove) void *memmove(void * _FORTIFY_POS0 __d,
72 73
73__access(write_only, 1, 3) 74__access(write_only, 1, 3)
74__diagnose_as_builtin(__builtin_memset, 1, 2, 3) 75__diagnose_as_builtin(__builtin_memset, 1, 2, 3)
75__warning_if(__c != 0 && __n == 0, "'memset' will set `0` bytes; did you invert the arguments?")
76_FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n) 76_FORTIFY_FN(memset) void *memset(void * _FORTIFY_POS0 __d, int __c, size_t __n)
77__warning_if(__c != 0 && __n == 0, "'memset' will set `0` bytes; did you invert the arguments?")
77{ 78{
78 size_t __b = __bos(__d, 0); 79 size_t __b = __bos(__d, 0);
79 80