diff options
Diffstat (limited to 'tests/util')
-rw-r--r-- | tests/util/messages-t.c | 5 | ||||
-rwxr-xr-x | tests/util/xmalloc-t | 32 | ||||
-rw-r--r-- | tests/util/xmalloc.c | 7 |
3 files changed, 24 insertions, 20 deletions
diff --git a/tests/util/messages-t.c b/tests/util/messages-t.c index f60fa6a..1098314 100644 --- a/tests/util/messages-t.c +++ b/tests/util/messages-t.c @@ -5,7 +5,7 @@ * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>. * * Written by Russ Allbery <eagle@eyrie.org> - * Copyright 2002, 2004, 2005 Russ Allbery <eagle@eyrie.org> + * Copyright 2002, 2004, 2005, 2015 Russ Allbery <eagle@eyrie.org> * Copyright 2009, 2010, 2011, 2012 * The Board of Trustees of the Leland Stanford Junior University * @@ -92,7 +92,8 @@ static void test11(void *data UNUSED) { sysdie("fatal"); } -static void log_msg(size_t len, const char *format, va_list args, int error) { +static void __attribute__((__format__(printf, 2, 0))) +log_msg(size_t len, const char *format, va_list args, int error) { fprintf(stderr, "%lu %d ", (unsigned long) len, error); vfprintf(stderr, format, args); fprintf(stderr, "\n"); diff --git a/tests/util/xmalloc-t b/tests/util/xmalloc-t index d52c448..af604ed 100755 --- a/tests/util/xmalloc-t +++ b/tests/util/xmalloc-t @@ -99,46 +99,46 @@ ok_xmalloc "vasprintf large" 0 "" "v" "30000000" "0" # We assume that there are enough miscellaneous allocations that an allocation # exactly as large as the limit will always fail. ok_xmalloc "malloc fail" 1 \ - "failed to malloc 30000000 bytes at xmalloc.c line 38" \ + "failed to malloc 30000000 bytes at xmalloc.c line 41" \ "m" "30000000" "30000000" ok_xmalloc "realloc fail" 1 \ - "failed to realloc 30000000 bytes at xmalloc.c line 66" \ + "failed to realloc 30000000 bytes at xmalloc.c line 69" \ "r" "30000000" "30000000" ok_xmalloc "reallocarray fail" 1 \ - "failed to reallocarray 30000000 bytes at xmalloc.c line 96" \ + "failed to reallocarray 30000000 bytes at xmalloc.c line 99" \ "y" "30000000" "30000000" ok_xmalloc "strdup fail" 1 \ - "failed to strdup 30000000 bytes at xmalloc.c line 127" \ + "failed to strdup 30000000 bytes at xmalloc.c line 130" \ "s" "30000000" "30000000" ok_xmalloc "strndup fail" 1 \ - "failed to strndup 30000000 bytes at xmalloc.c line 173" \ + "failed to strndup 30000000 bytes at xmalloc.c line 176" \ "n" "30000000" "30000000" ok_xmalloc "calloc fail" 1 \ - "failed to calloc 30000000 bytes at xmalloc.c line 197" \ + "failed to calloc 30000000 bytes at xmalloc.c line 200" \ "c" "30000000" "30000000" ok_xmalloc "asprintf fail" 1 \ - "failed to asprintf 30000000 bytes at xmalloc.c line 221" \ + "failed to asprintf 30000000 bytes at xmalloc.c line 224" \ "a" "30000000" "30000000" ok_xmalloc "vasprintf fail" 1 \ - "failed to vasprintf 30000000 bytes at xmalloc.c line 240" \ + "failed to vasprintf 30000000 bytes at xmalloc.c line 243" \ "v" "30000000" "30000000" # Check our custom error handler. -ok_xmalloc "malloc custom" 1 "malloc 30000000 xmalloc.c 38" \ +ok_xmalloc "malloc custom" 1 "malloc 30000000 xmalloc.c 41" \ "M" "30000000" "30000000" -ok_xmalloc "realloc custom" 1 "realloc 30000000 xmalloc.c 66" \ +ok_xmalloc "realloc custom" 1 "realloc 30000000 xmalloc.c 69" \ "R" "30000000" "30000000" -ok_xmalloc "reallocarray custom" 1 "reallocarray 30000000 xmalloc.c 96" \ +ok_xmalloc "reallocarray custom" 1 "reallocarray 30000000 xmalloc.c 99" \ "Y" "30000000" "30000000" -ok_xmalloc "strdup custom" 1 "strdup 30000000 xmalloc.c 127" \ +ok_xmalloc "strdup custom" 1 "strdup 30000000 xmalloc.c 130" \ "S" "30000000" "30000000" -ok_xmalloc "strndup custom" 1 "strndup 30000000 xmalloc.c 173" \ +ok_xmalloc "strndup custom" 1 "strndup 30000000 xmalloc.c 176" \ "N" "30000000" "30000000" -ok_xmalloc "calloc custom" 1 "calloc 30000000 xmalloc.c 197" \ +ok_xmalloc "calloc custom" 1 "calloc 30000000 xmalloc.c 200" \ "C" "30000000" "30000000" -ok_xmalloc "asprintf custom" 1 "asprintf 30000000 xmalloc.c 221" \ +ok_xmalloc "asprintf custom" 1 "asprintf 30000000 xmalloc.c 224" \ "A" "30000000" "30000000" -ok_xmalloc "vasprintf custom" 1 "vasprintf 30000000 xmalloc.c 240" \ +ok_xmalloc "vasprintf custom" 1 "vasprintf 30000000 xmalloc.c 243" \ "V" "30000000" "30000000" # Check the smaller ones again just for grins. diff --git a/tests/util/xmalloc.c b/tests/util/xmalloc.c index e222612..84ba081 100644 --- a/tests/util/xmalloc.c +++ b/tests/util/xmalloc.c @@ -34,7 +34,10 @@ #include <ctype.h> #include <errno.h> -#include <sys/time.h> +#ifdef HAVE_SYS_TIME_H +# include <sys/time.h> +#endif +#include <time.h> /* Linux requires sys/time.h be included before sys/resource.h. */ #include <sys/resource.h> @@ -261,7 +264,7 @@ test_asprintf(size_t size) /* Wrapper around vasprintf to do the va_list stuff. */ -static void +static void __attribute__((__format__(printf, 2, 3))) xvasprintf_wrapper(char **strp, const char *format, ...) { va_list args; |