From edafba9fe6168a63087aa39027b099345aa37772 Mon Sep 17 00:00:00 2001 From: wb2osz Date: Fri, 8 Nov 2019 21:00:12 -0500 Subject: [PATCH] Mitigate impact of cmake defining NDEBUG. --- ax25_pad.c | 3 ++- direwolf.h | 5 +++++ xid.c | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ax25_pad.c b/ax25_pad.c index b8bdbea..d8af765 100644 --- a/ax25_pad.c +++ b/ax25_pad.c @@ -418,7 +418,8 @@ packet_t ax25_from_text (char *monitor, int strict) this_p->frame_len = 7 + 7 + 1 + 1; this_p->num_addr = (-1); - assert (ax25_get_num_addr(this_p) == 2); + (void) ax25_get_num_addr(this_p); // when num_addr is -1, this sets it properly. + assert (this_p->num_addr == 2); /* diff --git a/direwolf.h b/direwolf.h index 9e32532..6df28ad 100644 --- a/direwolf.h +++ b/direwolf.h @@ -4,6 +4,11 @@ // TODO: include this file first before anything else in each .c file. +#ifdef NDEBUG +#undef NDEBUG // Because it would disable assert(). +#endif + + #ifndef DIREWOLF_H #define DIREWOLF_H 1 diff --git a/xid.c b/xid.c index a96b89a..617720c 100644 --- a/xid.c +++ b/xid.c @@ -665,6 +665,9 @@ int main (int argc, char *argv[]) { text_color_set (DW_COLOR_ERROR); +#ifdef NDEBUG +#error "This won't work properly if NDEBUG is defined. It should be undefined in direwolf.h" +#endif assert (n==1); assert (param.full_duplex == 0); assert (param.srej == srej_single);