]> eyrie.org Git - kerberos/krb5-strength.git/blobdiff - tests/runtests.c
Update to rra-c-util 10.5
[kerberos/krb5-strength.git] / tests / runtests.c
index 1050120c7f084405b20ad02d584f1b1440a2ffcd..72f4a70d992bf1f3952d6943fb8d8bbb826a6f28 100644 (file)
@@ -8,7 +8,7 @@
  * should be sent to the e-mail address below.  This program is part of C TAP
  * Harness <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2000-2001, 2004, 2006-2019 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2000-2001, 2004, 2006-2019, 2022 Russ Allbery <eagle@eyrie.org>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
 #endif
 
 /* Test status codes. */
-enum test_status { TEST_FAIL, TEST_PASS, TEST_SKIP, TEST_INVALID };
+enum test_status {
+    TEST_FAIL,
+    TEST_PASS,
+    TEST_SKIP,
+    TEST_INVALID
+};
 
 /* Really, just a boolean, but this is more self-documenting. */
-enum test_verbose { CONCISE = 0, VERBOSE = 1 };
+enum test_verbose {
+    CONCISE = 0,
+    VERBOSE = 1
+};
 
 /* Indicates the state of our plan. */
 enum plan_status {
@@ -272,6 +280,16 @@ Failed Set                 Fail/Total (%) Skip Stat  Failing Tests\n\
 #    endif
 #endif
 
+/*
+ * Suppress the argument to __malloc__ in Clang (not supported in at least
+ * version 13) and GCC versions prior to 11.
+ */
+#if !defined(__attribute__) && !defined(__malloc__)
+#    if defined(__clang__) || __GNUC__ < 11
+#        define __malloc__(dalloc) __malloc__
+#    endif
+#endif
+
 /*
  * LLVM and Clang pretend to be GCC but don't support all of the __attribute__
  * settings that GCC does.  For them, suppress warnings about unknown
@@ -288,15 +306,15 @@ static void die(const char *, ...)
 static void sysdie(const char *, ...)
     __attribute__((__nonnull__, __noreturn__, __format__(printf, 1, 2)));
 static void *x_calloc(size_t, size_t, const char *, int)
-    __attribute__((__alloc_size__(1, 2), __malloc__, __nonnull__));
+    __attribute__((__alloc_size__(1, 2), __malloc__(free), __nonnull__));
 static void *x_malloc(size_t, const char *, int)
-    __attribute__((__alloc_size__(1), __malloc__, __nonnull__));
+    __attribute__((__alloc_size__(1), __malloc__(free), __nonnull__));
 static void *x_reallocarray(void *, size_t, size_t, const char *, int)
-    __attribute__((__alloc_size__(2, 3), __malloc__, __nonnull__(4)));
+    __attribute__((__alloc_size__(2, 3), __malloc__(free), __nonnull__(4)));
 static char *x_strdup(const char *, const char *, int)
-    __attribute__((__malloc__, __nonnull__));
+    __attribute__((__malloc__(free), __nonnull__));
 static char *x_strndup(const char *, size_t, const char *, int)
-    __attribute__((__malloc__, __nonnull__));
+    __attribute__((__malloc__(free), __nonnull__));
 
 
 /*
@@ -435,9 +453,9 @@ x_strndup(const char *s, size_t size, const char *file, int line)
     char *copy;
 
     /* Don't assume that the source string is nul-terminated. */
-    for (p = s; (size_t)(p - s) < size && *p != '\0'; p++)
+    for (p = s; (size_t) (p - s) < size && *p != '\0'; p++)
         ;
-    len = (size_t)(p - s);
+    len = (size_t) (p - s);
     copy = (char *) malloc(len + 1);
     if (copy == NULL)
         sysdie("failed to strndup %lu bytes at %s line %d",