From 53161ad98c114d111f9e523c28df920aafb99798 Mon Sep 17 00:00:00 2001 From: Michael Tuexen <tuexen@fh-muenster.de> Date: Sun, 3 Jun 2018 20:14:02 +0200 Subject: [PATCH] Use own version of assert(). --- gtests/net/packetdrill/assert.h | 10 ++++++++++ gtests/net/packetdrill/checksum.c | 2 +- gtests/net/packetdrill/checksum_test.c | 2 +- gtests/net/packetdrill/code.c | 2 +- gtests/net/packetdrill/fmemopen.c | 2 +- gtests/net/packetdrill/header.h | 2 +- gtests/net/packetdrill/netdev.c | 2 +- gtests/net/packetdrill/open_memstream.c | 2 +- gtests/net/packetdrill/packet.c | 2 +- gtests/net/packetdrill/packet.h | 2 +- gtests/net/packetdrill/packet_parser.c | 2 +- gtests/net/packetdrill/packet_parser_test.c | 2 +- gtests/net/packetdrill/packet_socket_linux.c | 2 +- gtests/net/packetdrill/packet_socket_pcap.c | 2 +- gtests/net/packetdrill/packet_to_string_test.c | 2 +- gtests/net/packetdrill/packetdrill.c | 2 +- gtests/net/packetdrill/parse.h | 2 +- gtests/net/packetdrill/run_system_call.c | 2 +- gtests/net/packetdrill/script.c | 2 +- gtests/net/packetdrill/types.h | 2 +- 20 files changed, 29 insertions(+), 19 deletions(-) create mode 100644 gtests/net/packetdrill/assert.h diff --git a/gtests/net/packetdrill/assert.h b/gtests/net/packetdrill/assert.h new file mode 100644 index 00000000..9d038225 --- /dev/null +++ b/gtests/net/packetdrill/assert.h @@ -0,0 +1,10 @@ +#include <stdio.h> + +extern void __attribute__((noreturn)) die(char *format, ...); + +#define assert(expr) \ + do { \ + if (!(expr)) \ + die("assertion %s failed at %s line %d",\ + __STRING(expr), __FILE__, __LINE__);\ + } while (0) diff --git a/gtests/net/packetdrill/checksum.c b/gtests/net/packetdrill/checksum.c index f7ae72d9..60dd6412 100644 --- a/gtests/net/packetdrill/checksum.c +++ b/gtests/net/packetdrill/checksum.c @@ -24,8 +24,8 @@ #include "checksum.h" -#include <assert.h> #include <stdint.h> +#include "assert.h" /* Add bytes in buffer to a running checksum. Returns the new * intermediate checksum. Use ip_checksum_fold() to convert the diff --git a/gtests/net/packetdrill/checksum_test.c b/gtests/net/packetdrill/checksum_test.c index fb802dbc..34531efb 100644 --- a/gtests/net/packetdrill/checksum_test.c +++ b/gtests/net/packetdrill/checksum_test.c @@ -25,7 +25,7 @@ #include "checksum.h" #include <arpa/inet.h> -#include <assert.h> +#include "assert.h" #include "ip.h" #include "ipv6.h" #include "sctp.h" diff --git a/gtests/net/packetdrill/code.c b/gtests/net/packetdrill/code.c index 439695b8..69d86769 100644 --- a/gtests/net/packetdrill/code.c +++ b/gtests/net/packetdrill/code.c @@ -25,7 +25,6 @@ #include "code.h" -#include <assert.h> #include <errno.h> #include <signal.h> #include <stdio.h> @@ -36,6 +35,7 @@ #include <sys/types.h> #include <sys/wait.h> #include <unistd.h> +#include "assert.h" #include "run.h" #include "tcp.h" diff --git a/gtests/net/packetdrill/fmemopen.c b/gtests/net/packetdrill/fmemopen.c index 1d1989f8..5ed2be5e 100644 --- a/gtests/net/packetdrill/fmemopen.c +++ b/gtests/net/packetdrill/fmemopen.c @@ -25,10 +25,10 @@ #include "types.h" -#include <assert.h> #include <stdio.h> #include <stdlib.h> +#include "assert.h" #include "fmemopen.h" #if !defined(HAVE_FMEMOPEN) diff --git a/gtests/net/packetdrill/header.h b/gtests/net/packetdrill/header.h index e0a3e09a..b85deac3 100644 --- a/gtests/net/packetdrill/header.h +++ b/gtests/net/packetdrill/header.h @@ -31,8 +31,8 @@ #include "types.h" -#include <assert.h> #include <sys/time.h> +#include "assert.h" #include "gre.h" #include "icmp.h" #include "icmpv6.h" diff --git a/gtests/net/packetdrill/netdev.c b/gtests/net/packetdrill/netdev.c index 3a95ced4..ee092a8a 100644 --- a/gtests/net/packetdrill/netdev.c +++ b/gtests/net/packetdrill/netdev.c @@ -26,7 +26,6 @@ #include "netdev.h" #include <arpa/inet.h> -#include <assert.h> #include <errno.h> #include <fcntl.h> #include <net/if.h> @@ -52,6 +51,7 @@ #include <sys/kern_control.h> #include <sys/kern_event.h> #endif +#include "assert.h" #include "ip.h" #include "ipv6.h" #include "logging.h" diff --git a/gtests/net/packetdrill/open_memstream.c b/gtests/net/packetdrill/open_memstream.c index d3d6e796..9114091a 100644 --- a/gtests/net/packetdrill/open_memstream.c +++ b/gtests/net/packetdrill/open_memstream.c @@ -27,12 +27,12 @@ #ifndef HAVE_OPEN_MEMSTREAM +#include "assert.h" #include "open_memstream.h" #include <stdlib.h> #include <stdio.h> #include <string.h> #include <errno.h> -#include <assert.h> /* Our internal state for the memstream. */ struct mem_stream { diff --git a/gtests/net/packetdrill/packet.c b/gtests/net/packetdrill/packet.c index ebaebd5e..4fcc6b9c 100644 --- a/gtests/net/packetdrill/packet.c +++ b/gtests/net/packetdrill/packet.c @@ -25,9 +25,9 @@ #include "packet.h" -#include <assert.h> #include <stdlib.h> #include <string.h> +#include "assert.h" #include "ethernet.h" #include "gre_packet.h" #include "ip_packet.h" diff --git a/gtests/net/packetdrill/packet.h b/gtests/net/packetdrill/packet.h index eb1ab64c..6a13cd15 100644 --- a/gtests/net/packetdrill/packet.h +++ b/gtests/net/packetdrill/packet.h @@ -28,8 +28,8 @@ #include "types.h" -#include <assert.h> #include <sys/time.h> +#include "assert.h" #include "gre.h" #include "header.h" #include "icmp.h" diff --git a/gtests/net/packetdrill/packet_parser.c b/gtests/net/packetdrill/packet_parser.c index f5ac7a5a..1f836e5a 100644 --- a/gtests/net/packetdrill/packet_parser.c +++ b/gtests/net/packetdrill/packet_parser.c @@ -25,7 +25,6 @@ #include "packet_parser.h" #include <arpa/inet.h> -#include <assert.h> #include <errno.h> #include <netinet/in.h> #include <stdio.h> @@ -35,6 +34,7 @@ #include <sys/types.h> #include <unistd.h> +#include "assert.h" #include "checksum.h" #include "ethernet.h" #include "gre.h" diff --git a/gtests/net/packetdrill/packet_parser_test.c b/gtests/net/packetdrill/packet_parser_test.c index 46c8fca4..c65b5f3f 100644 --- a/gtests/net/packetdrill/packet_parser_test.c +++ b/gtests/net/packetdrill/packet_parser_test.c @@ -22,10 +22,10 @@ * Test for parsing IP packets. */ +#include "assert.h" #include "ethernet.h" #include "packet_parser.h" -#include <assert.h> #include <stdlib.h> #include <string.h> diff --git a/gtests/net/packetdrill/packet_socket_linux.c b/gtests/net/packetdrill/packet_socket_linux.c index bab7f345..a31873a2 100644 --- a/gtests/net/packetdrill/packet_socket_linux.c +++ b/gtests/net/packetdrill/packet_socket_linux.c @@ -24,7 +24,6 @@ #include "packet_socket.h" -#include <assert.h> #include <errno.h> #include <net/if.h> #include <stdlib.h> @@ -38,6 +37,7 @@ #include <netpacket/packet.h> #include <linux/filter.h> +#include "assert.h" #include "ethernet.h" #include "logging.h" diff --git a/gtests/net/packetdrill/packet_socket_pcap.c b/gtests/net/packetdrill/packet_socket_pcap.c index e9ca8622..cdbba1fc 100644 --- a/gtests/net/packetdrill/packet_socket_pcap.c +++ b/gtests/net/packetdrill/packet_socket_pcap.c @@ -24,7 +24,6 @@ #include "packet_socket.h" -#include <assert.h> #include <errno.h> #include <net/if.h> #include <stdlib.h> @@ -41,6 +40,7 @@ #include <pcap.h> #endif +#include "assert.h" #include "ethernet.h" #include "logging.h" diff --git a/gtests/net/packetdrill/packet_to_string_test.c b/gtests/net/packetdrill/packet_to_string_test.c index c40aa0ce..72605909 100644 --- a/gtests/net/packetdrill/packet_to_string_test.c +++ b/gtests/net/packetdrill/packet_to_string_test.c @@ -24,9 +24,9 @@ #include "packet_to_string.h" -#include <assert.h> #include <stdlib.h> #include <string.h> +#include "assert.h" #include "ethernet.h" #include "packet_parser.h" #include "logging.h" diff --git a/gtests/net/packetdrill/packetdrill.c b/gtests/net/packetdrill/packetdrill.c index 574bf0b4..6450e4b7 100644 --- a/gtests/net/packetdrill/packetdrill.c +++ b/gtests/net/packetdrill/packetdrill.c @@ -25,7 +25,6 @@ #include "types.h" #include <arpa/inet.h> -#include <assert.h> #include <getopt.h> #include <pthread.h> #if defined(__FreeBSD__) @@ -34,6 +33,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include "assert.h" #include "config.h" #include "parse.h" #include "run.h" diff --git a/gtests/net/packetdrill/parse.h b/gtests/net/packetdrill/parse.h index 989ebced..3ac8eae5 100644 --- a/gtests/net/packetdrill/parse.h +++ b/gtests/net/packetdrill/parse.h @@ -27,7 +27,7 @@ #include "types.h" -#include <assert.h> +#include "assert.h" #include "config.h" #include "script.h" diff --git a/gtests/net/packetdrill/run_system_call.c b/gtests/net/packetdrill/run_system_call.c index f2ed8d2b..a68be5ae 100644 --- a/gtests/net/packetdrill/run_system_call.c +++ b/gtests/net/packetdrill/run_system_call.c @@ -25,7 +25,6 @@ #include "run_system_call.h" #include <arpa/inet.h> -#include <assert.h> #include <errno.h> #include <fcntl.h> #include <limits.h> @@ -63,6 +62,7 @@ #endif #include <time.h> #include <unistd.h> +#include "assert.h" #include "logging.h" #include "run.h" #include "script.h" diff --git a/gtests/net/packetdrill/script.c b/gtests/net/packetdrill/script.c index 3bfc4993..cc82e4b3 100644 --- a/gtests/net/packetdrill/script.c +++ b/gtests/net/packetdrill/script.c @@ -24,11 +24,11 @@ #include "script.h" -#include <assert.h> #include <fcntl.h> #include <poll.h> #include <stdlib.h> +#include "assert.h" #include "symbols.h" /* Fill in a value representing the given expression in diff --git a/gtests/net/packetdrill/types.h b/gtests/net/packetdrill/types.h index 8a9808e9..de0ce195 100644 --- a/gtests/net/packetdrill/types.h +++ b/gtests/net/packetdrill/types.h @@ -31,7 +31,6 @@ * convention of including types.h first, before everything else. */ #define _GNU_SOURCE /* for asprintf */ -#include <assert.h> #include <limits.h> #include <stdio.h> #include <string.h> @@ -43,6 +42,7 @@ #include <sys/socket.h> #include <sys/time.h> +#include "assert.h" #include "platforms.h" /* We use some unconventional formatting here to avoid checkpatch.pl -- GitLab