INN commit: trunk (9 files)
INN Commit
rra at isc.org
Thu Jan 4 15:09:43 UTC 2018
Date: Thursday, January 4, 2018 @ 07:09:43
Author: iulius
Revision: 10213
Update to latest rra-c-util and C TAP Harness upstream versions
Modified:
trunk/lib/inet_aton.c
trunk/lib/network.c
trunk/lib/snprintf.c
trunk/tests/lib/fakewrite.c
trunk/tests/lib/xwrite-t.c
trunk/tests/runtests.c
trunk/tests/tap/basic.c
trunk/tests/tap/basic.h
trunk/tests/tap/float.c
-----------------------+
lib/inet_aton.c | 2 +-
lib/network.c | 4 ++--
lib/snprintf.c | 4 ++--
tests/lib/fakewrite.c | 4 ++--
tests/lib/xwrite-t.c | 12 ++++++------
tests/runtests.c | 10 ++++++----
tests/tap/basic.c | 39 ++++++++++++++++++++++++++++++++++++++-
tests/tap/basic.h | 5 ++++-
tests/tap/float.c | 11 ++++++++++-
9 files changed, 71 insertions(+), 20 deletions(-)
Modified: lib/inet_aton.c
===================================================================
--- lib/inet_aton.c 2018-01-04 15:06:39 UTC (rev 10212)
+++ lib/inet_aton.c 2018-01-04 15:09:43 UTC (rev 10213)
@@ -37,7 +37,7 @@
int
inet_aton(const char *s, struct in_addr *addr)
{
- unsigned long octet[4];
+ unsigned octet[4];
uint32_t address;
const char *p;
int base, i;
Modified: lib/network.c
===================================================================
--- lib/network.c 2018-01-04 15:06:39 UTC (rev 10212)
+++ lib/network.c 2018-01-04 15:09:43 UTC (rev 10213)
@@ -971,7 +971,7 @@
if (cidr > 32 || *end != '\0')
return false;
for (bits = 0, i = 0; i < cidr; i++)
- bits |= (1UL << (31 - i));
+ bits |= (1U << (31 - i));
addr_mask = htonl(bits);
} else if (inet_aton(mask, &tmp))
addr_mask = tmp.s_addr;
@@ -1000,7 +1000,7 @@
return false;
} else {
for (addr_mask = 0, bits = 0; bits < cidr % 8; bits++)
- addr_mask |= (1UL << (7 - bits));
+ addr_mask |= (1U << (7 - bits));
if ((a6.s6_addr[i] & addr_mask) != (b6.s6_addr[i] & addr_mask))
return false;
}
Modified: lib/snprintf.c
===================================================================
--- lib/snprintf.c 2018-01-04 15:06:39 UTC (rev 10212)
+++ lib/snprintf.c 2018-01-04 15:09:43 UTC (rev 10213)
@@ -781,7 +781,7 @@
/* Convert integer part */
do {
- iconvert[iplace++] = '0' + intpart % 10;
+ iconvert[iplace++] = (char) ('0' + (intpart % 10));
intpart = (intpart / 10);
} while(intpart && (iplace < sizeof(iconvert)));
if (iplace == sizeof(iconvert)) iplace--;
@@ -789,7 +789,7 @@
/* Convert fractional part */
do {
- fconvert[fplace++] = '0' + fracpart % 10;
+ fconvert[fplace++] = (char) ('0' + (fracpart % 10));
fracpart = (fracpart / 10);
} while(fracpart && (fplace < sizeof(fconvert)));
while (leadingfrac0s-- > 0 && fplace < sizeof(fconvert))
Modified: tests/lib/fakewrite.c
===================================================================
--- tests/lib/fakewrite.c 2018-01-04 15:06:39 UTC (rev 10212)
+++ tests/lib/fakewrite.c 2018-01-04 15:09:43 UTC (rev 10213)
@@ -117,8 +117,8 @@
ssize_t
fake_writev(int fd UNUSED, const struct iovec *iov, int iovcnt)
{
- int total, i;
- size_t left, n;
+ int i;
+ size_t left, n, total;
if (write_fail)
return 0;
Modified: tests/lib/xwrite-t.c
===================================================================
--- tests/lib/xwrite-t.c 2018-01-04 15:06:39 UTC (rev 10212)
+++ tests/lib/xwrite-t.c 2018-01-04 15:09:43 UTC (rev 10213)
@@ -70,10 +70,10 @@
test_write(xwrite(0, data, 256), 256, "xwrite interrupted");
write_offset = 0;
for (i = 0; i < 32; i++)
- data[i] = (char) i * 2;
+ data[i] = (char) (i * 2);
test_write(xwrite(0, data, 32), 32, "xwrite first block");
for (i = 32; i < 65; i++)
- data[i] = (char) i * 2;
+ data[i] = (char) (i * 2);
test_write(xwrite(0, data + 32, 33), 33, "xwrite second block");
write_offset = 0;
write_interrupt = 0;
@@ -100,11 +100,11 @@
iov[1].iov_len = 224;
test_write(xwritev(0, iov, 2), 256, "xwritev interrupted");
for (i = 0; i < 32; i++)
- data[i] = (char) i * 2;
+ data[i] = (char) (i * 2);
write_offset = 0;
test_write(xwritev(0, iov, 1), 32, "xwritev first block");
for (i = 32; i < 65; i++)
- data[i] = (char) i * 2;
+ data[i] = (char) (i * 2);
iov[0].iov_base = &data[32];
iov[0].iov_len = 16;
iov[1].iov_base = &data[48];
@@ -135,10 +135,10 @@
memset(data + 1, 0, 255);
test_write(xpwrite(0, data + 1, 255, 1), 255, "xpwrite interrupted");
for (i = 0; i < 32; i++)
- data[i + 32] = (char) i * 2;
+ data[i + 32] = (char) (i * 2);
test_write(xpwrite(0, data + 32, 32, 32), 32, "xpwrite first block");
for (i = 32; i < 65; i++)
- data[i + 32] = (char) i * 2;
+ data[i + 32] = (char) (i * 2);
test_write(xpwrite(0, data + 64, 33, 64), 33, "xpwrite second block");
write_interrupt = 0;
Modified: tests/runtests.c
===================================================================
--- tests/runtests.c 2018-01-04 15:06:39 UTC (rev 10212)
+++ tests/runtests.c 2018-01-04 15:09:43 UTC (rev 10213)
@@ -64,7 +64,7 @@
* Harness <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
*
* Copyright 2000, 2001, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013,
- * 2014, 2015, 2016 Russ Allbery <eagle at eyrie.org>
+ * 2014, 2015, 2016, 2017 Russ Allbery <eagle at eyrie.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -450,7 +450,7 @@
static double
tv_seconds(const struct timeval *tv)
{
- return difftime(tv->tv_sec, 0) + tv->tv_usec * 1e-6;
+ return difftime(tv->tv_sec, 0) + (double) tv->tv_usec * 1e-6;
}
@@ -1101,6 +1101,7 @@
struct testset *ts;
unsigned int chars;
unsigned long i, first, last, total;
+ double failed;
puts(header);
@@ -1109,8 +1110,9 @@
for (; fails; fails = fails->next) {
ts = fails->ts;
total = ts->count - ts->skipped;
+ failed = (double) ts->failed;
printf("%-26.26s %4lu/%-4lu %3.0f%% %4lu ", ts->file, ts->failed,
- total, total ? (ts->failed * 100.0) / total : 0,
+ total, total ? (failed * 100.0) / (double) total : 0,
ts->skipped);
if (WIFEXITED(ts->status))
printf("%4d ", WEXITSTATUS(ts->status));
@@ -1450,7 +1452,7 @@
fputs("All tests successful", stdout);
else
printf("Failed %lu/%lu tests, %.2f%% okay", failed, total,
- (total - failed) * 100.0 / total);
+ (double) (total - failed) * 100.0 / (double) total);
if (skipped != 0) {
if (skipped == 1)
printf(", %lu test skipped", skipped);
Modified: tests/tap/basic.c
===================================================================
--- tests/tap/basic.c 2018-01-04 15:06:39 UTC (rev 10212)
+++ tests/tap/basic.c 2018-01-04 15:09:43 UTC (rev 10213)
@@ -13,7 +13,7 @@
* This file is part of C TAP Harness. The current version plus supporting
* documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
*
- * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
+ * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
* Russ Allbery <eagle at eyrie.org>
* Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2013, 2014
* The Board of Trustees of the Leland Stanford Junior University
@@ -651,6 +651,41 @@
/*
+ * Takes pointers to an expected region of memory and a seen region of memory
+ * and assumes the test passes if the len bytes onwards from them match.
+ * Otherwise reports any bytes which didn't match.
+ */
+int
+is_blob(const void *wanted, const void *seen, size_t len, const char *format,
+ ...)
+{
+ int success;
+ size_t i;
+
+ fflush(stderr);
+ check_diag_files();
+ success = (memcmp(wanted, seen, len) == 0);
+ if (success)
+ printf("ok %lu", testnum++);
+ else {
+ const unsigned char *wanted_c = wanted;
+ const unsigned char *seen_c = seen;
+
+ for (i = 0; i < len; i++) {
+ if (wanted_c[i] != seen_c[i])
+ diag("offset %lu: wanted %02x, seen %02x", (unsigned long) i,
+ wanted_c[i], seen_c[i]);
+ }
+ printf("not ok %lu", testnum++);
+ _failed++;
+ }
+ PRINT_DESC(" - ", format);
+ putchar('\n');
+ return success;
+}
+
+
+/*
* Bail out with an error.
*/
void
@@ -849,6 +884,8 @@
{
if (n > 0 && UINT_MAX / n <= size)
bail("reallocarray too large");
+ if (n == 0)
+ n = 1;
p = realloc(p, n * size);
if (p == NULL)
sysbail("failed to realloc %lu bytes", (unsigned long) (n * size));
Modified: tests/tap/basic.h
===================================================================
--- tests/tap/basic.h 2018-01-04 15:06:39 UTC (rev 10212)
+++ tests/tap/basic.h 2018-01-04 15:09:43 UTC (rev 10213)
@@ -5,7 +5,7 @@
* This file is part of C TAP Harness. The current version plus supporting
* documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
*
- * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016
+ * Copyright 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
* Russ Allbery <eagle at eyrie.org>
* Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012, 2014
* The Board of Trustees of the Leland Stanford Junior University
@@ -128,6 +128,9 @@
__attribute__((__format__(printf, 3, 4)));
int is_hex(unsigned long wanted, unsigned long seen, const char *format, ...)
__attribute__((__format__(printf, 3, 4)));
+int is_blob(const void *wanted, const void *seen, size_t, const char *format,
+ ...)
+ __attribute__((__format__(printf, 4, 5)));
/* Bail out with an error. sysbail appends strerror(errno). */
void bail(const char *format, ...)
Modified: tests/tap/float.c
===================================================================
--- tests/tap/float.c 2018-01-04 15:06:39 UTC (rev 10212)
+++ tests/tap/float.c 2018-01-04 15:09:43 UTC (rev 10213)
@@ -11,7 +11,7 @@
* This file is part of C TAP Harness. The current version plus supporting
* documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
*
- * Copyright 2008, 2010, 2012, 2013, 2014, 2015, 2016
+ * Copyright 2008, 2010, 2012, 2013, 2014, 2015, 2016, 2017
* Russ Allbery <eagle at eyrie.org>
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -57,6 +57,15 @@
#endif
/*
+ * Clang 4.0.1 gets very confused by this file and produces warnings about
+ * floating point implicit conversion from the isnan() and isinf() macros.
+ */
+#if defined(__llvm__) || defined(__clang__)
+# pragma clang diagnostic ignored "-Wconversion"
+# pragma clang diagnostic ignored "-Wdouble-promotion"
+#endif
+
+/*
* Takes an expected double and a seen double and assumes the test passes if
* those two numbers are within delta of each other.
*/
More information about the inn-committers
mailing list