summaryrefslogtreecommitdiff
path: root/include/stdlib.h
diff options
context:
space:
mode:
authorjvoisin2023-09-22 18:27:54 +0200
committerjvoisin2023-09-22 18:30:35 +0200
commit75b95fa25df74fcd0498bf59e3524f20f594755d (patch)
tree729ba69a2358566f126a8b20f9f30d7a5f7f249c /include/stdlib.h
parent8c2352b985b1bf69efb965ba15f5e300eb7e8e12 (diff)
Add more __diagnose_as_builtin annotations
Diffstat (limited to 'include/stdlib.h')
-rw-r--r--include/stdlib.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/include/stdlib.h b/include/stdlib.h
index 734f0e6..d3cd863 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -43,6 +43,9 @@ extern "C" {
43__malloc(malloc (free, 1)) 43__malloc(malloc (free, 1))
44__alloc_size(1) 44__alloc_size(1)
45__warn_unused_result 45__warn_unused_result
46#if __has_builtin(__builtin_malloc)
47__diagnose_as_builtin(__builtin_malloc, 1)
48#endif
46_FORTIFY_FN(malloc) void *malloc(size_t __s) 49_FORTIFY_FN(malloc) void *malloc(size_t __s)
47{ 50{
48 return __orig_malloc(__s); 51 return __orig_malloc(__s);
@@ -50,6 +53,9 @@ _FORTIFY_FN(malloc) void *malloc(size_t __s)
50 53
51__alloc_size(2) 54__alloc_size(2)
52__warn_unused_result 55__warn_unused_result
56#if __has_builtin(__builtin_realloc)
57__diagnose_as_builtin(__builtin_realloc, 1, 2)
58#endif
53_FORTIFY_FN(realloc) void *realloc(void *__p, size_t __s) 59_FORTIFY_FN(realloc) void *realloc(void *__p, size_t __s)
54{ 60{
55 return __orig_realloc(__p, __s); 61 return __orig_realloc(__p, __s);
@@ -57,6 +63,9 @@ _FORTIFY_FN(realloc) void *realloc(void *__p, size_t __s)
57 63
58__alloc_size(1, 2) 64__alloc_size(1, 2)
59__warn_unused_result 65__warn_unused_result
66#if __has_builtin(__builtin_calloc)
67__diagnose_as_builtin(__builtin_calloc, 1, 2)
68#endif
60_FORTIFY_FN(calloc) void *calloc(size_t __n, size_t __s) 69_FORTIFY_FN(calloc) void *calloc(size_t __n, size_t __s)
61{ 70{
62 return __orig_calloc(__n, __s); 71 return __orig_calloc(__n, __s);
@@ -66,6 +75,9 @@ _FORTIFY_FN(calloc) void *calloc(size_t __n, size_t __s)
66#undef reallocarray 75#undef reallocarray
67__alloc_size (2, 3) 76__alloc_size (2, 3)
68__warn_unused_result 77__warn_unused_result
78#if __has_builtin(__builtin_reallocarray)
79__diagnose_as_builtin(__builtin_reallocarray, 1, 2, 3)
80#endif
69_FORTIFY_FN(reallocarray) void* reallocarray(void* __p, size_t __n, size_t __s) 81_FORTIFY_FN(reallocarray) void* reallocarray(void* __p, size_t __n, size_t __s)
70{ 82{
71 return __orig_reallocarray(__p, __n, __s); 83 return __orig_reallocarray(__p, __n, __s);
@@ -76,6 +88,9 @@ _FORTIFY_FN(reallocarray) void* reallocarray(void* __p, size_t __n, size_t __s)
76#if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__) 88#if (defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)) && !defined(__clang__)
77#undef realpath 89#undef realpath
78__warning_if(__p == NULL, "'realpath' called with path set to `NULL`; did you invert the arguments?") 90__warning_if(__p == NULL, "'realpath' called with path set to `NULL`; did you invert the arguments?")
91#if __has_builtin(__builtin_realpath)
92__diagnose_as_builtin(__builtin_realpath, 1, 2)
93#endif
79_FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) 94_FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r)
80{ 95{
81#ifndef PATH_MAX 96#ifndef PATH_MAX