]> eyrie.org Git - kerberos/krb5-strength.git/commitdiff
Avoid Clang warnings in util/xmalloc.c
authorRuss Allbery <eagle@eyrie.org>
Mon, 25 Dec 2023 21:23:27 +0000 (13:23 -0800)
committerRuss Allbery <eagle@eyrie.org>
Mon, 25 Dec 2023 21:23:27 +0000 (13:23 -0800)
The preprocessor code to suppress false positive GCC warnings needs
to be wrapped in a conditional since Clang doesn't understand that
warning flag.

util/xmalloc.c

index 43f26a1ee56367b488a8cfbd9c51c4b21243e7a5..21b53d5f206754fa2874872c727899d4e541b667 100644 (file)
@@ -159,14 +159,18 @@ 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.
          */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wuse-after-free"
+#if !defined(__clang__)
+#    pragma GCC diagnostic push
+#    pragma GCC diagnostic ignored "-Wuse-after-free"
+#endif
     while (newp == NULL) {
         (*xmalloc_error_handler)("realloc", size, file, line);
         newp = realloc(p, size);
     }
     return newp;
-#pragma GCC diagnostic pop
+#if !defined(__clang__)
+#    pragma GCC diagnostic pop
+#endif
 }
 
 
@@ -186,13 +190,17 @@ 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.
          */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wuse-after-free"
+#if !defined(__clang__)
+#    pragma GCC diagnostic push
+#    pragma GCC diagnostic ignored "-Wuse-after-free"
+#endif
     while (newp == NULL) {
         (*xmalloc_error_handler)("reallocarray", n *size, file, line);
         newp = reallocarray(p, n, size);
     }
-#pragma GCC diagnostic pop
+#if !defined(__clang__)
+#    pragma GCC diagnostic pop
+#endif
     return newp;
 }