diff options
| author | jvoisin | 2023-09-22 18:27:54 +0200 |
|---|---|---|
| committer | jvoisin | 2023-09-22 18:30:35 +0200 |
| commit | 75b95fa25df74fcd0498bf59e3524f20f594755d (patch) | |
| tree | 729ba69a2358566f126a8b20f9f30d7a5f7f249c /include/stdlib.h | |
| parent | 8c2352b985b1bf69efb965ba15f5e300eb7e8e12 (diff) | |
Add more __diagnose_as_builtin annotations
Diffstat (limited to 'include/stdlib.h')
| -rw-r--r-- | include/stdlib.h | 15 |
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 |
