diff options
| author | jvoisin | 2023-09-11 20:23:12 +0200 |
|---|---|---|
| committer | jvoisin | 2023-09-11 20:23:12 +0200 |
| commit | b2c20e6c16278fe556ce4c4ff7d3b146b3a8f009 (patch) | |
| tree | b2d0596b1cfec9344cff603f0ae6b79a8f12d97e /include/fortify-headers.h | |
| parent | b9bd9400d2a6a4484ef92d708f363b9e8d0e3cb7 (diff) | |
Factorize overlap checks into a macro
Diffstat (limited to 'include/fortify-headers.h')
| -rw-r--r-- | include/fortify-headers.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/fortify-headers.h b/include/fortify-headers.h index 5be4271..3eaed7c 100644 --- a/include/fortify-headers.h +++ b/include/fortify-headers.h | |||
| @@ -123,6 +123,15 @@ | |||
| 123 | 123 | ||
| 124 | #endif /* __has_attribute */ | 124 | #endif /* __has_attribute */ |
| 125 | 125 | ||
| 126 | //TODO(jvoisin) Add a check for overflows | ||
| 127 | /* check if pointers are overlapping but not if dst == src, | ||
| 128 | * since gcc seems to like to generate code that relies on dst == src */ | ||
| 129 | #define __fh_overlap(a, b, l) \ | ||
| 130 | ( \ | ||
| 131 | ((a) < (b) && (b) < (a) + (size_t)(l)) \ | ||
| 132 | || ((b) < (a) && (a) < (b) + (size_t)(l)) \ | ||
| 133 | ) | ||
| 134 | |||
| 126 | /* | 135 | /* |
| 127 | * We're not making use of C23's <stdckdint.h> since: | 136 | * We're not making use of C23's <stdckdint.h> since: |
| 128 | * - there is no elegant way to make it ignore the results. | 137 | * - there is no elegant way to make it ignore the results. |
