diff --git a/Makefile.am b/Makefile.am index e4149b62ed..a5101df2f0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -11,11 +11,19 @@ AM_CFLAGS = \ $(SAN_FLAGS) \ $(WERROR) \ # end -AM_CPPFLAGS = \ + +# CPPFLAGS_BASE does not contain the include path for overriding assert.h, +# therefore should be used in tools that do *not* link libfrr or do not want +# assert() overridden +CPPFLAGS_BASE = \ -I$(top_srcdir) -I$(top_srcdir)/include -I$(top_srcdir)/lib \ -I$(top_builddir) \ $(LUA_INCLUDE) \ # end +AM_CPPFLAGS = \ + -I$(top_srcdir)/lib/assert \ + $(CPPFLAGS_BASE) \ + # end AM_LDFLAGS = \ -export-dynamic \ $(AC_LDFLAGS) \ diff --git a/bgpd/bgp_conditional_adv.c b/bgpd/bgp_conditional_adv.c index b9ea26e862..6e80765f86 100644 --- a/bgpd/bgp_conditional_adv.c +++ b/bgpd/bgp_conditional_adv.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "bgpd/bgp_conditional_adv.h" #include "bgpd/bgp_vty.h" diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c index 99d0344c9f..e9b0f9e46a 100644 --- a/bgpd/bgp_io.c +++ b/bgpd/bgp_io.c @@ -32,7 +32,6 @@ #include "stream.h" // for stream_get_endp, stream_getw_from, str... #include "ringbuf.h" // for ringbuf_remain, ringbuf_peek, ringbuf_... #include "thread.h" // for THREAD_OFF, THREAD_ARG, thread... -#include "zassert.h" // for assert #include "bgpd/bgp_io.h" #include "bgpd/bgp_debug.h" // for bgp_debug_neighbor_events, bgp_type_str diff --git a/bgpd/bgp_nb.c b/bgpd/bgp_nb.c index 2547439499..21810b634d 100644 --- a/bgpd/bgp_nb.c +++ b/bgpd/bgp_nb.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "northbound.h" #include "libfrr.h" #include "bgpd/bgp_nb.h" diff --git a/bgpd/bgp_nb_config.c b/bgpd/bgp_nb_config.c index 307fa4e9bc..ff2c8ce93e 100644 --- a/bgpd/bgp_nb_config.c +++ b/bgpd/bgp_nb_config.c @@ -18,6 +18,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "northbound.h" #include "libfrr.h" #include "log.h" diff --git a/bgpd/bgp_routemap_nb.c b/bgpd/bgp_routemap_nb.c index fc59122184..b165c5d0ee 100644 --- a/bgpd/bgp_routemap_nb.c +++ b/bgpd/bgp_routemap_nb.c @@ -18,6 +18,8 @@ */ +#include + #include "lib/command.h" #include "lib/log.h" #include "lib/northbound.h" diff --git a/bgpd/bgp_routemap_nb_config.c b/bgpd/bgp_routemap_nb_config.c index ec6284273e..ff08c16a82 100644 --- a/bgpd/bgp_routemap_nb_config.c +++ b/bgpd/bgp_routemap_nb_config.c @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "lib/command.h" #include "lib/log.h" #include "lib/northbound.h" diff --git a/bgpd/bgp_trace.c b/bgpd/bgp_trace.c index 2ebc63b6b5..02afbeb46f 100644 --- a/bgpd/bgp_trace.c +++ b/bgpd/bgp_trace.c @@ -1,4 +1,6 @@ #define TRACEPOINT_CREATE_PROBES #define TRACEPOINT_DEFINE +#include + #include "bgp_trace.h" diff --git a/eigrpd/eigrp_metric.c b/eigrpd/eigrp_metric.c index 2b05db71d5..ea62f9d1be 100644 --- a/eigrpd/eigrp_metric.c +++ b/eigrpd/eigrp_metric.c @@ -21,6 +21,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "eigrpd/eigrp_structs.h" #include "eigrpd/eigrpd.h" #include "eigrpd/eigrp_types.h" diff --git a/lib/assert/assert.h b/lib/assert/assert.h new file mode 100644 index 0000000000..fbdbd52ce8 --- /dev/null +++ b/lib/assert/assert.h @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2021 David Lamparter, for NetDEF, Inc. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* WARNING: this file is "special" in that it overrides the system-provided + * assert.h by being on the include path before it. That means it should + * provide the functional equivalent. + * + * This is intentional because FRR extends assert() to write to the log and + * add backtraces. Overriding the entire file is the simplest and most + * reliable way to get this to work; there were problems previously with the + * system assert.h getting included afterwards and redefining assert() back to + * the system variant. + */ + +#ifndef _FRR_ASSERT_H +#define _FRR_ASSERT_H + +#include "xref.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __cplusplus +/* C++ has this built-in, but C provides it in assert.h for >=C11. Since we + * replace assert.h entirely, we need to provide it here too. + */ +#define static_assert _Static_assert +#endif + +struct xref_assert { + struct xref xref; + + const char *expr; + const char *extra, *args; +}; + +extern void _zlog_assert_failed(const struct xref_assert *xref, + const char *extra, ...) PRINTFRR(2, 3) + __attribute__((noreturn)); + +/* the "do { } while (expr_)" is there to get a warning for assignments inside + * the assert expression aka "assert(x = 1)". The (necessary) braces around + * expr_ in the if () statement would suppress these warnings. Since + * _zlog_assert_failed() is noreturn, the while condition will never be + * checked. + */ +#define assert(expr_) \ + ({ \ + static const struct xref_assert _xref __attribute__( \ + (used)) = { \ + .xref = XREF_INIT(XREFT_ASSERT, NULL, __func__), \ + .expr = #expr_, \ + }; \ + XREF_LINK(_xref.xref); \ + if (__builtin_expect((expr_) ? 0 : 1, 0)) \ + do { \ + _zlog_assert_failed(&_xref, NULL); \ + } while (expr_); \ + }) + +#define assertf(expr_, extra_, ...) \ + ({ \ + static const struct xref_assert _xref __attribute__( \ + (used)) = { \ + .xref = XREF_INIT(XREFT_ASSERT, NULL, __func__), \ + .expr = #expr_, \ + .extra = extra_, \ + .args = #__VA_ARGS__, \ + }; \ + XREF_LINK(_xref.xref); \ + if (__builtin_expect((expr_) ? 0 : 1, 0)) \ + do { \ + _zlog_assert_failed(&_xref, extra_, \ + ##__VA_ARGS__); \ + } while (expr_); \ + }) + +#define zassert assert + +#ifdef __cplusplus +} +#endif + +#endif /* _FRR_ASSERT_H */ diff --git a/lib/clippy.c b/lib/clippy.c index 6223697ae9..7ca99c9a94 100644 --- a/lib/clippy.c +++ b/lib/clippy.c @@ -106,12 +106,7 @@ int main(int argc, char **argv) /* and now for the ugly part... provide simplified logging functions so we * don't need to link libzebra (which would be a circular build dep) */ -#ifdef __ASSERT_FUNCTION -#undef __ASSERT_FUNCTION -#endif - #include "log.h" -#include "zassert.h" void vzlogx(const struct xref_logmsg *xref, int prio, const char *format, va_list args) @@ -120,15 +115,6 @@ void vzlogx(const struct xref_logmsg *xref, int prio, fputs("\n", stderr); } -void _zlog_assert_failed(const char *assertion, const char *file, - unsigned int line, const char *function) -{ - fprintf(stderr, - "Assertion `%s' failed in file %s, line %u, function %s", - assertion, file, line, (function ? function : "?")); - abort(); -} - void memory_oom(size_t size, const char *name) { abort(); diff --git a/lib/compiler.h b/lib/compiler.h index b7a142bdee..86cf347e01 100644 --- a/lib/compiler.h +++ b/lib/compiler.h @@ -373,6 +373,10 @@ CPP_NOTICE("time to remove this CONFDATE block") #else /* !_FRR_ATTRIBUTE_PRINTFRR */ #define PRINTFRR(a, b) __attribute__((format(printf, a, b))) +/* frr-format plugin is C-only for now, so no point in doing these shenanigans + * for C++... (also they can break some C++ stuff...) + */ +#ifndef __cplusplus /* these should be typedefs, but might also be #define */ #ifdef uint64_t #undef uint64_t @@ -400,6 +404,8 @@ _Static_assert(sizeof(_uint64_t) == 8 && sizeof(_int64_t) == 8, #define PRIu64 "llu" #define PRId64 "lld" #define PRIx64 "llx" + +#endif /* !__cplusplus */ #endif /* !_FRR_ATTRIBUTE_PRINTFRR */ #ifdef __cplusplus diff --git a/lib/libfrr_trace.c b/lib/libfrr_trace.c index 2f300e6ee1..59320322ca 100644 --- a/lib/libfrr_trace.c +++ b/lib/libfrr_trace.c @@ -1,4 +1,6 @@ #define TRACEPOINT_CREATE_PROBES #define TRACEPOINT_DEFINE +#include + #include "libfrr_trace.h" diff --git a/lib/link_state.c b/lib/link_state.c index 8606f8eb09..afeb89c592 100644 --- a/lib/link_state.c +++ b/lib/link_state.c @@ -22,6 +22,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "if.h" #include "linklist.h" #include "log.h" diff --git a/lib/log.c b/lib/log.c index ca2f501686..15fdfd4b0a 100644 --- a/lib/log.c +++ b/lib/log.c @@ -311,17 +311,6 @@ void zlog_thread_info(int log_level) zlog(log_level, "Current thread not known/applicable"); } -void _zlog_assert_failed(const char *assertion, const char *file, - unsigned int line, const char *function) -{ - zlog(LOG_CRIT, "Assertion `%s' failed in file %s, line %u, function %s", - assertion, file, line, (function ? function : "?")); - zlog_backtrace(LOG_CRIT); - zlog_thread_info(LOG_CRIT); - log_memstats(stderr, "log"); - abort(); -} - void memory_oom(size_t size, const char *name) { zlog(LOG_CRIT, diff --git a/lib/log.h b/lib/log.h index 7147253644..59f1742d01 100644 --- a/lib/log.h +++ b/lib/log.h @@ -22,8 +22,6 @@ #ifndef _ZEBRA_LOG_H #define _ZEBRA_LOG_H -#include "zassert.h" - #include #include #include diff --git a/lib/routing_nb.c b/lib/routing_nb.c index 0160354a7e..6238fb055d 100644 --- a/lib/routing_nb.c +++ b/lib/routing_nb.c @@ -16,6 +16,8 @@ * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "northbound.h" #include "libfrr.h" #include "routing_nb.h" diff --git a/lib/routing_nb_config.c b/lib/routing_nb_config.c index f66f32015d..594ad6c9e8 100644 --- a/lib/routing_nb_config.c +++ b/lib/routing_nb_config.c @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "northbound.h" #include "libfrr.h" #include "vrf.h" diff --git a/lib/subdir.am b/lib/subdir.am index 98ba1cf24c..480c2938d0 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -278,13 +278,14 @@ pkginclude_HEADERS += \ lib/yang.h \ lib/yang_translator.h \ lib/yang_wrappers.h \ - lib/zassert.h \ lib/zclient.h \ lib/zebra.h \ lib/zlog.h \ lib/zlog_targets.h \ lib/pbr.h \ lib/routing_nb.h \ + \ + lib/assert/assert.h \ # end @@ -413,7 +414,7 @@ lib_grammar_sandbox_SOURCES = \ lib_grammar_sandbox_LDADD = \ lib/libfrr.la -lib_clippy_CPPFLAGS = $(AM_CPPFLAGS) -D_GNU_SOURCE -DBUILDING_CLIPPY +lib_clippy_CPPFLAGS = $(CPPFLAGS_BASE) -D_GNU_SOURCE -DBUILDING_CLIPPY lib_clippy_CFLAGS = $(AC_CFLAGS) $(PYTHON_CFLAGS) lib_clippy_LDADD = $(PYTHON_LIBS) $(UST_LIBS) -lelf lib_clippy_LDFLAGS = -export-dynamic diff --git a/lib/thread.c b/lib/thread.c index 7b5d2f3113..3af89fad5a 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -664,7 +664,7 @@ static int time_hhmmss(char *buf, int buf_size, long sec) long mm; int wr; - zassert(buf_size >= 8); + assert(buf_size >= 8); hh = sec / 3600; sec %= 3600; diff --git a/lib/xref.h b/lib/xref.h index 63166b069a..949458b313 100644 --- a/lib/xref.h +++ b/lib/xref.h @@ -33,6 +33,7 @@ enum xref_type { XREFT_THREADSCHED = 0x100, XREFT_LOGMSG = 0x200, + XREFT_ASSERT = 0x280, XREFT_DEFUN = 0x300, XREFT_INSTALL_ELEMENT = 0x301, diff --git a/lib/zassert.h b/lib/zassert.h deleted file mode 100644 index 527282c4f2..0000000000 --- a/lib/zassert.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * This file is part of Quagga. - * - * Quagga is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the - * Free Software Foundation; either version 2, or (at your option) any - * later version. - * - * Quagga is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; see the file COPYING; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef _QUAGGA_ASSERT_H -#define _QUAGGA_ASSERT_H - -#ifdef __cplusplus -extern "C" { -#endif - -extern void _zlog_assert_failed(const char *assertion, const char *file, - unsigned int line, const char *function) - __attribute__((noreturn)); - -#undef __ASSERT_FUNCTION -#define __ASSERT_FUNCTION __func__ - -#define zassert(EX) \ - ((void)((EX) ? 0 : (_zlog_assert_failed(#EX, __FILE__, __LINE__, \ - __ASSERT_FUNCTION), \ - 0))) - -#undef assert -#define assert(EX) zassert(EX) - -#ifdef __cplusplus -} -#endif - -#endif /* _QUAGGA_ASSERT_H */ diff --git a/lib/zebra.h b/lib/zebra.h index 26c0fe05b5..3b624117de 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -206,7 +206,7 @@ #define __attribute__(x) #endif /* !__GNUC__ || VTYSH_EXTRACT_PL */ -#include "zassert.h" +#include /* * Add explicit static cast only when using a C++ compiler. diff --git a/lib/zlog.c b/lib/zlog.c index a99fd71f0d..89ab9265d1 100644 --- a/lib/zlog.c +++ b/lib/zlog.c @@ -526,6 +526,36 @@ void zlog_sigsafe(const char *text, size_t len) } } +void _zlog_assert_failed(const struct xref_assert *xref, const char *extra, ...) +{ + va_list ap; + static bool assert_in_assert; /* "global-ish" variable, init to 0 */ + + if (assert_in_assert) + abort(); + assert_in_assert = true; + + if (extra) { + struct va_format vaf; + + va_start(ap, extra); + vaf.fmt = extra; + vaf.va = ≈ + + zlog(LOG_CRIT, + "%s:%d: %s(): assertion (%s) failed, extra info: %pVA", + xref->xref.file, xref->xref.line, xref->xref.func, + xref->expr, &vaf); + + va_end(ap); + } else + zlog(LOG_CRIT, "%s:%d: %s(): assertion (%s) failed", + xref->xref.file, xref->xref.line, xref->xref.func, + xref->expr); + + /* abort() prints backtrace & memstats in SIGABRT handler */ + abort(); +} int zlog_msg_prio(struct zlog_msg *msg) { diff --git a/lib/zlog.h b/lib/zlog.h index 2ef4173605..c421c16f38 100644 --- a/lib/zlog.h +++ b/lib/zlog.h @@ -25,6 +25,8 @@ #include #include +#include + #include "atomlist.h" #include "frrcu.h" #include "memory.h" diff --git a/nhrpd/nhrp_cache.c b/nhrpd/nhrp_cache.c index bcf0e2168c..c358baecb2 100644 --- a/nhrpd/nhrp_cache.c +++ b/nhrpd/nhrp_cache.c @@ -72,7 +72,7 @@ static void nhrp_cache_free(struct nhrp_cache *c) debugf(NHRP_DEBUG_COMMON, "Deleting cache entry"); nhrp_cache_counts[c->cur.type]--; notifier_call(&c->notifier_list, NOTIFY_CACHE_DELETE); - zassert(!notifier_active(&c->notifier_list)); + assert(!notifier_active(&c->notifier_list)); hash_release(nifp->cache_hash, c); THREAD_OFF(c->t_timeout); THREAD_OFF(c->t_auth); diff --git a/nhrpd/zbuf.c b/nhrpd/zbuf.c index 43ce974817..e191a90f2d 100644 --- a/nhrpd/zbuf.c +++ b/nhrpd/zbuf.c @@ -14,7 +14,7 @@ #include #include #include -#include "zassert.h" +#include #include "zbuf.h" #include "memory.h" #include "nhrpd.h" @@ -59,7 +59,7 @@ void zbuf_reset(struct zbuf *zb) void zbuf_reset_head(struct zbuf *zb, void *ptr) { - zassert((void *)zb->buf <= ptr && ptr <= (void *)zb->tail); + assert((void *)zb->buf <= ptr && ptr <= (void *)zb->tail); zb->head = ptr; } diff --git a/nhrpd/zbuf.h b/nhrpd/zbuf.h index d4a7c15a95..2741860bfd 100644 --- a/nhrpd/zbuf.h +++ b/nhrpd/zbuf.h @@ -15,7 +15,6 @@ #include #include -#include "zassert.h" #include "list.h" struct zbuf { diff --git a/ospf6d/ospf6_routemap_nb.c b/ospf6d/ospf6_routemap_nb.c index b710fefbdf..faa992e026 100644 --- a/ospf6d/ospf6_routemap_nb.c +++ b/ospf6d/ospf6_routemap_nb.c @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "lib/northbound.h" #include "lib/routemap.h" #include "ospf6_routemap_nb.h" diff --git a/ospf6d/ospf6_routemap_nb_config.c b/ospf6d/ospf6_routemap_nb_config.c index 3c7741e473..cd0a3260d5 100644 --- a/ospf6d/ospf6_routemap_nb_config.c +++ b/ospf6d/ospf6_routemap_nb_config.c @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "lib/command.h" #include "lib/log.h" #include "lib/northbound.h" diff --git a/ospfd/ospf_routemap_nb.c b/ospfd/ospf_routemap_nb.c index 1f6b0ef78c..e53d009a55 100644 --- a/ospfd/ospf_routemap_nb.c +++ b/ospfd/ospf_routemap_nb.c @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "lib/northbound.h" #include "lib/routemap.h" #include "ospf_routemap_nb.h" diff --git a/ospfd/ospf_routemap_nb_config.c b/ospfd/ospf_routemap_nb_config.c index bfb18c5e08..9026795425 100644 --- a/ospfd/ospf_routemap_nb_config.c +++ b/ospfd/ospf_routemap_nb_config.c @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "lib/command.h" #include "lib/log.h" #include "lib/northbound.h" diff --git a/pathd/path_cli.c b/pathd/path_cli.c index cf14aa8c61..ecb667f985 100644 --- a/pathd/path_cli.c +++ b/pathd/path_cli.c @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include #include #include diff --git a/pathd/path_debug.c b/pathd/path_debug.c index df0550715a..eec5707396 100644 --- a/pathd/path_debug.c +++ b/pathd/path_debug.c @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include #include #include diff --git a/pathd/path_pcep_config.c b/pathd/path_pcep_config.c index 107475bec9..aacbca4ae9 100644 --- a/pathd/path_pcep_config.c +++ b/pathd/path_pcep_config.c @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include #include #include diff --git a/pathd/path_pcep_debug.c b/pathd/path_pcep_debug.c index d222371bbb..370484dc1b 100644 --- a/pathd/path_pcep_debug.c +++ b/pathd/path_pcep_debug.c @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include #include #include diff --git a/pathd/path_zebra.c b/pathd/path_zebra.c index 276bc9289c..8c9357460f 100644 --- a/pathd/path_zebra.c +++ b/pathd/path_zebra.c @@ -16,6 +16,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "thread.h" #include "log.h" #include "lib_errors.h" diff --git a/pbrd/pbr_zebra.c b/pbrd/pbr_zebra.c index 4b73e13c27..eb41bf6043 100644 --- a/pbrd/pbr_zebra.c +++ b/pbrd/pbr_zebra.c @@ -50,8 +50,8 @@ struct pbr_interface *pbr_if_new(struct interface *ifp) { struct pbr_interface *pbr_ifp; - zassert(ifp); - zassert(!ifp->info); + assert(ifp); + assert(!ifp->info); pbr_ifp = XCALLOC(MTYPE_PBR_INTERFACE, sizeof(*pbr_ifp)); diff --git a/pceplib/pcep_msg_messages.c b/pceplib/pcep_msg_messages.c index ec2a237f30..9bbfc5372b 100644 --- a/pceplib/pcep_msg_messages.c +++ b/pceplib/pcep_msg_messages.c @@ -25,6 +25,10 @@ * This is the implementation of a High Level PCEP message API. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/pcep_msg_messages_encoding.c b/pceplib/pcep_msg_messages_encoding.c index 7c8e1b3a1f..e90ca1cfd8 100644 --- a/pceplib/pcep_msg_messages_encoding.c +++ b/pceplib/pcep_msg_messages_encoding.c @@ -25,6 +25,10 @@ * Encoding and decoding for PCEP messages. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/pcep_msg_object_error_types.c b/pceplib/pcep_msg_object_error_types.c index a4fd8151cd..c72dfd7061 100644 --- a/pceplib/pcep_msg_object_error_types.c +++ b/pceplib/pcep_msg_object_error_types.c @@ -19,6 +19,10 @@ * Author : Brady Johnson */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "pcep_msg_object_error_types.h" diff --git a/pceplib/pcep_msg_objects.c b/pceplib/pcep_msg_objects.c index 6c943ddc2a..e253fcc540 100644 --- a/pceplib/pcep_msg_objects.c +++ b/pceplib/pcep_msg_objects.c @@ -25,6 +25,10 @@ * This is the implementation of a High Level PCEP message object API. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/pcep_msg_objects_encoding.c b/pceplib/pcep_msg_objects_encoding.c index c4089ba5ec..9ab96f7bce 100644 --- a/pceplib/pcep_msg_objects_encoding.c +++ b/pceplib/pcep_msg_objects_encoding.c @@ -25,6 +25,10 @@ * Encoding and decoding for PCEP Objects. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/pcep_msg_tlvs.c b/pceplib/pcep_msg_tlvs.c index 9c84e71ee1..6298ed4b8d 100644 --- a/pceplib/pcep_msg_tlvs.c +++ b/pceplib/pcep_msg_tlvs.c @@ -25,6 +25,10 @@ * This is the implementation of a High Level PCEP message object TLV API. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/pcep_msg_tools.c b/pceplib/pcep_msg_tools.c index e190d2a850..8f32f2c537 100644 --- a/pceplib/pcep_msg_tools.c +++ b/pceplib/pcep_msg_tools.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/pcep_session_logic.c b/pceplib/pcep_session_logic.c index 52655914c6..2ec2fd72a8 100644 --- a/pceplib/pcep_session_logic.c +++ b/pceplib/pcep_session_logic.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/pcep_session_logic_counters.c b/pceplib/pcep_session_logic_counters.c index a6bd41b4f1..fceb15af76 100644 --- a/pceplib/pcep_session_logic_counters.c +++ b/pceplib/pcep_session_logic_counters.c @@ -25,6 +25,10 @@ * PCEP session logic counters configuration. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/pcep_session_logic_loop.c b/pceplib/pcep_session_logic_loop.c index 269aa1e07e..4b855c06cd 100644 --- a/pceplib/pcep_session_logic_loop.c +++ b/pceplib/pcep_session_logic_loop.c @@ -20,6 +20,10 @@ * */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/pcep_session_logic_states.c b/pceplib/pcep_session_logic_states.c index 3beceefad0..3e9c701a62 100644 --- a/pceplib/pcep_session_logic_states.c +++ b/pceplib/pcep_session_logic_states.c @@ -20,6 +20,10 @@ * */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/pcep_socket_comm_loop.c b/pceplib/pcep_socket_comm_loop.c index d58409c4f3..d9a6b9ae48 100644 --- a/pceplib/pcep_socket_comm_loop.c +++ b/pceplib/pcep_socket_comm_loop.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/pcep_socket_comm_mock.c b/pceplib/pcep_socket_comm_mock.c index 069d0cf998..7a9511e315 100644 --- a/pceplib/pcep_socket_comm_mock.c +++ b/pceplib/pcep_socket_comm_mock.c @@ -27,6 +27,10 @@ * created. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/pcep_timers.c b/pceplib/pcep_timers.c index d0a2349d05..4c06d2b3f7 100644 --- a/pceplib/pcep_timers.c +++ b/pceplib/pcep_timers.c @@ -25,6 +25,10 @@ * Implementation of public API timer functions. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/pcep_timers_event_loop.c b/pceplib/pcep_timers_event_loop.c index 932a53eb2a..8984496717 100644 --- a/pceplib/pcep_timers_event_loop.c +++ b/pceplib/pcep_timers_event_loop.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/pcep_utils_double_linked_list.c b/pceplib/pcep_utils_double_linked_list.c index acdcee0598..696e46632a 100644 --- a/pceplib/pcep_utils_double_linked_list.c +++ b/pceplib/pcep_utils_double_linked_list.c @@ -20,6 +20,10 @@ * */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/pcep_utils_logging.c b/pceplib/pcep_utils_logging.c index 65e1abbc03..0286c23078 100644 --- a/pceplib/pcep_utils_logging.c +++ b/pceplib/pcep_utils_logging.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include "pcep_utils_logging.h" diff --git a/pceplib/pcep_utils_memory.c b/pceplib/pcep_utils_memory.c index 7362e3433b..c564705f66 100644 --- a/pceplib/pcep_utils_memory.c +++ b/pceplib/pcep_utils_memory.c @@ -20,6 +20,10 @@ * */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/pcep_utils_ordered_list.c b/pceplib/pcep_utils_ordered_list.c index f5c7f70240..81eb614494 100644 --- a/pceplib/pcep_utils_ordered_list.c +++ b/pceplib/pcep_utils_ordered_list.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/pcep_utils_queue.c b/pceplib/pcep_utils_queue.c index e8c3f2be0e..627533d01b 100644 --- a/pceplib/pcep_utils_queue.c +++ b/pceplib/pcep_utils_queue.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/test/pcep_msg_messages_test.c b/pceplib/test/pcep_msg_messages_test.c index b8984a42bc..61fa94047b 100644 --- a/pceplib/test/pcep_msg_messages_test.c +++ b/pceplib/test/pcep_msg_messages_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/test/pcep_msg_messages_tests.c b/pceplib/test/pcep_msg_messages_tests.c index bd85a16530..f24a797f77 100644 --- a/pceplib/test/pcep_msg_messages_tests.c +++ b/pceplib/test/pcep_msg_messages_tests.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/test/pcep_msg_object_error_types_test.c b/pceplib/test/pcep_msg_object_error_types_test.c index 7275eaf098..b1463751d6 100644 --- a/pceplib/test/pcep_msg_object_error_types_test.c +++ b/pceplib/test/pcep_msg_object_error_types_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/test/pcep_msg_objects_test.c b/pceplib/test/pcep_msg_objects_test.c index a4c069945c..e0814de543 100644 --- a/pceplib/test/pcep_msg_objects_test.c +++ b/pceplib/test/pcep_msg_objects_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/test/pcep_msg_tools_test.c b/pceplib/test/pcep_msg_tools_test.c index ff5fc62390..787df2fd7a 100644 --- a/pceplib/test/pcep_msg_tools_test.c +++ b/pceplib/test/pcep_msg_tools_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/test/pcep_pcc_api_test.c b/pceplib/test/pcep_pcc_api_test.c index c227dc1a3d..4adbb6374e 100644 --- a/pceplib/test/pcep_pcc_api_test.c +++ b/pceplib/test/pcep_pcc_api_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include // gethostbyname #include #include diff --git a/pceplib/test/pcep_pcc_api_tests.c b/pceplib/test/pcep_pcc_api_tests.c index 04895d6340..5d9e92c1d3 100644 --- a/pceplib/test/pcep_pcc_api_tests.c +++ b/pceplib/test/pcep_pcc_api_tests.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/test/pcep_session_logic_loop_test.c b/pceplib/test/pcep_session_logic_loop_test.c index 3a40f59bb9..d68b200549 100644 --- a/pceplib/test/pcep_session_logic_loop_test.c +++ b/pceplib/test/pcep_session_logic_loop_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/test/pcep_session_logic_states_test.c b/pceplib/test/pcep_session_logic_states_test.c index f75c16e397..24741fa345 100644 --- a/pceplib/test/pcep_session_logic_states_test.c +++ b/pceplib/test/pcep_session_logic_states_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/test/pcep_session_logic_test.c b/pceplib/test/pcep_session_logic_test.c index 66db4fbaea..503e77c20e 100644 --- a/pceplib/test/pcep_session_logic_test.c +++ b/pceplib/test/pcep_session_logic_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/test/pcep_session_logic_tests.c b/pceplib/test/pcep_session_logic_tests.c index 67bf6e22ef..9a15390c1b 100644 --- a/pceplib/test/pcep_session_logic_tests.c +++ b/pceplib/test/pcep_session_logic_tests.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/test/pcep_socket_comm_loop_test.c b/pceplib/test/pcep_socket_comm_loop_test.c index 94f0983ca7..748cf433e6 100644 --- a/pceplib/test/pcep_socket_comm_loop_test.c +++ b/pceplib/test/pcep_socket_comm_loop_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/test/pcep_socket_comm_test.c b/pceplib/test/pcep_socket_comm_test.c index 35afbcbb13..0ab38bf96e 100644 --- a/pceplib/test/pcep_socket_comm_test.c +++ b/pceplib/test/pcep_socket_comm_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/test/pcep_socket_comm_tests.c b/pceplib/test/pcep_socket_comm_tests.c index 293678f1a7..6a5839d3d0 100644 --- a/pceplib/test/pcep_socket_comm_tests.c +++ b/pceplib/test/pcep_socket_comm_tests.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/test/pcep_timers_event_loop_test.c b/pceplib/test/pcep_timers_event_loop_test.c index ae63601df2..79ed84bfeb 100644 --- a/pceplib/test/pcep_timers_event_loop_test.c +++ b/pceplib/test/pcep_timers_event_loop_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/test/pcep_timers_test.c b/pceplib/test/pcep_timers_test.c index 9d9e0f6c1b..e5be90a8ed 100644 --- a/pceplib/test/pcep_timers_test.c +++ b/pceplib/test/pcep_timers_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/test/pcep_timers_tests.c b/pceplib/test/pcep_timers_tests.c index adfea17e29..f3aa8307a7 100644 --- a/pceplib/test/pcep_timers_tests.c +++ b/pceplib/test/pcep_timers_tests.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pceplib/test/pcep_utils_counters_test.c b/pceplib/test/pcep_utils_counters_test.c index 6f53e4d400..bcdce36188 100644 --- a/pceplib/test/pcep_utils_counters_test.c +++ b/pceplib/test/pcep_utils_counters_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/test/pcep_utils_double_linked_list_test.c b/pceplib/test/pcep_utils_double_linked_list_test.c index d2600e66c4..4eb85816b9 100644 --- a/pceplib/test/pcep_utils_double_linked_list_test.c +++ b/pceplib/test/pcep_utils_double_linked_list_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "pcep_utils_double_linked_list.h" diff --git a/pceplib/test/pcep_utils_memory_test.c b/pceplib/test/pcep_utils_memory_test.c index b0b528f084..0958626a0c 100644 --- a/pceplib/test/pcep_utils_memory_test.c +++ b/pceplib/test/pcep_utils_memory_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include diff --git a/pceplib/test/pcep_utils_ordered_list_test.c b/pceplib/test/pcep_utils_ordered_list_test.c index fe9ee58825..d20f5e68af 100644 --- a/pceplib/test/pcep_utils_ordered_list_test.c +++ b/pceplib/test/pcep_utils_ordered_list_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "pcep_utils_ordered_list.h" diff --git a/pceplib/test/pcep_utils_queue_test.c b/pceplib/test/pcep_utils_queue_test.c index 1731457789..061dfbf37b 100644 --- a/pceplib/test/pcep_utils_queue_test.c +++ b/pceplib/test/pcep_utils_queue_test.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include "pcep_utils_queue.h" diff --git a/pceplib/test/pcep_utils_tests.c b/pceplib/test/pcep_utils_tests.c index 452b9fa09c..ad9f76933a 100644 --- a/pceplib/test/pcep_utils_tests.c +++ b/pceplib/test/pcep_utils_tests.c @@ -21,6 +21,10 @@ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/pimd/pim_assert.c b/pimd/pim_assert.c index 957f904714..0988938701 100644 --- a/pimd/pim_assert.c +++ b/pimd/pim_assert.c @@ -304,7 +304,7 @@ int pim_assert_recv(struct interface *ifp, struct pim_neighbor *neigh, msg_metric.ip_address = src_addr; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); ++pim_ifp->pim_ifstat_assert_recv; return dispatch_assert(ifp, msg_source_addr.u.prefix4, sg.grp, diff --git a/pimd/pim_hello.c b/pimd/pim_hello.c index 6f5c4174e2..e48a4bdd4d 100644 --- a/pimd/pim_hello.c +++ b/pimd/pim_hello.c @@ -141,14 +141,14 @@ int pim_hello_recv(struct interface *ifp, struct in_addr src_addr, on_trace(__func__, ifp, src_addr); pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); ++pim_ifp->pim_ifstat_hello_recv; /* Parse PIM hello TLVs */ - zassert(tlv_buf_size >= 0); + assert(tlv_buf_size >= 0); tlv_curr = tlv_buf; tlv_pastend = tlv_buf + tlv_buf_size; @@ -539,11 +539,11 @@ void pim_hello_require(struct interface *ifp) { struct pim_interface *pim_ifp; - zassert(ifp); + assert(ifp); pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); if (pim_ifp->pim_ifstat_hello_sent) return; diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index 62d19f7619..834399053b 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -115,8 +115,8 @@ struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim, { struct pim_interface *pim_ifp; - zassert(ifp); - zassert(!ifp->info); + assert(ifp); + assert(!ifp->info); pim_ifp = XCALLOC(MTYPE_PIM_INTERFACE, sizeof(*pim_ifp)); @@ -145,8 +145,8 @@ struct pim_interface *pim_if_new(struct interface *ifp, bool igmp, bool pim, The number of seconds represented by the [Query Response Interval] must be less than the [Query Interval]. */ - zassert(pim_ifp->igmp_query_max_response_time_dsec - < pim_ifp->igmp_default_query_interval); + assert(pim_ifp->igmp_query_max_response_time_dsec + < pim_ifp->igmp_default_query_interval); if (pim) PIM_IF_DO_PIM(pim_ifp->options); @@ -198,9 +198,9 @@ void pim_if_delete(struct interface *ifp) struct pim_interface *pim_ifp; struct pim_ifchannel *ch; - zassert(ifp); + assert(ifp); pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); if (pim_ifp->igmp_join_list) { pim_if_igmp_join_del_all(ifp); @@ -238,7 +238,7 @@ void pim_if_update_could_assert(struct interface *ifp) struct pim_ifchannel *ch; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) { pim_ifchannel_update_could_assert(ch); @@ -251,7 +251,7 @@ static void pim_if_update_my_assert_metric(struct interface *ifp) struct pim_ifchannel *ch; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) { pim_ifchannel_update_my_assert_metric(ch); @@ -263,7 +263,7 @@ static void pim_addr_change(struct interface *ifp) struct pim_interface *pim_ifp; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); pim_if_dr_election(ifp); /* router's own DR Priority (addr) changes -- Done TODO T30 */ @@ -507,10 +507,10 @@ void pim_if_addr_add(struct connected *ifc) struct in_addr ifaddr; bool vxlan_term; - zassert(ifc); + assert(ifc); ifp = ifc->ifp; - zassert(ifp); + assert(ifp); pim_ifp = ifp->info; if (!pim_ifp) return; @@ -708,9 +708,9 @@ void pim_if_addr_del(struct connected *ifc, int force_prim_as_any) { struct interface *ifp; - zassert(ifc); + assert(ifc); ifp = ifc->ifp; - zassert(ifp); + assert(ifp); if (PIM_DEBUG_ZEBRA) zlog_debug("%s: %s ifindex=%d disconnected IP address %pFX %s", @@ -945,7 +945,7 @@ int pim_if_add_vif(struct interface *ifp, bool ispimreg, bool is_vxlan_term) struct in_addr ifaddr; unsigned char flags = 0; - zassert(pim_ifp); + assert(pim_ifp); if (pim_ifp->mroute_vif_index > 0) { zlog_warn("%s: vif_index=%d > 0 on interface %s ifindex=%d", @@ -1063,8 +1063,8 @@ int pim_if_lan_delay_enabled(struct interface *ifp) struct pim_interface *pim_ifp; pim_ifp = ifp->info; - zassert(pim_ifp); - zassert(pim_ifp->pim_number_of_nonlandelay_neighbors >= 0); + assert(pim_ifp); + assert(pim_ifp->pim_number_of_nonlandelay_neighbors >= 0); return pim_ifp->pim_number_of_nonlandelay_neighbors == 0; } @@ -1128,7 +1128,7 @@ struct pim_neighbor *pim_if_find_neighbor(struct interface *ifp, struct pim_interface *pim_ifp; struct prefix p; - zassert(ifp); + assert(ifp); pim_ifp = ifp->info; if (!pim_ifp) { @@ -1171,7 +1171,7 @@ long pim_if_t_suppressed_msec(struct interface *ifp) uint32_t ramount = 0; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); /* join suppression disabled ? */ if (PIM_IF_TEST_PIM_CAN_DISABLE_JOIN_SUPPRESSION(pim_ifp->options)) @@ -1196,7 +1196,7 @@ static struct igmp_join *igmp_join_find(struct list *join_list, struct listnode *node; struct igmp_join *ij; - zassert(join_list); + assert(join_list); for (ALL_LIST_ELEMENTS_RO(join_list, node, ij)) { if ((group_addr.s_addr == ij->group_addr.s_addr) @@ -1245,7 +1245,7 @@ static struct igmp_join *igmp_join_new(struct interface *ifp, int join_fd; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); join_fd = igmp_join_sock(ifp->name, ifp->ifindex, group_addr, source_addr); @@ -1416,7 +1416,7 @@ void pim_if_assert_on_neighbor_down(struct interface *ifp, struct pim_ifchannel *ch; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) { /* Is (S,G,I) assert loser ? */ diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index cdaf7bcdd4..579824c88d 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -498,7 +498,7 @@ void pim_ifchannel_membership_clear(struct interface *ifp) struct pim_ifchannel *ch; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) ifmembership_set(ch, PIM_IFMEMBERSHIP_NOINFO); @@ -510,7 +510,7 @@ void pim_ifchannel_delete_on_noinfo(struct interface *ifp) struct pim_ifchannel *ch, *ch_tmp; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); RB_FOREACH_SAFE (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb, ch_tmp) delete_on_noinfo(ch); @@ -825,7 +825,7 @@ static int nonlocal_upstream(int is_join, struct interface *recv_ifp, int is_local; /* boolean */ recv_pim_ifp = recv_ifp->info; - zassert(recv_pim_ifp); + assert(recv_pim_ifp); is_local = (upstream.s_addr == recv_pim_ifp->primary_address.s_addr); @@ -913,7 +913,7 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr, } pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); switch (ch->ifjoin_state) { case PIM_IFJOIN_NOINFO: @@ -939,7 +939,7 @@ void pim_ifchannel_join_add(struct interface *ifp, struct in_addr neigh_addr, } break; case PIM_IFJOIN_JOIN: - zassert(!ch->t_ifjoin_prune_pending_timer); + assert(!ch->t_ifjoin_prune_pending_timer); /* In the JOIN state ch->t_ifjoin_expiry_timer may be NULL due to diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c index 73e42e9d83..f2b909e268 100644 --- a/pimd/pim_igmp.c +++ b/pimd/pim_igmp.c @@ -159,7 +159,7 @@ static int pim_igmp_other_querier_expire(struct thread *t) igmp = THREAD_ARG(t); - zassert(!igmp->t_igmp_query_timer); + assert(!igmp->t_igmp_query_timer); if (PIM_DEBUG_IGMP_TRACE) { char ifaddr_str[INET_ADDRSTRLEN]; @@ -185,9 +185,9 @@ void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp) long other_querier_present_interval_msec; struct pim_interface *pim_ifp; - zassert(igmp); - zassert(igmp->interface); - zassert(igmp->interface->info); + assert(igmp); + assert(igmp->interface); + assert(igmp->interface->info); pim_ifp = igmp->interface->info; @@ -218,7 +218,7 @@ void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp) Since this socket is starting the other-querier-present timer, there should not be periodic query timer for this socket. */ - zassert(!igmp->t_igmp_query_timer); + assert(!igmp->t_igmp_query_timer); /* RFC 3376: 8.5. Other Querier Present Interval @@ -255,7 +255,7 @@ void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp) void pim_igmp_other_querier_timer_off(struct igmp_sock *igmp) { - zassert(igmp); + assert(igmp); if (PIM_DEBUG_IGMP_TRACE) { if (igmp->t_other_querier_timer) { @@ -589,9 +589,9 @@ void pim_igmp_general_query_on(struct igmp_sock *igmp) Since this socket is starting as querier, there should not exist a timer for other-querier-present. */ - zassert(!igmp->t_other_querier_timer); + assert(!igmp->t_other_querier_timer); pim_ifp = igmp->interface->info; - zassert(pim_ifp); + assert(pim_ifp); /* RFC 3376: 8.6. Startup Query Interval @@ -638,7 +638,7 @@ void pim_igmp_general_query_on(struct igmp_sock *igmp) void pim_igmp_general_query_off(struct igmp_sock *igmp) { - zassert(igmp); + assert(igmp); if (PIM_DEBUG_IGMP_TRACE) { if (igmp->t_igmp_query_timer) { @@ -664,8 +664,8 @@ static int pim_igmp_general_query(struct thread *t) igmp = THREAD_ARG(t); - zassert(igmp->interface); - zassert(igmp->interface->info); + assert(igmp->interface); + assert(igmp->interface->info); pim_ifp = igmp->interface->info; @@ -835,19 +835,19 @@ void igmp_group_delete(struct igmp_group *group) void igmp_group_delete_empty_include(struct igmp_group *group) { - zassert(!group->group_filtermode_isexcl); - zassert(!listcount(group->group_source_list)); + assert(!group->group_filtermode_isexcl); + assert(!listcount(group->group_source_list)); igmp_group_delete(group); } void igmp_sock_free(struct igmp_sock *igmp) { - zassert(!igmp->t_igmp_read); - zassert(!igmp->t_igmp_query_timer); - zassert(!igmp->t_other_querier_timer); - zassert(igmp->igmp_group_list); - zassert(!listcount(igmp->igmp_group_list)); + assert(!igmp->t_igmp_read); + assert(!igmp->t_igmp_query_timer); + assert(!igmp->t_other_querier_timer); + assert(igmp->igmp_group_list); + assert(!listcount(igmp->igmp_group_list)); list_delete(&igmp->igmp_group_list); hash_free(igmp->igmp_group_hash); @@ -1076,7 +1076,7 @@ static int igmp_group_timer(struct thread *t) group_str, group->group_igmp_sock->interface->name); } - zassert(group->group_filtermode_isexcl); + assert(group->group_filtermode_isexcl); group->group_filtermode_isexcl = 0; @@ -1085,7 +1085,7 @@ static int igmp_group_timer(struct thread *t) igmp_source_delete_expired(group->group_source_list); - zassert(!group->group_filtermode_isexcl); + assert(!group->group_filtermode_isexcl); /* RFC 3376: 6.2.2. Definition of Group Timers @@ -1137,7 +1137,7 @@ void igmp_group_timer_on(struct igmp_group *group, long interval_msec, it represents the time for the *filter-mode* of the group to expire and switch to INCLUDE mode. */ - zassert(group->group_filtermode_isexcl); + assert(group->group_filtermode_isexcl); thread_add_timer_msec(router->master, igmp_group_timer, group, interval_msec, &group->t_group_timer); @@ -1228,8 +1228,8 @@ struct igmp_group *igmp_add_group_by_addr(struct igmp_sock *igmp, it represents the time for the *filter-mode* of the group to expire and switch to INCLUDE mode. */ - zassert(!group->group_filtermode_isexcl); /* INCLUDE mode */ - zassert(!group->t_group_timer); /* group timer == 0 */ + assert(!group->group_filtermode_isexcl); /* INCLUDE mode */ + assert(!group->t_group_timer); /* group timer == 0 */ /* Any source (*,G) is forwarded only if mode is EXCLUDE {empty} */ igmp_anysource_forward_stop(group); diff --git a/pimd/pim_igmpv2.c b/pimd/pim_igmpv2.c index 7f3c7a0f8c..6eadf87c83 100644 --- a/pimd/pim_igmpv2.c +++ b/pimd/pim_igmpv2.c @@ -54,7 +54,7 @@ void igmp_v2_send_query(struct igmp_group *group, int fd, const char *ifname, /* max_resp_code must be non-zero else this will look like an IGMP v1 * query */ max_resp_code = igmp_msg_encode16to8(query_max_response_time_dsec); - zassert(max_resp_code > 0); + assert(max_resp_code > 0); query_buf[0] = PIM_IGMP_MEMBERSHIP_QUERY; query_buf[1] = max_resp_code; diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c index 425adfe166..3ae7744eb0 100644 --- a/pimd/pim_igmpv3.c +++ b/pimd/pim_igmpv3.c @@ -103,7 +103,7 @@ void igmp_group_reset_gmi(struct igmp_group *group) it represents the time for the *filter-mode* of the group to expire and switch to INCLUDE mode. */ - zassert(group->group_filtermode_isexcl); + assert(group->group_filtermode_isexcl); igmp_group_timer_on(group, group_membership_interval_msec, ifp->name); } @@ -314,7 +314,7 @@ static void group_exclude_fwd_anysrc_ifempty(struct igmp_group *group) { struct pim_interface *pim_ifp = group->group_igmp_sock->interface->info; - zassert(group->group_filtermode_isexcl); + assert(group->group_filtermode_isexcl); if (listcount(group->group_source_list) < 1) { igmp_anysource_forward_start(pim_ifp->pim, group); @@ -324,7 +324,7 @@ static void group_exclude_fwd_anysrc_ifempty(struct igmp_group *group) void igmp_source_free(struct igmp_source *source) { /* make sure there is no source timer running */ - zassert(!source->t_source_timer); + assert(!source->t_source_timer); XFREE(MTYPE_PIM_IGMP_GROUP_SOURCE, source); } @@ -557,7 +557,7 @@ static void isex_excl(struct igmp_group *group, int num_sources, int i; /* EXCLUDE mode */ - zassert(group->group_filtermode_isexcl); + assert(group->group_filtermode_isexcl); /* E.1: set deletion flag for known sources (X,Y) */ source_mark_delete_flag(group); @@ -577,10 +577,10 @@ static void isex_excl(struct igmp_group *group, int num_sources, /* E.4: if not found, create source with timer=GMI: * (A-X-Y) */ source = source_new(group, *src_addr); - zassert(!source->t_source_timer); /* timer == 0 */ + assert(!source->t_source_timer); /* timer == 0 */ igmp_source_reset_gmi(group->group_igmp_sock, group, source); - zassert(source->t_source_timer); /* (A-X-Y) timer > 0 */ + assert(source->t_source_timer); /* (A-X-Y) timer > 0 */ } } /* scan received sources */ @@ -610,7 +610,7 @@ static void isex_incl(struct igmp_group *group, int num_sources, int i; /* INCLUDE mode */ - zassert(!group->group_filtermode_isexcl); + assert(!group->group_filtermode_isexcl); /* I.1: set deletion flag for known sources (A) */ source_mark_delete_flag(group); @@ -631,7 +631,7 @@ static void isex_incl(struct igmp_group *group, int num_sources, /* I.4: if not found, create source with timer=0 (B-A) */ source = source_new(group, *src_addr); - zassert(!source->t_source_timer); /* (B-A) timer=0 */ + assert(!source->t_source_timer); /* (B-A) timer=0 */ } } /* scan received sources */ @@ -641,7 +641,7 @@ static void isex_incl(struct igmp_group *group, int num_sources, group->group_filtermode_isexcl = 1; /* boolean=true */ - zassert(group->group_filtermode_isexcl); + assert(group->group_filtermode_isexcl); group_exclude_fwd_anysrc_ifempty(group); } @@ -675,10 +675,10 @@ void igmpv3_report_isex(struct igmp_sock *igmp, struct in_addr from, } else { /* INCLUDE mode */ isex_incl(group, num_sources, sources); - zassert(group->group_filtermode_isexcl); + assert(group->group_filtermode_isexcl); } - zassert(group->group_filtermode_isexcl); + assert(group->group_filtermode_isexcl); igmp_group_reset_gmi(group); } @@ -807,7 +807,7 @@ static void toex_incl(struct igmp_group *group, int num_sources, int num_sources_tosend = 0; int i; - zassert(!group->group_filtermode_isexcl); + assert(!group->group_filtermode_isexcl); /* Set DELETE flag for all known sources (A) */ source_mark_delete_flag(group); @@ -834,7 +834,7 @@ static void toex_incl(struct igmp_group *group, int num_sources, /* If source not found, create source with timer=0: * (B-A)=0 */ source = source_new(group, *src_addr); - zassert(!source->t_source_timer); /* (B-A) timer=0 */ + assert(!source->t_source_timer); /* (B-A) timer=0 */ } } /* Scan received sources (B) */ @@ -849,7 +849,7 @@ static void toex_incl(struct igmp_group *group, int num_sources, source_query_send_by_flag(group, num_sources_tosend); } - zassert(group->group_filtermode_isexcl); + assert(group->group_filtermode_isexcl); group_exclude_fwd_anysrc_ifempty(group); } @@ -894,17 +894,17 @@ static void toex_excl(struct igmp_group *group, int num_sources, long group_timer_msec; source = source_new(group, *src_addr); - zassert(!source->t_source_timer); /* timer == 0 */ + assert(!source->t_source_timer); /* timer == 0 */ group_timer_msec = igmp_group_timer_remain_msec(group); igmp_source_timer_on(group, source, group_timer_msec); - zassert(source->t_source_timer); /* (A-X-Y) timer > 0 */ + assert(source->t_source_timer); /* (A-X-Y) timer > 0 */ /* make sure source is created with DELETE flag unset */ - zassert(!IGMP_SOURCE_TEST_DELETE(source->source_flags)); + assert(!IGMP_SOURCE_TEST_DELETE(source->source_flags)); } /* make sure reported source has DELETE flag unset */ - zassert(!IGMP_SOURCE_TEST_DELETE(source->source_flags)); + assert(!IGMP_SOURCE_TEST_DELETE(source->source_flags)); if (source->t_source_timer) { /* if source timer>0 mark SEND flag: Q(G,A-Y) */ @@ -948,9 +948,9 @@ void igmpv3_report_toex(struct igmp_sock *igmp, struct in_addr from, } else { /* INCLUDE mode */ toex_incl(group, num_sources, sources); - zassert(group->group_filtermode_isexcl); + assert(group->group_filtermode_isexcl); } - zassert(group->group_filtermode_isexcl); + assert(group->group_filtermode_isexcl); /* Group Timer=GMI */ igmp_group_reset_gmi(group); @@ -1347,7 +1347,7 @@ static void source_query_send_by_flag(struct igmp_group *group, long lmqi_msec; /* Last Member Query Interval */ long lmqt_msec; /* Last Member Query Time */ - zassert(num_sources_tosend > 0); + assert(num_sources_tosend > 0); igmp = group->group_igmp_sock; pim_ifp = igmp->interface->info; @@ -1408,10 +1408,10 @@ static void block_excl(struct igmp_group *group, int num_sources, long group_timer_msec; source = source_new(group, *src_addr); - zassert(!source->t_source_timer); /* timer == 0 */ + assert(!source->t_source_timer); /* timer == 0 */ group_timer_msec = igmp_group_timer_remain_msec(group); igmp_source_timer_on(group, source, group_timer_msec); - zassert(source->t_source_timer); /* (A-X-Y) timer > 0 */ + assert(source->t_source_timer); /* (A-X-Y) timer > 0 */ } if (source->t_source_timer) { @@ -1523,7 +1523,7 @@ void igmp_group_timer_lower_to_lmqt(struct igmp_group *group) lmqt_msec); } - zassert(group->group_filtermode_isexcl); + assert(group->group_filtermode_isexcl); igmp_group_timer_on(group, lmqt_msec, ifname); } @@ -1581,7 +1581,7 @@ void igmp_v3_send_query(struct igmp_group *group, int fd, const char *ifname, socklen_t tolen; uint16_t checksum; - zassert(num_sources >= 0); + assert(num_sources >= 0); msg_size = IGMP_V3_SOURCES_OFFSET + (num_sources << 2); if (msg_size > query_buf_size) { @@ -1593,7 +1593,7 @@ void igmp_v3_send_query(struct igmp_group *group, int fd, const char *ifname, } s_flag = PIM_FORCE_BOOLEAN(s_flag); - zassert((s_flag == 0) || (s_flag == 1)); + assert((s_flag == 0) || (s_flag == 1)); max_resp_code = igmp_msg_encode16to8(query_max_response_time_dsec); qqic = igmp_msg_encode16to8(querier_query_interval); diff --git a/pimd/pim_join.c b/pimd/pim_join.c index 2766a6d2b5..c7a80ca8e0 100644 --- a/pimd/pim_join.c +++ b/pimd/pim_join.c @@ -71,7 +71,7 @@ static void recv_join(struct interface *ifp, struct pim_neighbor *neigh, } pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); ++pim_ifp->pim_ifstat_join_recv; @@ -134,7 +134,7 @@ static void recv_prune(struct interface *ifp, struct pim_neighbor *neigh, } pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); ++pim_ifp->pim_ifstat_prune_recv; diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c index 8e6f2ec42b..da2daea7c3 100644 --- a/pimd/pim_nb_config.c +++ b/pimd/pim_nb_config.c @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "pimd.h" #include "pim_nb.h" #include "lib/northbound_cli.h" @@ -36,7 +38,7 @@ static void pim_if_membership_clear(struct interface *ifp) struct pim_interface *pim_ifp; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); if (PIM_IF_TEST_PIM(pim_ifp->options) && PIM_IF_TEST_IGMP(pim_ifp->options)) { @@ -62,7 +64,7 @@ static void pim_if_membership_refresh(struct interface *ifp) struct igmp_sock *igmp; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); if (!PIM_IF_TEST_PIM(pim_ifp->options)) return; @@ -576,7 +578,7 @@ static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp) struct interface *ifp; struct pim_interface *pim_ifp; - zassert(igmp); + assert(igmp); /* other querier present? */ @@ -585,8 +587,8 @@ static void igmp_sock_query_interval_reconfig(struct igmp_sock *igmp) /* this is the querier */ - zassert(igmp->interface); - zassert(igmp->interface->info); + assert(igmp->interface); + assert(igmp->interface->info); ifp = igmp->interface; pim_ifp = ifp->info; @@ -616,25 +618,25 @@ static void igmp_sock_query_reschedule(struct igmp_sock *igmp) if (igmp->t_igmp_query_timer) { /* other querier present */ - zassert(igmp->t_igmp_query_timer); - zassert(!igmp->t_other_querier_timer); + assert(igmp->t_igmp_query_timer); + assert(!igmp->t_other_querier_timer); pim_igmp_general_query_off(igmp); pim_igmp_general_query_on(igmp); - zassert(igmp->t_igmp_query_timer); - zassert(!igmp->t_other_querier_timer); + assert(igmp->t_igmp_query_timer); + assert(!igmp->t_other_querier_timer); } else { /* this is the querier */ - zassert(!igmp->t_igmp_query_timer); - zassert(igmp->t_other_querier_timer); + assert(!igmp->t_igmp_query_timer); + assert(igmp->t_other_querier_timer); pim_igmp_other_querier_timer_off(igmp); pim_igmp_other_querier_timer_on(igmp); - zassert(!igmp->t_igmp_query_timer); - zassert(igmp->t_other_querier_timer); + assert(!igmp->t_igmp_query_timer); + assert(igmp->t_other_querier_timer); } } diff --git a/pimd/pim_neighbor.c b/pimd/pim_neighbor.c index 19dc469091..48b1a30f2d 100644 --- a/pimd/pim_neighbor.c +++ b/pimd/pim_neighbor.c @@ -49,7 +49,7 @@ static void dr_election_by_addr(struct interface *ifp) struct pim_neighbor *neigh; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); pim_ifp->pim_dr_addr = pim_ifp->primary_address; @@ -73,7 +73,7 @@ static void dr_election_by_pri(struct interface *ifp) uint32_t dr_pri; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); pim_ifp->pim_dr_addr = pim_ifp->primary_address; dr_pri = pim_ifp->pim_dr_priority; @@ -310,9 +310,9 @@ pim_neighbor_new(struct interface *ifp, struct in_addr source_addr, struct pim_neighbor *neigh; char src_str[INET_ADDRSTRLEN]; - zassert(ifp); + assert(ifp); pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); neigh = XCALLOC(MTYPE_PIM_NEIGHBOR, sizeof(*neigh)); @@ -412,7 +412,7 @@ static void delete_prefix_list(struct pim_neighbor *neigh) void pim_neighbor_free(struct pim_neighbor *neigh) { - zassert(!neigh->t_expire_timer); + assert(!neigh->t_expire_timer); delete_prefix_list(neigh); @@ -503,7 +503,7 @@ pim_neighbor_add(struct interface *ifp, struct in_addr source_addr, } pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); listnode_add(pim_ifp->pim_neighbor_list, neigh); @@ -566,7 +566,7 @@ static uint16_t find_neighbors_next_highest_propagation_delay_msec( uint16_t next_highest_delay_msec; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); next_highest_delay_msec = pim_ifp->pim_propagation_delay_msec; @@ -590,7 +590,7 @@ static uint16_t find_neighbors_next_highest_override_interval_msec( uint16_t next_highest_interval_msec; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); next_highest_interval_msec = pim_ifp->pim_override_interval_msec; @@ -613,7 +613,7 @@ void pim_neighbor_delete(struct interface *ifp, struct pim_neighbor *neigh, char src_str[INET_ADDRSTRLEN]; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); pim_inet4_dump("", neigh->source_addr, src_str, sizeof(src_str)); zlog_info("PIM NEIGHBOR DOWN: neighbor %s on interface %s: %s", src_str, @@ -637,10 +637,10 @@ void pim_neighbor_delete(struct interface *ifp, struct pim_neighbor *neigh, --pim_ifp->pim_dr_num_nondrpri_neighbors; } - zassert(neigh->propagation_delay_msec - <= pim_ifp->pim_neighbors_highest_propagation_delay_msec); - zassert(neigh->override_interval_msec - <= pim_ifp->pim_neighbors_highest_override_interval_msec); + assert(neigh->propagation_delay_msec + <= pim_ifp->pim_neighbors_highest_propagation_delay_msec); + assert(neigh->override_interval_msec + <= pim_ifp->pim_neighbors_highest_override_interval_msec); if (pim_if_lan_delay_enabled(ifp)) { @@ -683,7 +683,7 @@ void pim_neighbor_delete_all(struct interface *ifp, const char *delete_message) struct pim_neighbor *neigh; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); for (ALL_LIST_ELEMENTS(pim_ifp->pim_neighbor_list, neigh_node, neigh_nextnode, neigh)) { @@ -728,9 +728,9 @@ static void delete_from_neigh_addr(struct interface *ifp, struct pim_interface *pim_ifp; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); - zassert(addr_list); + assert(addr_list); /* Scan secondary address list diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c index 3ec0720fc4..0a4e3e1a6f 100644 --- a/pimd/pim_oil.c +++ b/pimd/pim_oil.c @@ -219,8 +219,8 @@ int pim_channel_del_oif(struct channel_oil *channel_oil, struct interface *oif, { struct pim_interface *pim_ifp; - zassert(channel_oil); - zassert(oif); + assert(channel_oil); + assert(oif); pim_ifp = oif->info; diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c index 2ccff8b84a..4ba08a19d8 100644 --- a/pimd/pim_pim.c +++ b/pimd/pim_pim.c @@ -407,8 +407,8 @@ static void pim_sock_read_on(struct interface *ifp) { struct pim_interface *pim_ifp; - zassert(ifp); - zassert(ifp->info); + assert(ifp); + assert(ifp->info); pim_ifp = ifp->info; @@ -444,7 +444,7 @@ void pim_ifstat_reset(struct interface *ifp) { struct pim_interface *pim_ifp; - zassert(ifp); + assert(ifp); pim_ifp = ifp->info; if (!pim_ifp) { @@ -462,8 +462,8 @@ void pim_sock_reset(struct interface *ifp) { struct pim_interface *pim_ifp; - zassert(ifp); - zassert(ifp->info); + assert(ifp); + assert(ifp->info); pim_ifp = ifp->info; @@ -671,8 +671,8 @@ static int hello_send(struct interface *ifp, uint16_t holdtime) pim_msg_size = pim_tlv_size + PIM_PIM_MIN_LEN; - zassert(pim_msg_size >= PIM_PIM_MIN_LEN); - zassert(pim_msg_size <= PIM_PIM_BUFSIZE_WRITE); + assert(pim_msg_size >= PIM_PIM_MIN_LEN); + assert(pim_msg_size <= PIM_PIM_BUFSIZE_WRITE); pim_msg_build_header(pim_msg, pim_msg_size, PIM_MSG_TYPE_HELLO, false); @@ -846,7 +846,7 @@ int pim_sock_add(struct interface *ifp) uint32_t old_genid; pim_ifp = ifp->info; - zassert(pim_ifp); + assert(pim_ifp); if (pim_ifp->pim_sock_fd >= 0) { if (PIM_DEBUG_PIM_PACKETS) diff --git a/pimd/pim_ssmpingd.c b/pimd/pim_ssmpingd.c index f4d3547b3f..03e77de161 100644 --- a/pimd/pim_ssmpingd.c +++ b/pimd/pim_ssmpingd.c @@ -41,12 +41,12 @@ void pim_ssmpingd_init(struct pim_instance *pim) { int result; - zassert(!pim->ssmpingd_list); + assert(!pim->ssmpingd_list); result = inet_pton(AF_INET, PIM_SSMPINGD_REPLY_GROUP, &pim->ssmpingd_group_addr); - zassert(result > 0); + assert(result > 0); } void pim_ssmpingd_destroy(struct pim_instance *pim) @@ -197,7 +197,7 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl) static void ssmpingd_delete(struct ssmpingd_sock *ss) { - zassert(ss); + assert(ss); THREAD_OFF(ss->t_sock_read); diff --git a/pimd/pim_time.c b/pimd/pim_time.c index 9878fcf6b4..c88ee7554b 100644 --- a/pimd/pim_time.c +++ b/pimd/pim_time.c @@ -106,7 +106,7 @@ int pim_time_mmss(char *buf, int buf_size, long sec) long mm; int wr; - zassert(buf_size >= 5); + assert(buf_size >= 5); mm = sec / 60; sec %= 60; @@ -122,7 +122,7 @@ static int pim_time_hhmmss(char *buf, int buf_size, long sec) long mm; int wr; - zassert(buf_size >= 8); + assert(buf_size >= 8); hh = sec / 3600; sec %= 3600; @@ -156,7 +156,7 @@ void pim_time_timer_to_hhmmss(char *buf, int buf_size, struct thread *t_timer) void pim_time_uptime(char *buf, int buf_size, int64_t uptime_sec) { - zassert(buf_size >= 8); + assert(buf_size >= 8); pim_time_hhmmss(buf, buf_size, uptime_sec); } diff --git a/pimd/pim_tlv.c b/pimd/pim_tlv.c index 633bb207bd..f21c369b8d 100644 --- a/pimd/pim_tlv.c +++ b/pimd/pim_tlv.c @@ -662,7 +662,7 @@ int pim_tlv_parse_addr_list(const char *ifname, struct in_addr src_addr, const uint8_t *addr; const uint8_t *pastend; - zassert(hello_option_addr_list); + assert(hello_option_addr_list); /* Scan addr list diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index f0eae955cc..6f933e9e72 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -471,8 +471,8 @@ void igmp_anysource_forward_start(struct pim_instance *pim, struct igmp_source *source; struct in_addr src_addr = {.s_addr = 0}; /* Any source (*,G) is forwarded only if mode is EXCLUDE {empty} */ - zassert(group->group_filtermode_isexcl); - zassert(listcount(group->group_source_list) < 1); + assert(group->group_filtermode_isexcl); + assert(listcount(group->group_source_list) < 1); source = source_new(group, src_addr); if (!source) { diff --git a/pimd/pimd.c b/pimd/pimd.c index 811dc96b56..1679480794 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -126,7 +126,7 @@ void pim_init(void) "%s %s: could not solve %s to group address: errno=%d: %s", __FILE__, __func__, PIM_ALL_PIM_ROUTERS, errno, safe_strerror(errno)); - zassert(0); + assert(0); return; } diff --git a/python/firstheader.py b/python/firstheader.py index bf50f33a33..892e9da8d6 100644 --- a/python/firstheader.py +++ b/python/firstheader.py @@ -1,30 +1,90 @@ -# # check that the first header included in C files is either # zebra.h or config.h # +# Copyright (C) 2020 David Lamparter for NetDEF, Inc. +# +# This program is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the Free +# Software Foundation; either version 2 of the License, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +# more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; see the file COPYING; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -import sys, os, re, subprocess +import sys +import os +import re +import subprocess +import argparse + +argp = argparse.ArgumentParser(description="include fixer") +argp.add_argument("--autofix", action="store_const", const=True) +argp.add_argument("--warn-empty", action="store_const", const=True) +argp.add_argument("--pipe", action="store_const", const=True) include_re = re.compile('^#\s*include\s+["<]([^ ">]+)[">]', re.M) -errors = 0 +ignore = [ + lambda fn: fn.startswith("tools/"), + lambda fn: fn + in [ + "lib/elf_py.c", + ], +] + + +def run(args): + out = [] + + files = subprocess.check_output(["git", "ls-files"]).decode("ASCII") + for fn in files.splitlines(): + if not fn.endswith(".c"): + continue + if max([i(fn) for i in ignore]): + continue + + with open(fn, "r") as fd: + data = fd.read() -files = subprocess.check_output(["git", "ls-files"]).decode("ASCII") -for fn in files.splitlines(): - if not fn.endswith(".c"): - continue - if fn.startswith("tools/"): - continue - with open(fn, "r") as fd: - data = fd.read() m = include_re.search(data) if m is None: - # sys.stderr.write('no #include in %s?\n' % (fn)) + if args.warn_empty: + sys.stderr.write("no #include in %s?\n" % (fn)) continue if m.group(1) in ["config.h", "zebra.h", "lib/zebra.h"]: continue - sys.stderr.write("%s: %s\n" % (fn, m.group(0))) - errors += 1 -if errors: - sys.exit(1) + if args.autofix: + sys.stderr.write("%s: %s - fixing\n" % (fn, m.group(0))) + if fn.startswith("pceplib/"): + insert = '#ifdef HAVE_CONFIG_H\n#include "config.h"\n#endif\n\n' + else: + insert = "#include \n\n" + + pos = m.span()[0] + + data = data[:pos] + insert + data[pos:] + with open(fn + ".new", "w") as fd: + fd.write(data) + os.rename(fn + ".new", fn) + else: + sys.stderr.write("%s: %s\n" % (fn, m.group(0))) + out.append(fn) + + if len(out): + if args.pipe: + # for "vim `firstheader.py`" + print("\n".join(out)) + return 1 + return 0 + + +if __name__ == "__main__": + args = argp.parse_args() + sys.exit(run(args)) diff --git a/staticd/static_nb.c b/staticd/static_nb.c index a2a14751cf..aa9076aa88 100644 --- a/staticd/static_nb.c +++ b/staticd/static_nb.c @@ -16,6 +16,8 @@ * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "northbound.h" #include "libfrr.h" #include "static_nb.h" diff --git a/staticd/static_nb_config.c b/staticd/static_nb_config.c index db154992f9..e78f5172a3 100644 --- a/staticd/static_nb_config.c +++ b/staticd/static_nb_config.c @@ -16,6 +16,8 @@ * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "northbound.h" #include "libfrr.h" #include "log.h" diff --git a/tests/.gitignore b/tests/.gitignore index ca20b0ecac..0c938beab6 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -21,6 +21,7 @@ /lib/cli/test_commands_defun.c /lib/northbound/test_oper_data /lib/cxxcompat +/lib/test_assert /lib/test_atomlist /lib/test_buffer /lib/test_checksum @@ -52,4 +53,4 @@ /lib/test_zmq /ospf6d/test_lsdb /ospf6d/test_lsdb_clippy.c -/zebra/test_lm_plugin \ No newline at end of file +/zebra/test_lm_plugin diff --git a/tests/lib/cxxcompat.c b/tests/lib/cxxcompat.c index fde0d6af52..2589fca614 100644 --- a/tests/lib/cxxcompat.c +++ b/tests/lib/cxxcompat.c @@ -104,7 +104,6 @@ #include "lib/yang.h" #include "lib/yang_translator.h" #include "lib/yang_wrappers.h" -#include "lib/zassert.h" #include "lib/zclient.h" PREDECL_RBTREE_UNIQ(footree); diff --git a/tests/lib/test_assert.c b/tests/lib/test_assert.c new file mode 100644 index 0000000000..8f1f4f2bad --- /dev/null +++ b/tests/lib/test_assert.c @@ -0,0 +1,64 @@ +/* + * Quick test for assert() + * Copyright (C) 2021 David Lamparter for NetDEF, Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the Free + * Software Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; see the file COPYING; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +/* make sure this works with assert.h & nothing else. also check the include + * shadowing, we don't want to pick up system assert.h + */ +#include + +__attribute__((noinline)) +void func_for_bt(int number) +{ + assert(number > 2); + assertf(number > 3, "(A) the number was %d", number); +} + +#include +#include "lib/zlog.h" +#include "lib/thread.h" +#include "lib/sigevent.h" + +int main(int argc, char **argv) +{ + int number = 10; + struct thread_master *master; + + zlog_aux_init("NONE: ", LOG_DEBUG); + + if (argc > 1) + number = atoi(argv[1]); + + assert(number > 0); + assertf(number > 1, "(B) the number was %d", number); + + /* set up SIGABRT handler */ + master = thread_master_create("test"); + signal_init(master, 0, NULL); + + func_for_bt(number); + assert(number > 4); + assertf(number > 5, "(C) the number was %d", number); + + assertf(number > 10, "(D) the number was %d", number); + return 0; +} diff --git a/tests/lib/test_assert.py b/tests/lib/test_assert.py new file mode 100644 index 0000000000..67c88e6220 --- /dev/null +++ b/tests/lib/test_assert.py @@ -0,0 +1,56 @@ +import frrtest +import os +import re +import subprocess +import inspect + +basedir = os.path.dirname(__file__) +program = os.path.join(basedir, "test_assert") + + +def check(number, rex=None): + proc = subprocess.Popen( + [frrtest.binpath(program), str(number)], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + ) + out, err = proc.communicate() + exitcode = proc.wait() + + if rex is None: + assert exitcode == 0 + else: + assert exitcode != 0 + + text = out.decode("US-ASCII") + err.decode("US-ASCII") + rex = re.compile(rex, re.M | re.S) + m = rex.search(text) + assert m is not None, "non-matching output: %s" % text + + +def test_assert_0(): + check(0, r"test_assert\.c:\d+.*number > 0") + + +def test_assert_1(): + check(1, r"test_assert\.c:\d+.*number > 1.*\(B\) the number was 1") + + +def test_assert_2(): + check(2, r"test_assert\.c:\d+.*number > 2") + + +def test_assert_3(): + check(3, r"test_assert\.c:\d+.*number > 3.*\(A\) the number was 3") + + +def test_assert_4(): + check(4, r"test_assert\.c:\d+.*number > 4") + + +def test_assert_10(): + check(10, r"test_assert\.c:\d+.*number > 10.*\(D\) the number was 10") + + +def test_assert_11(): + check(11) diff --git a/tests/lib/test_ringbuf.c b/tests/lib/test_ringbuf.c index 7ba5a29b62..4ac62940b8 100644 --- a/tests/lib/test_ringbuf.c +++ b/tests/lib/test_ringbuf.c @@ -93,7 +93,7 @@ int main(int argc, char **argv) assert(ringbuf_get(soil, &compost, BUFSIZ) == BUFSIZ); validate_state(soil, BUFSIZ, 0); - assert(soil->empty = true); + assert(soil->empty == true); assert(soil->start == soil->end); assert(soil->start == 15); diff --git a/tests/lib/test_seqlock.c b/tests/lib/test_seqlock.c index 639c2bdc2b..768307d56d 100644 --- a/tests/lib/test_seqlock.c +++ b/tests/lib/test_seqlock.c @@ -32,6 +32,7 @@ #include "monotime.h" #include "seqlock.h" +#include "printfrr.h" static struct seqlock sqlo; static pthread_t thr1; @@ -43,7 +44,7 @@ static void writestr(const char *str) char buf[32]; int64_t usec = monotime_since(&start, NULL); - snprintf(buf, sizeof(buf), "[%02"PRId64"] ", usec / 100000); + snprintfrr(buf, sizeof(buf), "[%02" PRId64 "] ", usec / 100000); iov[0].iov_base = buf; iov[0].iov_len = strlen(buf); diff --git a/tests/subdir.am b/tests/subdir.am index ec0a154a2d..139f4878c8 100644 --- a/tests/subdir.am +++ b/tests/subdir.am @@ -66,6 +66,7 @@ clippy_scan += \ check_PROGRAMS = \ tests/lib/cxxcompat \ + tests/lib/test_assert \ tests/lib/test_atomlist \ tests/lib/test_buffer \ tests/lib/test_checksum \ @@ -249,6 +250,10 @@ tests_lib_northbound_test_oper_data_CPPFLAGS = $(TESTS_CPPFLAGS) tests_lib_northbound_test_oper_data_LDADD = $(ALL_TESTS_LDADD) tests_lib_northbound_test_oper_data_SOURCES = tests/lib/northbound/test_oper_data.c nodist_tests_lib_northbound_test_oper_data_SOURCES = yang/frr-test-module.yang.c +tests_lib_test_assert_CFLAGS = $(TESTS_CFLAGS) +tests_lib_test_assert_CPPFLAGS = $(TESTS_CPPFLAGS) +tests_lib_test_assert_LDADD = $(ALL_TESTS_LDADD) +tests_lib_test_assert_SOURCES = tests/lib/test_assert.c tests_lib_test_atomlist_CFLAGS = $(TESTS_CFLAGS) tests_lib_test_atomlist_CPPFLAGS = $(TESTS_CPPFLAGS) tests_lib_test_atomlist_LDADD = $(ALL_TESTS_LDADD) @@ -289,7 +294,7 @@ tests_lib_test_nexthop_iter_CPPFLAGS = $(TESTS_CPPFLAGS) tests_lib_test_nexthop_iter_LDADD = $(ALL_TESTS_LDADD) tests_lib_test_nexthop_iter_SOURCES = tests/lib/test_nexthop_iter.c tests/helpers/c/prng.c tests_lib_test_ntop_CFLAGS = $(TESTS_CFLAGS) -tests_lib_test_ntop_CPPFLAGS = $(TESTS_CPPFLAGS) +tests_lib_test_ntop_CPPFLAGS = $(CPPFLAGS_BASE) # no assert override tests_lib_test_ntop_LDADD = # none tests_lib_test_ntop_SOURCES = tests/lib/test_ntop.c tests/helpers/c/prng.c tests_lib_test_prefix2str_CFLAGS = $(TESTS_CFLAGS) @@ -404,6 +409,7 @@ EXTRA_DIST += \ tests/lib/northbound/test_oper_data.in \ tests/lib/northbound/test_oper_data.py \ tests/lib/northbound/test_oper_data.refout \ + tests/lib/test_assert.py \ tests/lib/test_atomlist.py \ tests/lib/test_nexthop_iter.py \ tests/lib/test_ntop.py \ diff --git a/tools/subdir.am b/tools/subdir.am index e159d82d4c..6a03a23baa 100644 --- a/tools/subdir.am +++ b/tools/subdir.am @@ -34,9 +34,11 @@ tools_gen_yang_deviations_SOURCES = tools/gen_yang_deviations.c tools_gen_yang_deviations_LDADD = lib/libfrr.la $(LIBYANG_LIBS) tools_ssd_SOURCES = tools/start-stop-daemon.c +tools_ssd_CPPFLAGS = # don't bother autoconf'ing these for a simple optional tool llvm_version = $(shell echo __clang_major__ | $(CC) -xc -P -E -) +tools_frr_llvm_cg_CPPFLAGS = $(CPPFLAGS_BASE) tools_frr_llvm_cg_CFLAGS = $(AM_CFLAGS) `llvm-config-$(llvm_version) --cflags` tools_frr_llvm_cg_LDFLAGS = `llvm-config-$(llvm_version) --ldflags --libs` tools_frr_llvm_cg_SOURCES = \ diff --git a/zebra/zebra_routemap_nb.c b/zebra/zebra_routemap_nb.c index c82c34dd53..9da4589501 100644 --- a/zebra/zebra_routemap_nb.c +++ b/zebra/zebra_routemap_nb.c @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + #include "northbound.h" #include "libfrr.h" #include "zebra_routemap_nb.h" diff --git a/zebra/zserv.c b/zebra/zserv.c index f89b6fe478..0bf4d8ece2 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -50,7 +50,6 @@ #include "lib/thread.h" /* for thread (ptr only), THREAD_ARG, ... */ #include "lib/vrf.h" /* for vrf_info_lookup, VRF_DEFAULT */ #include "lib/vty.h" /* for vty_out, vty (ptr only) */ -#include "lib/zassert.h" /* for assert */ #include "lib/zclient.h" /* for zmsghdr, ZEBRA_HEADER_SIZE, ZEBRA... */ #include "lib/frr_pthread.h" /* for frr_pthread_new, frr_pthread_stop... */ #include "lib/frratomic.h" /* for atomic_load_explicit, atomic_stor... */