From: Russ Allbery Date: Mon, 25 Dec 2023 22:25:11 +0000 (-0800) Subject: Make xmalloc diagnostic suppression conditional X-Git-Tag: release/3.3~8 X-Git-Url: https://git.eyrie.org/?a=commitdiff_plain;h=f01375baadbcd5c04f75874a37f093156ee0dbe9;p=kerberos%2Fkrb5-strength.git Make xmalloc diagnostic suppression conditional It looks like -Wuse-after-free was added in GCC 12, although it doesn't appear in the changes. Make suppressing diagnostics about it in util/xmalloc.c conditional on that version to avoid problems on GitHub CI with an older GCC version. --- diff --git a/util/xmalloc.c b/util/xmalloc.c index 21b53d5..8495e60 100644 --- a/util/xmalloc.c +++ b/util/xmalloc.c @@ -159,7 +159,7 @@ x_realloc(void *p, size_t size, const char *file, int line) * that if realloc fails (which is true in every case when it returns * NULL when size > 0), p is unchanged and still valid. */ -#if !defined(__clang__) +#if __GNUC__ >= 12 && !defined(__clang__) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wuse-after-free" #endif @@ -168,7 +168,7 @@ x_realloc(void *p, size_t size, const char *file, int line) newp = realloc(p, size); } return newp; -#if !defined(__clang__) +#if __GNUC__ >= 12 && !defined(__clang__) # pragma GCC diagnostic pop #endif } @@ -190,7 +190,7 @@ x_reallocarray(void *p, size_t n, size_t size, const char *file, int line) * every case when it returns NULL when size > 0 and n > 0), p is * unchanged and still valid. */ -#if !defined(__clang__) +#if __GNUC__ >= 12 && !defined(__clang__) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wuse-after-free" #endif @@ -198,7 +198,7 @@ x_reallocarray(void *p, size_t n, size_t size, const char *file, int line) (*xmalloc_error_handler)("reallocarray", n *size, file, line); newp = reallocarray(p, n, size); } -#if !defined(__clang__) +#if __GNUC__ >= 12 && !defined(__clang__) # pragma GCC diagnostic pop #endif return newp;