aboutsummaryrefslogtreecommitdiff
path: root/tests/util/xmalloc.c
diff options
context:
space:
mode:
authorRuss Allbery <eagle@eyrie.org>2020-05-17 17:05:30 -0700
committerRuss Allbery <eagle@eyrie.org>2020-05-17 17:05:30 -0700
commitc138111a3c27863308b6552a5527a9e821a3dc11 (patch)
treefe3c16462bf0213708f20d251a63e5b9bbf2d23f /tests/util/xmalloc.c
parentccfbd34d597318215b979338c4cb5d7e4a3f0d6f (diff)
Update to rra-c-util 8.2 and C TAP Harness 4.7
Update to rra-c-util 8.2: * Implement explicit_bzero with memset if it is not available. * Reformat all C source using clang-format 10. * Work around Test::Strict not skipping .git directories. * Fix warnings with perltidy 20190601 and Perl::Critic 1.134. * Fix warnings with Clang 10, GCC 10, and the Clang static analyzer. Update to C TAP Harness 4.7: * Fix warnings with GCC 10. * Reformat all C source using clang-format 10. * Fixed malloc error checking in bstrndup.
Diffstat (limited to 'tests/util/xmalloc.c')
-rw-r--r--tests/util/xmalloc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/util/xmalloc.c b/tests/util/xmalloc.c
index d157bbb..eb6f1d2 100644
--- a/tests/util/xmalloc.c
+++ b/tests/util/xmalloc.c
@@ -4,7 +4,7 @@
* The canonical version of this file is maintained in the rra-c-util package,
* which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
*
- * Copyright 2000-2001, 2006, 2017 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2000-2001, 2006, 2017, 2020 Russ Allbery <eagle@eyrie.org>
* Copyright 2008, 2012-2014
* The Board of Trustees of the Leland Stanford Junior University
*
@@ -34,10 +34,11 @@
#include <config.h>
#include <portable/system.h>
+#include <assert.h>
#include <ctype.h>
#include <errno.h>
#ifdef HAVE_SYS_TIME_H
-# include <sys/time.h>
+# include <sys/time.h>
#endif
#include <time.h>
@@ -94,6 +95,7 @@ test_realloc(size_t size)
char *buffer;
size_t i;
+ assert(size > 10);
buffer = xmalloc(10);
if (buffer == NULL)
return 0;
@@ -101,8 +103,7 @@ test_realloc(size_t size)
buffer = xrealloc(buffer, size);
if (buffer == NULL)
return 0;
- if (size > 0)
- memset(buffer + 10, 2, size - 10);
+ memset(buffer + 10, 2, size - 10);
for (i = 0; i < 10; i++)
if (buffer[i] != 1)
return 0;
@@ -383,6 +384,7 @@ main(int argc, char *argv[])
#endif
}
+ /* clang-format off */
switch (code) {
case 'c': exit(test_calloc(size) ? willfail : 1);
case 'm': exit(test_malloc(size) ? willfail : 1);
@@ -394,5 +396,7 @@ main(int argc, char *argv[])
case 'v': exit(test_vasprintf(size) ? willfail : 1);
default: die("Unknown mode %c", argv[1][0]);
}
+ /* clang-format on */
+
exit(1);
}