diff options
Diffstat (limited to 'lib')
99 files changed, 341 insertions, 312 deletions
diff --git a/lib/agentx.c b/lib/agentx.c index c1ff7a61b1..b5a035ee2b 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -34,9 +34,9 @@ #include "lib_errors.h" #include "xref.h" -XREF_SETUP() +XREF_SETUP(); -DEFINE_HOOK(agentx_enabled, (), ()) +DEFINE_HOOK(agentx_enabled, (), ()); static int agentx_enabled = 0; diff --git a/lib/atomlist.h b/lib/atomlist.h index 5ca19cbcd4..c795128a34 100644 --- a/lib/atomlist.h +++ b/lib/atomlist.h @@ -123,15 +123,16 @@ struct atomlist_head { /* use as: * - * PREDECL_ATOMLIST(namelist) + * PREDECL_ATOMLIST(namelist); * struct name { * struct namelist_item nlitem; * } - * DECLARE_ATOMLIST(namelist, struct name, nlitem) + * DECLARE_ATOMLIST(namelist, struct name, nlitem); */ #define PREDECL_ATOMLIST(prefix) \ struct prefix ## _head { struct atomlist_head ah; }; \ -struct prefix ## _item { struct atomlist_item ai; }; +struct prefix ## _item { struct atomlist_item ai; }; \ +MACRO_REQUIRE_SEMICOLON() /* end */ #define INIT_ATOMLIST(var) { } @@ -171,7 +172,7 @@ macro_inline void prefix ## _fini(struct prefix##_head *h) \ assert(prefix ## _count(h) == 0); \ memset(h, 0, sizeof(*h)); \ } \ -/* ... */ +MACRO_REQUIRE_SEMICOLON() /* end */ /* add_head: * - contention on ->first pointer @@ -221,7 +222,8 @@ struct atomsort_head { #define _PREDECL_ATOMSORT(prefix) \ struct prefix ## _head { struct atomsort_head ah; }; \ -struct prefix ## _item { struct atomsort_item ai; }; +struct prefix ## _item { struct atomsort_item ai; }; \ +MACRO_REQUIRE_SEMICOLON() /* end */ #define INIT_ATOMSORT_UNIQ(var) { } #define INIT_ATOMSORT_NONUNIQ(var) { } @@ -298,7 +300,7 @@ macro_inline type *prefix ## _pop(struct prefix##_head *h) \ struct atomsort_item *p = atomsort_pop(&h->ah); \ return p ? container_of(p, type, field.ai) : NULL; \ } \ -/* ... */ +MACRO_REQUIRE_SEMICOLON() /* end */ #define PREDECL_ATOMSORT_UNIQ(prefix) \ _PREDECL_ATOMSORT(prefix) @@ -312,7 +314,7 @@ macro_inline int prefix ## __cmp(const struct atomsort_item *a, \ } \ \ _DECLARE_ATOMSORT(prefix, type, field, \ - prefix ## __cmp, prefix ## __cmp) \ + prefix ## __cmp, prefix ## __cmp); \ \ atomic_find_warn \ macro_inline type *prefix ## _find(struct prefix##_head *h, const type *item) \ @@ -325,7 +327,7 @@ macro_inline type *prefix ## _find(struct prefix##_head *h, const type *item) \ return NULL; \ return p; \ } \ -/* ... */ +MACRO_REQUIRE_SEMICOLON() /* end */ #define PREDECL_ATOMSORT_NONUNIQ(prefix) \ _PREDECL_ATOMSORT(prefix) @@ -352,8 +354,8 @@ macro_inline int prefix ## __cmp_uq(const struct atomsort_item *a, \ } \ \ _DECLARE_ATOMSORT(prefix, type, field, \ - prefix ## __cmp, prefix ## __cmp_uq) \ -/* ... */ + prefix ## __cmp, prefix ## __cmp_uq); \ +MACRO_REQUIRE_SEMICOLON() /* end */ struct atomsort_item *atomsort_add(struct atomsort_head *h, struct atomsort_item *item, int (*cmpfn)( @@ -32,7 +32,7 @@ #include "vty.h" #include "bfd.h" -DEFINE_MTYPE_STATIC(LIB, BFD_INFO, "BFD info") +DEFINE_MTYPE_STATIC(LIB, BFD_INFO, "BFD info"); static int bfd_debug = 0; static struct bfd_gbl bfd_gbl; diff --git a/lib/buffer.c b/lib/buffer.c index 42796faae8..7929b3709d 100644 --- a/lib/buffer.c +++ b/lib/buffer.c @@ -29,8 +29,8 @@ #include <stddef.h> -DEFINE_MTYPE_STATIC(LIB, BUFFER, "Buffer") -DEFINE_MTYPE_STATIC(LIB, BUFFER_DATA, "Buffer data") +DEFINE_MTYPE_STATIC(LIB, BUFFER, "Buffer"); +DEFINE_MTYPE_STATIC(LIB, BUFFER_DATA, "Buffer data"); /* Buffer master. */ struct buffer { diff --git a/lib/command.c b/lib/command.c index 6a4d504b2f..770e2fc5ac 100644 --- a/lib/command.c +++ b/lib/command.c @@ -51,8 +51,8 @@ #include "frrscript.h" -DEFINE_MTYPE_STATIC(LIB, HOST, "Host config") -DEFINE_MTYPE(LIB, COMPLETION, "Completion item") +DEFINE_MTYPE_STATIC(LIB, HOST, "Host config"); +DEFINE_MTYPE(LIB, COMPLETION, "Completion item"); #define item(x) \ { \ diff --git a/lib/command.h b/lib/command.h index 71abb20b05..14e51486ea 100644 --- a/lib/command.h +++ b/lib/command.h @@ -34,7 +34,7 @@ extern "C" { #endif -DECLARE_MTYPE(COMPLETION) +DECLARE_MTYPE(COMPLETION); /* * From RFC 1123 (Requirements for Internet Hosts), Section 2.1 on hostnames: diff --git a/lib/command_graph.c b/lib/command_graph.c index d30d9ab702..c6c3840455 100644 --- a/lib/command_graph.c +++ b/lib/command_graph.c @@ -26,11 +26,11 @@ #include "command_graph.h" -DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command Tokens") -DEFINE_MTYPE_STATIC(LIB, CMD_DESC, "Command Token Text") -DEFINE_MTYPE_STATIC(LIB, CMD_TEXT, "Command Token Help") -DEFINE_MTYPE(LIB, CMD_ARG, "Command Argument") -DEFINE_MTYPE_STATIC(LIB, CMD_VAR, "Command Argument Name") +DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command Tokens"); +DEFINE_MTYPE_STATIC(LIB, CMD_DESC, "Command Token Text"); +DEFINE_MTYPE_STATIC(LIB, CMD_TEXT, "Command Token Help"); +DEFINE_MTYPE(LIB, CMD_ARG, "Command Argument"); +DEFINE_MTYPE_STATIC(LIB, CMD_VAR, "Command Argument Name"); struct cmd_token *cmd_token_new(enum cmd_token_type type, uint8_t attr, const char *text, const char *desc) diff --git a/lib/command_graph.h b/lib/command_graph.h index 86715410ce..2754dca67d 100644 --- a/lib/command_graph.h +++ b/lib/command_graph.h @@ -37,7 +37,7 @@ extern "C" { #endif -DECLARE_MTYPE(CMD_ARG) +DECLARE_MTYPE(CMD_ARG); struct vty; diff --git a/lib/command_match.c b/lib/command_match.c index 801b05f157..e9e8466ffd 100644 --- a/lib/command_match.c +++ b/lib/command_match.c @@ -26,7 +26,7 @@ #include "command_match.h" #include "memory.h" -DEFINE_MTYPE_STATIC(LIB, CMD_MATCHSTACK, "Command Match Stack") +DEFINE_MTYPE_STATIC(LIB, CMD_MATCHSTACK, "Command Match Stack"); #ifdef TRACE_MATCHER #define TM 1 diff --git a/lib/command_parse.y b/lib/command_parse.y index 8135d02b4b..5ebc19b278 100644 --- a/lib/command_parse.y +++ b/lib/command_parse.y @@ -54,7 +54,7 @@ #include "command_graph.h" #include "log.h" - DECLARE_MTYPE(LEX) + DECLARE_MTYPE(LEX); #define YYSTYPE CMD_YYSTYPE #define YYLTYPE CMD_YYLTYPE @@ -376,7 +376,7 @@ selector: '[' selector_seq_seq ']' varname_token #undef scanner -DEFINE_MTYPE(LIB, LEX, "Lexer token (temporary)") +DEFINE_MTYPE(LIB, LEX, "Lexer token (temporary)"); void cmd_graph_parse (struct graph *graph, const struct cmd_element *cmd) diff --git a/lib/compiler.h b/lib/compiler.h index 70ef8e9bc8..b7a142bdee 100644 --- a/lib/compiler.h +++ b/lib/compiler.h @@ -21,6 +21,21 @@ extern "C" { #endif +#ifdef __cplusplus +# if __cplusplus < 201103L +# error FRRouting headers must be compiled in C++11 mode or newer +# endif +/* C++ defines static_assert(), but not _Static_assert(). C defines + * _Static_assert() and has static_assert() in <assert.h>. However, we mess + * with assert() in zassert.h so let's not include <assert.h> here. + */ +# define _Static_assert static_assert +#else +# if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L +# error FRRouting must be compiled with min. -std=gnu11 (GNU ISO C11 dialect) +# endif +#endif + /* function attributes, use like * void prototype(void) __attribute__((_CONSTRUCTOR(100))); */ @@ -121,6 +136,24 @@ extern "C" { #define macro_inline static inline __attribute__((unused)) #define macro_pure static inline __attribute__((unused, pure)) +/* if the macro ends with a function definition */ +#define MACRO_REQUIRE_SEMICOLON() \ + _Static_assert(1, "please add a semicolon after this macro") + +#if CONFDATE < 20210601 +#ifdef ENABLE_BGP_VNC +/* temporarily disabled for transition for LabN CI + * NB: it's not possible to generate a deprecation warning for this, hence + * the shortened transition period (since otherwise new uses of the old syntax + * may creep in without errors) + */ +#undef MACRO_REQUIRE_SEMICOLON +#define MACRO_REQUIRE_SEMICOLON() \ + /* nothing */ +#endif /* ENABLE_BGP_VNC */ +#else /* CONFDATE >= 20210601 */ +CPP_NOTICE("time to remove this CONFDATE block") +#endif /* variadic macros, use like: * #define V_0() ... @@ -357,10 +390,8 @@ typedef signed long long _int64_t; /* if this breaks, 128-bit machines may have entered reality (or <long long> * is something weird) */ -#if __STDC_VERSION__ >= 201112L _Static_assert(sizeof(_uint64_t) == 8 && sizeof(_int64_t) == 8, "nobody expects the spanish intquisition"); -#endif /* since we redefined int64_t, we also need to redefine PRI*64 */ #undef PRIu64 diff --git a/lib/debug.c b/lib/debug.c index 3248ceb13b..e2ba4cd4ef 100644 --- a/lib/debug.c +++ b/lib/debug.c @@ -24,7 +24,7 @@ static struct debug_cb_list_head cb_head; -DECLARE_LIST(debug_cb_list, struct debug_callbacks, item) +DECLARE_LIST(debug_cb_list, struct debug_callbacks, item); /* All code in this section should be reentrant and MT-safe */ diff --git a/lib/debug.h b/lib/debug.h index f25cd42691..a72657bdaf 100644 --- a/lib/debug.h +++ b/lib/debug.h @@ -84,7 +84,7 @@ struct debug { const char *desc; }; -PREDECL_LIST(debug_cb_list) +PREDECL_LIST(debug_cb_list); /* * Callback set for debugging code. * diff --git a/lib/defaults.h b/lib/defaults.h index 20ef28db31..55250f0f81 100644 --- a/lib/defaults.h +++ b/lib/defaults.h @@ -98,7 +98,8 @@ struct frr_default { static void _dfltinit_##varname(void) \ { \ frr_default_add(&_dflt_##varname); \ - } + } \ + MACRO_REQUIRE_SEMICOLON() /* end */ /* use: * FRR_CFG_DEFAULT_LONG(SHARP_BLUNTNESS, diff --git a/lib/distribute.c b/lib/distribute.c index 3ea60c8772..60bd0a47bb 100644 --- a/lib/distribute.c +++ b/lib/distribute.c @@ -27,10 +27,10 @@ #include "distribute.h" #include "memory.h" -DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_CTX, "Distribute ctx") -DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE, "Distribute list") -DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_IFNAME, "Dist-list ifname") -DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_NAME, "Dist-list name") +DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_CTX, "Distribute ctx"); +DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE, "Distribute list"); +DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_IFNAME, "Dist-list ifname"); +DEFINE_MTYPE_STATIC(LIB, DISTRIBUTE_NAME, "Dist-list name"); static struct list *dist_ctx_list; diff --git a/lib/elf_py.c b/lib/elf_py.c index 0d8ad76e1c..d26e443b82 100644 --- a/lib/elf_py.c +++ b/lib/elf_py.c @@ -100,7 +100,7 @@ static PyObject *refuse_new(PyTypeObject *type, PyObject *args, PyObject *kwds) struct elfreloc; struct elfsect; -PREDECL_HASH(elfrelocs) +PREDECL_HASH(elfrelocs); /* ELFFile and ELFSection intentionally share some behaviour, particularly * subscript[123:456] access to file data. This is because relocatables @@ -200,7 +200,7 @@ static int elfreloc_cmp(const struct elfreloc *a, const struct elfreloc *b); static uint32_t elfreloc_hash(const struct elfreloc *reloc); DECLARE_HASH(elfrelocs, struct elfreloc, elfrelocs_item, - elfreloc_cmp, elfreloc_hash) + elfreloc_cmp, elfreloc_hash); static Elf_Scn *elf_find_addr(struct elffile *ef, uint64_t addr, size_t *idx); static PyObject *elffile_secbyidx(struct elffile *w, Elf_Scn *scn, size_t idx); diff --git a/lib/ferr.c b/lib/ferr.c index 691da495cf..513ef5ebec 100644 --- a/lib/ferr.c +++ b/lib/ferr.c @@ -35,7 +35,7 @@ #include "linklist.h" #include "frr_pthread.h" -DEFINE_MTYPE_STATIC(LIB, ERRINFO, "error information") +DEFINE_MTYPE_STATIC(LIB, ERRINFO, "error information"); /* * Thread-specific key for temporary storage of allocated ferr. diff --git a/lib/filter.c b/lib/filter.c index f5ae9ee2b7..83423ba321 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -31,9 +31,9 @@ #include "libfrr.h" #include "northbound_cli.h" -DEFINE_MTYPE_STATIC(LIB, ACCESS_LIST, "Access List") -DEFINE_MTYPE_STATIC(LIB, ACCESS_LIST_STR, "Access List Str") -DEFINE_MTYPE_STATIC(LIB, ACCESS_FILTER, "Access Filter") +DEFINE_MTYPE_STATIC(LIB, ACCESS_LIST, "Access List"); +DEFINE_MTYPE_STATIC(LIB, ACCESS_LIST_STR, "Access List Str"); +DEFINE_MTYPE_STATIC(LIB, ACCESS_FILTER, "Access Filter"); /* Static structure for mac access_list's master. */ static struct access_master access_master_mac = { diff --git a/lib/frr_pthread.c b/lib/frr_pthread.c index 3f0179fbc1..03359f4d18 100644 --- a/lib/frr_pthread.c +++ b/lib/frr_pthread.c @@ -30,8 +30,8 @@ #include "zlog.h" #include "libfrr_trace.h" -DEFINE_MTYPE_STATIC(LIB, FRR_PTHREAD, "FRR POSIX Thread") -DEFINE_MTYPE_STATIC(LIB, PTHREAD_PRIM, "POSIX sync primitives") +DEFINE_MTYPE_STATIC(LIB, FRR_PTHREAD, "FRR POSIX Thread"); +DEFINE_MTYPE_STATIC(LIB, PTHREAD_PRIM, "POSIX sync primitives"); /* default frr_pthread start/stop routine prototypes */ static void *fpt_run(void *arg); diff --git a/lib/frr_zmq.c b/lib/frr_zmq.c index 33adcd7b80..05f0fce5fc 100644 --- a/lib/frr_zmq.c +++ b/lib/frr_zmq.c @@ -26,7 +26,7 @@ #include "log.h" #include "lib_errors.h" -DEFINE_MTYPE_STATIC(LIB, ZEROMQ_CB, "ZeroMQ callback") +DEFINE_MTYPE_STATIC(LIB, ZEROMQ_CB, "ZeroMQ callback"); /* libzmq's context */ void *frrzmq_context = NULL; diff --git a/lib/frrcu.c b/lib/frrcu.c index 7e6475b648..0e717a98a5 100644 --- a/lib/frrcu.c +++ b/lib/frrcu.c @@ -54,12 +54,12 @@ #include "seqlock.h" #include "atomlist.h" -DEFINE_MTYPE_STATIC(LIB, RCU_THREAD, "RCU thread") -DEFINE_MTYPE_STATIC(LIB, RCU_NEXT, "RCU sequence barrier") +DEFINE_MTYPE_STATIC(LIB, RCU_THREAD, "RCU thread"); +DEFINE_MTYPE_STATIC(LIB, RCU_NEXT, "RCU sequence barrier"); -DECLARE_ATOMLIST(rcu_heads, struct rcu_head, head) +DECLARE_ATOMLIST(rcu_heads, struct rcu_head, head); -PREDECL_ATOMLIST(rcu_threads) +PREDECL_ATOMLIST(rcu_threads); struct rcu_thread { struct rcu_threads_item head; @@ -70,7 +70,7 @@ struct rcu_thread { /* only accessed by thread itself, not atomic */ unsigned depth; }; -DECLARE_ATOMLIST(rcu_threads, struct rcu_thread, head) +DECLARE_ATOMLIST(rcu_threads, struct rcu_thread, head); static const struct rcu_action rcua_next = { .type = RCUA_NEXT }; static const struct rcu_action rcua_end = { .type = RCUA_END }; diff --git a/lib/frrcu.h b/lib/frrcu.h index 47751ae7df..3808259040 100644 --- a/lib/frrcu.h +++ b/lib/frrcu.h @@ -116,7 +116,7 @@ struct rcu_action { }; /* RCU cleanup function queue item */ -PREDECL_ATOMLIST(rcu_heads) +PREDECL_ATOMLIST(rcu_heads); struct rcu_head { struct rcu_heads_item head; const struct rcu_action *action; diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index a40b815caa..209765bd6f 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -34,7 +34,7 @@ #define GRAMMAR_STR "CLI grammar sandbox\n" -DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command desc") +DEFINE_MTYPE_STATIC(LIB, CMD_TOKENS, "Command desc"); /** headers **/ void grammar_sandbox_init(void); diff --git a/lib/graph.c b/lib/graph.c index 128e45c570..1cbe1b90f9 100644 --- a/lib/graph.c +++ b/lib/graph.c @@ -25,8 +25,8 @@ #include "memory.h" #include "buffer.h" -DEFINE_MTYPE_STATIC(LIB, GRAPH, "Graph") -DEFINE_MTYPE_STATIC(LIB, GRAPH_NODE, "Graph Node") +DEFINE_MTYPE_STATIC(LIB, GRAPH, "Graph"); +DEFINE_MTYPE_STATIC(LIB, GRAPH_NODE, "Graph Node"); struct graph *graph_new(void) { struct graph *graph = XCALLOC(MTYPE_GRAPH, sizeof(struct graph)); diff --git a/lib/hash.c b/lib/hash.c index ec616ee724..e9132f7907 100644 --- a/lib/hash.c +++ b/lib/hash.c @@ -31,9 +31,9 @@ #include "frr_pthread.h" #include "libfrr_trace.h" -DEFINE_MTYPE_STATIC(LIB, HASH, "Hash") -DEFINE_MTYPE_STATIC(LIB, HASH_BUCKET, "Hash Bucket") -DEFINE_MTYPE_STATIC(LIB, HASH_INDEX, "Hash Index") +DEFINE_MTYPE_STATIC(LIB, HASH, "Hash"); +DEFINE_MTYPE_STATIC(LIB, HASH_BUCKET, "Hash Bucket"); +DEFINE_MTYPE_STATIC(LIB, HASH_INDEX, "Hash Index"); static pthread_mutex_t _hashes_mtx = PTHREAD_MUTEX_INITIALIZER; static struct list *_hashes; diff --git a/lib/hook.c b/lib/hook.c index 5a8ad00d66..895243aad7 100644 --- a/lib/hook.c +++ b/lib/hook.c @@ -23,7 +23,7 @@ #include "memory.h" #include "hook.h" -DEFINE_MTYPE_STATIC(LIB, HOOK_ENTRY, "Hook entry") +DEFINE_MTYPE_STATIC(LIB, HOOK_ENTRY, "Hook entry"); void _hook_register(struct hook *hook, struct hookent *stackent, void *funcptr, void *arg, bool has_arg, struct frrmod_runtime *module, diff --git a/lib/hook.h b/lib/hook.h index bef5351e90..ff3ef29fa3 100644 --- a/lib/hook.h +++ b/lib/hook.h @@ -35,10 +35,10 @@ extern "C" { * * mydaemon.h: * #include "hook.h" - * DECLARE_HOOK (some_update_event, (struct eventinfo *info), (info)) + * DECLARE_HOOK (some_update_event, (struct eventinfo *info), (info)); * * mydaemon.c: - * DEFINE_HOOK (some_update_event, (struct eventinfo *info), (info)) + * DEFINE_HOOK (some_update_event, (struct eventinfo *info), (info)); * ... * hook_call (some_update_event, info) * @@ -184,7 +184,7 @@ extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg, #define HOOK_ADDARG(...) (hookarg , ## __VA_ARGS__) /* use in header file - declares the hook and its arguments - * usage: DECLARE_HOOK(my_hook, (int arg1, struct foo *arg2), (arg1, arg2)) + * usage: DECLARE_HOOK(my_hook, (int arg1, struct foo *arg2), (arg1, arg2)); * as above, "passlist" must use the same order and same names as "arglist" * * theoretically passlist is not neccessary, but let's keep things simple and @@ -201,7 +201,9 @@ extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg, int(*funcptr) HOOK_ADDDEF arglist) \ { \ return (void *)funcptr; \ - } + } \ + MACRO_REQUIRE_SEMICOLON() /* end */ + #define DECLARE_KOOH(hookname, arglist, passlist) \ DECLARE_HOOK(hookname, arglist, passlist) @@ -230,7 +232,8 @@ extern void _hook_unregister(struct hook *hook, void *funcptr, void *arg, hooksum += hookp.farg HOOK_ADDARG passlist; \ } \ return hooksum; \ - } + } \ + MACRO_REQUIRE_SEMICOLON() /* end */ #define DEFINE_HOOK(hookname, arglist, passlist) \ DEFINE_HOOK_INT(hookname, arglist, passlist, false) diff --git a/lib/id_alloc.c b/lib/id_alloc.c index 95096fa5f0..9179dc4299 100644 --- a/lib/id_alloc.c +++ b/lib/id_alloc.c @@ -29,13 +29,14 @@ #include <inttypes.h> -DEFINE_MTYPE_STATIC(LIB, IDALLOC_ALLOCATOR, "ID Number Allocator") -DEFINE_MTYPE_STATIC(LIB, IDALLOC_ALLOCATOR_NAME, "ID Number Allocator Name") -DEFINE_MTYPE_STATIC(LIB, IDALLOC_DIRECTORY, "ID Number Allocator Directory") +DEFINE_MTYPE_STATIC(LIB, IDALLOC_ALLOCATOR, "ID Number Allocator"); +DEFINE_MTYPE_STATIC(LIB, IDALLOC_ALLOCATOR_NAME, "ID Number Allocator Name"); +DEFINE_MTYPE_STATIC(LIB, IDALLOC_DIRECTORY, "ID Number Allocator Directory"); DEFINE_MTYPE_STATIC(LIB, IDALLOC_SUBDIRECTORY, - "ID Number Allocator Subdirectory") -DEFINE_MTYPE_STATIC(LIB, IDALLOC_PAGE, "ID Number Allocator Page") -DEFINE_MTYPE_STATIC(LIB, IDALLOC_POOL, "ID Number temporary holding pool entry") + "ID Number Allocator Subdirectory"); +DEFINE_MTYPE_STATIC(LIB, IDALLOC_PAGE, "ID Number Allocator Page"); +DEFINE_MTYPE_STATIC(LIB, IDALLOC_POOL, + "ID Number temporary holding pool entry"); #if UINT_MAX >= UINT32_MAX #define FFS32(x) ffs(x) @@ -39,11 +39,11 @@ #include "lib/if_clippy.c" #endif -DEFINE_MTYPE_STATIC(LIB, IF, "Interface") -DEFINE_MTYPE_STATIC(LIB, CONNECTED, "Connected") -DEFINE_MTYPE_STATIC(LIB, NBR_CONNECTED, "Neighbor Connected") -DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label") -DEFINE_MTYPE_STATIC(LIB, IF_LINK_PARAMS, "Informational Link Parameters") +DEFINE_MTYPE_STATIC(LIB, IF, "Interface"); +DEFINE_MTYPE_STATIC(LIB, CONNECTED, "Connected"); +DEFINE_MTYPE_STATIC(LIB, NBR_CONNECTED, "Neighbor Connected"); +DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label"); +DEFINE_MTYPE_STATIC(LIB, IF_LINK_PARAMS, "Informational Link Parameters"); static struct interface *if_lookup_by_ifindex(ifindex_t ifindex, vrf_id_t vrf_id); @@ -53,10 +53,10 @@ static int if_cmp_index_func(const struct interface *ifp1, RB_GENERATE(if_name_head, interface, name_entry, if_cmp_func); RB_GENERATE(if_index_head, interface, index_entry, if_cmp_index_func); -DEFINE_QOBJ_TYPE(interface) +DEFINE_QOBJ_TYPE(interface); -DEFINE_HOOK(if_add, (struct interface * ifp), (ifp)) -DEFINE_KOOH(if_del, (struct interface * ifp), (ifp)) +DEFINE_HOOK(if_add, (struct interface * ifp), (ifp)); +DEFINE_KOOH(if_del, (struct interface * ifp), (ifp)); static struct interface_master{ int (*create_hook)(struct interface *ifp); @@ -31,7 +31,7 @@ extern "C" { #endif -DECLARE_MTYPE(CONNECTED_LABEL) +DECLARE_MTYPE(CONNECTED_LABEL); /* Interface link-layer type, if known. Derived from: * @@ -301,14 +301,14 @@ struct interface { */ bool configured; - QOBJ_FIELDS + QOBJ_FIELDS; }; RB_HEAD(if_name_head, interface); RB_PROTOTYPE(if_name_head, interface, name_entry, if_cmp_func) RB_HEAD(if_index_head, interface); RB_PROTOTYPE(if_index_head, interface, index_entry, if_cmp_index_func) -DECLARE_QOBJ_TYPE(interface) +DECLARE_QOBJ_TYPE(interface); #define IFNAME_RB_INSERT(vrf, ifp) \ ({ \ @@ -378,8 +378,8 @@ DECLARE_QOBJ_TYPE(interface) * can use 1000+ so they run after the daemon has initialised daemon-specific * interface data */ -DECLARE_HOOK(if_add, (struct interface * ifp), (ifp)) -DECLARE_KOOH(if_del, (struct interface * ifp), (ifp)) +DECLARE_HOOK(if_add, (struct interface * ifp), (ifp)); +DECLARE_KOOH(if_del, (struct interface * ifp), (ifp)); #define METRIC_MAX (~0) diff --git a/lib/if_rmap.c b/lib/if_rmap.c index 1973d40be4..8282e476df 100644 --- a/lib/if_rmap.c +++ b/lib/if_rmap.c @@ -26,10 +26,11 @@ #include "if.h" #include "if_rmap.h" -DEFINE_MTYPE_STATIC(LIB, IF_RMAP_CTX, "Interface route map container") -DEFINE_MTYPE_STATIC(LIB, IF_RMAP_CTX_NAME, "Interface route map container name") -DEFINE_MTYPE_STATIC(LIB, IF_RMAP, "Interface route map") -DEFINE_MTYPE_STATIC(LIB, IF_RMAP_NAME, "I.f. route map name") +DEFINE_MTYPE_STATIC(LIB, IF_RMAP_CTX, "Interface route map container"); +DEFINE_MTYPE_STATIC(LIB, IF_RMAP_CTX_NAME, + "Interface route map container name"); +DEFINE_MTYPE_STATIC(LIB, IF_RMAP, "Interface route map"); +DEFINE_MTYPE_STATIC(LIB, IF_RMAP_NAME, "I.f. route map name"); static struct list *if_rmap_ctx_list; diff --git a/lib/keychain.c b/lib/keychain.c index 82fd6a65f2..db5c23b1ba 100644 --- a/lib/keychain.c +++ b/lib/keychain.c @@ -25,11 +25,11 @@ #include "linklist.h" #include "keychain.h" -DEFINE_MTYPE_STATIC(LIB, KEY, "Key") -DEFINE_MTYPE_STATIC(LIB, KEYCHAIN, "Key chain") +DEFINE_MTYPE_STATIC(LIB, KEY, "Key"); +DEFINE_MTYPE_STATIC(LIB, KEYCHAIN, "Key chain"); -DEFINE_QOBJ_TYPE(keychain) -DEFINE_QOBJ_TYPE(key) +DEFINE_QOBJ_TYPE(keychain); +DEFINE_QOBJ_TYPE(key); /* Master list of key chain. */ static struct list *keychain_list; diff --git a/lib/keychain.h b/lib/keychain.h index e5cf39f7c6..eb6d2f175e 100644 --- a/lib/keychain.h +++ b/lib/keychain.h @@ -32,9 +32,9 @@ struct keychain { struct list *key; - QOBJ_FIELDS + QOBJ_FIELDS; }; -DECLARE_QOBJ_TYPE(keychain) +DECLARE_QOBJ_TYPE(keychain); struct key_range { time_t start; @@ -51,9 +51,9 @@ struct key { struct key_range send; struct key_range accept; - QOBJ_FIELDS + QOBJ_FIELDS; }; -DECLARE_QOBJ_TYPE(key) +DECLARE_QOBJ_TYPE(key); extern void keychain_init(void); extern struct keychain *keychain_lookup(const char *); diff --git a/lib/ldp_sync.c b/lib/ldp_sync.c index c9d7eb37cf..8912d15589 100644 --- a/lib/ldp_sync.c +++ b/lib/ldp_sync.c @@ -31,7 +31,7 @@ #include "ldp_sync.h" /* Library code */ -DEFINE_MTYPE_STATIC(LIB, LDP_SYNC_INFO, "LDP SYNC info") +DEFINE_MTYPE_STATIC(LIB, LDP_SYNC_INFO, "LDP SYNC info"); /* * ldp_sync_info_create - Allocate the LDP_SYNC information diff --git a/lib/libfrr.c b/lib/libfrr.c index 51b97369c9..5b0a523fb5 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -45,10 +45,10 @@ #include "defaults.h" #include "frrscript.h" -DEFINE_HOOK(frr_late_init, (struct thread_master * tm), (tm)) -DEFINE_HOOK(frr_very_late_init, (struct thread_master * tm), (tm)) -DEFINE_KOOH(frr_early_fini, (), ()) -DEFINE_KOOH(frr_fini, (), ()) +DEFINE_HOOK(frr_late_init, (struct thread_master * tm), (tm)); +DEFINE_HOOK(frr_very_late_init, (struct thread_master * tm), (tm)); +DEFINE_KOOH(frr_early_fini, (), ()); +DEFINE_KOOH(frr_fini, (), ()); const char frr_sysconfdir[] = SYSCONFDIR; char frr_vtydir[256]; diff --git a/lib/libfrr.h b/lib/libfrr.h index 825f502bdf..db0f364986 100644 --- a/lib/libfrr.h +++ b/lib/libfrr.h @@ -124,8 +124,8 @@ struct frr_daemon_info { __VA_ARGS__}; \ FRR_COREMOD_SETUP(.name = #execname, \ .description = #execname " daemon", \ - .version = FRR_VERSION, ) \ -/* end */ + .version = FRR_VERSION, ); \ + MACRO_REQUIRE_SEMICOLON() /* end */ extern void frr_init_vtydir(void); extern void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv); @@ -141,8 +141,8 @@ extern enum frr_cli_mode frr_get_cli_mode(void); extern uint32_t frr_get_fd_limit(void); extern bool frr_is_startup_fd(int fd); -DECLARE_HOOK(frr_late_init, (struct thread_master * tm), (tm)) -DECLARE_HOOK(frr_very_late_init, (struct thread_master * tm), (tm)) +DECLARE_HOOK(frr_late_init, (struct thread_master * tm), (tm)); +DECLARE_HOOK(frr_very_late_init, (struct thread_master * tm), (tm)); extern void frr_config_fork(void); extern void frr_run(struct thread_master *master); @@ -153,10 +153,10 @@ extern bool frr_zclient_addr(struct sockaddr_storage *sa, socklen_t *sa_len, /* these two are before the protocol daemon does its own shutdown * it's named this way being the counterpart to frr_late_init */ -DECLARE_KOOH(frr_early_fini, (), ()) +DECLARE_KOOH(frr_early_fini, (), ()); extern void frr_early_fini(void); /* and these two are after the daemon did its own cleanup */ -DECLARE_KOOH(frr_fini, (), ()) +DECLARE_KOOH(frr_fini, (), ()); extern void frr_fini(void); extern char config_default[512]; diff --git a/lib/link_state.c b/lib/link_state.c index ecf0d0698d..7f0d2a1245 100644 --- a/lib/link_state.c +++ b/lib/link_state.c @@ -36,7 +36,7 @@ #include "link_state.h" /* Link State Memory allocation */ -DEFINE_MTYPE_STATIC(LIB, LS_DB, "Link State Database") +DEFINE_MTYPE_STATIC(LIB, LS_DB, "Link State Database"); /** * Link State Node management functions diff --git a/lib/link_state.h b/lib/link_state.h index 93669f5b23..f9eb59b76a 100644 --- a/lib/link_state.h +++ b/lib/link_state.h @@ -324,7 +324,7 @@ extern int ls_attributes_same(struct ls_attributes *a1, */ /* Link State Vertex structure */ -PREDECL_RBTREE_UNIQ(vertices) +PREDECL_RBTREE_UNIQ(vertices); struct ls_vertex { struct vertices_item entry; /* Entry in RB Tree */ uint64_t key; /* Unique Key identifier */ @@ -335,7 +335,7 @@ struct ls_vertex { }; /* Link State Edge structure */ -PREDECL_RBTREE_UNIQ(edges) +PREDECL_RBTREE_UNIQ(edges); struct ls_edge { struct edges_item entry; /* Entry in RB tree */ uint64_t key; /* Unique Key identifier */ @@ -345,7 +345,7 @@ struct ls_edge { }; /* Link State Subnet structure */ -PREDECL_RBTREE_UNIQ(subnets) +PREDECL_RBTREE_UNIQ(subnets); struct ls_subnet { struct subnets_item entry; /* Entry in RB tree */ struct prefix key; /* Unique Key identifier */ @@ -359,21 +359,21 @@ macro_inline int vertex_cmp(const struct ls_vertex *node1, { return (node1->key - node2->key); } -DECLARE_RBTREE_UNIQ(vertices, struct ls_vertex, entry, vertex_cmp) +DECLARE_RBTREE_UNIQ(vertices, struct ls_vertex, entry, vertex_cmp); macro_inline int edge_cmp(const struct ls_edge *edge1, const struct ls_edge *edge2) { return (edge1->key - edge2->key); } -DECLARE_RBTREE_UNIQ(edges, struct ls_edge, entry, edge_cmp) +DECLARE_RBTREE_UNIQ(edges, struct ls_edge, entry, edge_cmp); macro_inline int subnet_cmp(const struct ls_subnet *a, const struct ls_subnet *b) { return prefix_cmp(&a->key, &b->key); } -DECLARE_RBTREE_UNIQ(subnets, struct ls_subnet, entry, subnet_cmp) +DECLARE_RBTREE_UNIQ(subnets, struct ls_subnet, entry, subnet_cmp); /* Link State TED Structure */ struct ls_ted { diff --git a/lib/linklist.c b/lib/linklist.c index 43c2002231..5de6c8a817 100644 --- a/lib/linklist.c +++ b/lib/linklist.c @@ -25,8 +25,8 @@ #include "memory.h" #include "libfrr_trace.h" -DEFINE_MTYPE_STATIC(LIB, LINK_LIST, "Link List") -DEFINE_MTYPE_STATIC(LIB, LINK_NODE, "Link Node") +DEFINE_MTYPE_STATIC(LIB, LINK_LIST, "Link List"); +DEFINE_MTYPE_STATIC(LIB, LINK_NODE, "Link Node"); struct list *list_new(void) { diff --git a/lib/log_vty.c b/lib/log_vty.c index d1dcac2340..7dadca8059 100644 --- a/lib/log_vty.c +++ b/lib/log_vty.c @@ -33,7 +33,7 @@ #define ZLOG_MAXLVL(a, b) MAX(a, b) -DEFINE_HOOK(zlog_rotate, (), ()) +DEFINE_HOOK(zlog_rotate, (), ()); static const int log_default_lvl = LOG_DEBUG; diff --git a/lib/log_vty.h b/lib/log_vty.h index 16c4475467..f0fb7d3dba 100644 --- a/lib/log_vty.h +++ b/lib/log_vty.h @@ -34,7 +34,7 @@ extern void log_config_write(struct vty *vty); extern int log_level_match(const char *s); extern void log_show_syslog(struct vty *vty); -DECLARE_HOOK(zlog_rotate, (), ()) +DECLARE_HOOK(zlog_rotate, (), ()); extern void zlog_rotate(void); #ifdef __cplusplus diff --git a/lib/memory.c b/lib/memory.c index a377d3b945..0dc8e90524 100644 --- a/lib/memory.c +++ b/lib/memory.c @@ -34,8 +34,8 @@ static struct memgroup *mg_first = NULL; struct memgroup **mg_insert = &mg_first; -DEFINE_MGROUP(LIB, "libfrr") -DEFINE_MTYPE(LIB, TMP, "Temporary memory") +DEFINE_MGROUP(LIB, "libfrr"); +DEFINE_MTYPE(LIB, TMP, "Temporary memory"); static inline void mt_count_alloc(struct memtype *mt, size_t size, void *ptr) { diff --git a/lib/memory.h b/lib/memory.h index e9db12fce2..c95602f485 100644 --- a/lib/memory.h +++ b/lib/memory.h @@ -56,20 +56,20 @@ struct memgroup { /* macro usage: * * mydaemon.h - * DECLARE_MGROUP(MYDAEMON) - * DECLARE_MTYPE(MYDAEMON_COMMON) + * DECLARE_MGROUP(MYDAEMON); + * DECLARE_MTYPE(MYDAEMON_COMMON); * * mydaemon.c - * DEFINE_MGROUP(MYDAEMON, "my daemon memory") + * DEFINE_MGROUP(MYDAEMON, "my daemon memory"); * DEFINE_MTYPE(MYDAEMON, MYDAEMON_COMMON, - * "this mtype is used in multiple files in mydaemon") + * "this mtype is used in multiple files in mydaemon"); * foo = qmalloc(MTYPE_MYDAEMON_COMMON, sizeof(*foo)) * * mydaemon_io.c * bar = qmalloc(MTYPE_MYDAEMON_COMMON, sizeof(*bar)) * * DEFINE_MTYPE_STATIC(MYDAEMON, MYDAEMON_IO, - * "this mtype is used only in this file") + * "this mtype is used only in this file"); * baz = qmalloc(MTYPE_MYDAEMON_IO, sizeof(*baz)) * * Note: Naming conventions (MGROUP_ and MTYPE_ prefixes are enforced @@ -78,7 +78,7 @@ struct memgroup { * but MGROUP_* aren't. */ -#define DECLARE_MGROUP(name) extern struct memgroup _mg_##name; +#define DECLARE_MGROUP(name) extern struct memgroup _mg_##name #define _DEFINE_MGROUP(mname, desc, ...) \ struct memgroup _mg_##mname \ __attribute__((section(".data.mgroups"))) = { \ @@ -104,7 +104,7 @@ struct memgroup { _mg_##mname.next->ref = _mg_##mname.ref; \ *_mg_##mname.ref = _mg_##mname.next; \ } \ - /* end */ + MACRO_REQUIRE_SEMICOLON() /* end */ #define DEFINE_MGROUP(mname, desc) \ _DEFINE_MGROUP(mname, desc, ) @@ -112,7 +112,7 @@ struct memgroup { _DEFINE_MGROUP(mname, desc, .active_at_exit = true) #define DECLARE_MTYPE(name) \ - extern struct memtype MTYPE_##name[1]; \ + extern struct memtype MTYPE_##name[1] \ /* end */ #define DEFINE_MTYPE_ATTR(group, mname, attr, desc) \ @@ -140,7 +140,7 @@ struct memgroup { MTYPE_##mname->next->ref = MTYPE_##mname->ref; \ *MTYPE_##mname->ref = MTYPE_##mname->next; \ } \ - /* end */ + MACRO_REQUIRE_SEMICOLON() /* end */ #define DEFINE_MTYPE(group, name, desc) \ DEFINE_MTYPE_ATTR(group, name, , desc) \ @@ -150,8 +150,8 @@ struct memgroup { DEFINE_MTYPE_ATTR(group, name, static, desc) \ /* end */ -DECLARE_MGROUP(LIB) -DECLARE_MTYPE(TMP) +DECLARE_MGROUP(LIB); +DECLARE_MTYPE(TMP); extern void *qmalloc(struct memtype *mt, size_t size) diff --git a/lib/module.c b/lib/module.c index 3d299a6a2e..d2491a3479 100644 --- a/lib/module.c +++ b/lib/module.c @@ -27,8 +27,8 @@ #include "memory.h" #include "version.h" -DEFINE_MTYPE_STATIC(LIB, MODULE_LOADNAME, "Module loading name") -DEFINE_MTYPE_STATIC(LIB, MODULE_LOADARGS, "Module loading arguments") +DEFINE_MTYPE_STATIC(LIB, MODULE_LOADNAME, "Module loading name"); +DEFINE_MTYPE_STATIC(LIB, MODULE_LOADARGS, "Module loading arguments"); static struct frrmod_info frrmod_default_info = { .name = "libfrr", @@ -43,7 +43,7 @@ union _frrmod_runtime_u frrmod_default = { }, }; -XREF_SETUP() +XREF_SETUP(); // if defined(HAVE_SYS_WEAK_ALIAS_ATTRIBUTE) // union _frrmod_runtime_u _frrmod_this_module diff --git a/lib/module.h b/lib/module.h index 5d8d9cfbcc..6275877cb3 100644 --- a/lib/module.h +++ b/lib/module.h @@ -79,12 +79,13 @@ extern union _frrmod_runtime_u _frrmod_this_module; NULL, \ &_frrmod_info, \ }}; \ - XREF_SETUP() \ - /* end */ + XREF_SETUP(); \ + MACRO_REQUIRE_SEMICOLON() /* end */ #define FRR_MODULE_SETUP(...) \ - FRR_COREMOD_SETUP(__VA_ARGS__) \ - DSO_SELF struct frrmod_runtime *frr_module = &_frrmod_this_module.r; + FRR_COREMOD_SETUP(__VA_ARGS__); \ + DSO_SELF struct frrmod_runtime *frr_module = &_frrmod_this_module.r; \ + MACRO_REQUIRE_SEMICOLON() /* end */ extern struct frrmod_runtime *frrmod_list; diff --git a/lib/netns_linux.c b/lib/netns_linux.c index c688433983..cde842b88c 100644 --- a/lib/netns_linux.c +++ b/lib/netns_linux.c @@ -40,8 +40,8 @@ #include "vrf.h" #include "lib_errors.h" -DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context") -DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name") +DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context"); +DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name"); static inline int ns_compare(const struct ns *ns, const struct ns *ns2); static struct ns *ns_lookup_name_internal(const char *name); diff --git a/lib/netns_other.c b/lib/netns_other.c index 3fc4b8df4b..b6570d3b9e 100644 --- a/lib/netns_other.c +++ b/lib/netns_other.c @@ -26,8 +26,8 @@ #include "log.h" #include "memory.h" -DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context") -DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name") +DEFINE_MTYPE_STATIC(LIB, NS, "NetNS Context"); +DEFINE_MTYPE_STATIC(LIB, NS_NAME, "NetNS Name"); static inline int ns_compare(const struct ns *ns, const struct ns *ns2); diff --git a/lib/nexthop.c b/lib/nexthop.c index dd8c108205..17ef95c687 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -34,8 +34,8 @@ #include "vrf.h" #include "nexthop_group.h" -DEFINE_MTYPE_STATIC(LIB, NEXTHOP, "Nexthop") -DEFINE_MTYPE_STATIC(LIB, NH_LABEL, "Nexthop label") +DEFINE_MTYPE_STATIC(LIB, NEXTHOP, "Nexthop"); +DEFINE_MTYPE_STATIC(LIB, NH_LABEL, "Nexthop label"); static int _nexthop_labels_cmp(const struct nexthop *nh1, const struct nexthop *nh2) diff --git a/lib/nexthop_group.c b/lib/nexthop_group.c index dee98ad8d7..4fee9bde3c 100644 --- a/lib/nexthop_group.c +++ b/lib/nexthop_group.c @@ -32,7 +32,7 @@ #include "lib/nexthop_group_clippy.c" #endif -DEFINE_MTYPE_STATIC(LIB, NEXTHOP_GROUP, "Nexthop Group") +DEFINE_MTYPE_STATIC(LIB, NEXTHOP_GROUP, "Nexthop Group"); /* * Internal struct used to hold nhg config strings @@ -620,7 +620,7 @@ static void nhgc_delete(struct nexthop_group_cmd *nhgc) XFREE(MTYPE_TMP, nhgc); } -DEFINE_QOBJ_TYPE(nexthop_group_cmd) +DEFINE_QOBJ_TYPE(nexthop_group_cmd); DEFUN_NOSH(nexthop_group, nexthop_group_cmd, "nexthop-group NHGNAME", "Enter into the nexthop-group submode\n" diff --git a/lib/nexthop_group.h b/lib/nexthop_group.h index 5f7bde0def..8e75e5c6ac 100644 --- a/lib/nexthop_group.h +++ b/lib/nexthop_group.h @@ -97,12 +97,12 @@ struct nexthop_group_cmd { struct list *nhg_list; - QOBJ_FIELDS + QOBJ_FIELDS; }; RB_HEAD(nhgc_entry_head, nexthp_group_cmd); RB_PROTOTYPE(nhgc_entry_head, nexthop_group_cmd, nhgc_entry, nexthop_group_cmd_compare) -DECLARE_QOBJ_TYPE(nexthop_group_cmd) +DECLARE_QOBJ_TYPE(nexthop_group_cmd); /* * Initialize nexthop_groups. If you are interested in when diff --git a/lib/northbound.c b/lib/northbound.c index b6d3518285..27ba632c9d 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -32,9 +32,9 @@ #include "northbound_db.h" #include "frrstr.h" -DEFINE_MTYPE_STATIC(LIB, NB_NODE, "Northbound Node") -DEFINE_MTYPE_STATIC(LIB, NB_CONFIG, "Northbound Configuration") -DEFINE_MTYPE_STATIC(LIB, NB_CONFIG_ENTRY, "Northbound Configuration Entry") +DEFINE_MTYPE_STATIC(LIB, NB_NODE, "Northbound Node"); +DEFINE_MTYPE_STATIC(LIB, NB_CONFIG, "Northbound Configuration"); +DEFINE_MTYPE_STATIC(LIB, NB_CONFIG_ENTRY, "Northbound Configuration Entry"); /* Running configuration - shouldn't be modified directly. */ struct nb_config *running_config; diff --git a/lib/northbound.h b/lib/northbound.h index 3e1342f985..21aad64a09 100644 --- a/lib/northbound.h +++ b/lib/northbound.h @@ -677,9 +677,9 @@ typedef int (*nb_oper_data_cb)(const struct lys_node *snode, /* Hooks. */ DECLARE_HOOK(nb_notification_send, (const char *xpath, struct list *arguments), - (xpath, arguments)) -DECLARE_HOOK(nb_client_debug_config_write, (struct vty *vty), (vty)) -DECLARE_HOOK(nb_client_debug_set_all, (uint32_t flags, bool set), (flags, set)) + (xpath, arguments)); +DECLARE_HOOK(nb_client_debug_config_write, (struct vty *vty), (vty)); +DECLARE_HOOK(nb_client_debug_set_all, (uint32_t flags, bool set), (flags, set)); /* Northbound debugging records */ extern struct debug nb_dbg_cbs_config; diff --git a/lib/northbound_confd.c b/lib/northbound_confd.c index 8acba9fd2b..3d8771ffbc 100644 --- a/lib/northbound_confd.c +++ b/lib/northbound_confd.c @@ -32,7 +32,7 @@ #include <confd_dp.h> #include <confd_maapi.h> -DEFINE_MTYPE_STATIC(LIB, CONFD, "ConfD module") +DEFINE_MTYPE_STATIC(LIB, CONFD, "ConfD module"); static struct debug nb_dbg_client_confd = {0, "Northbound client: ConfD"}; @@ -1483,4 +1483,5 @@ static int frr_confd_module_init(void) FRR_MODULE_SETUP(.name = "frr_confd", .version = FRR_VERSION, .description = "FRR ConfD integration module", - .init = frr_confd_module_init, ) + .init = frr_confd_module_init, +); diff --git a/lib/northbound_grpc.cpp b/lib/northbound_grpc.cpp index abdae993b1..d042e15dad 100644 --- a/lib/northbound_grpc.cpp +++ b/lib/northbound_grpc.cpp @@ -1412,4 +1412,5 @@ static int frr_grpc_module_init(void) FRR_MODULE_SETUP(.name = "frr_grpc", .version = FRR_VERSION, .description = "FRR gRPC northbound module", - .init = frr_grpc_module_init, ) + .init = frr_grpc_module_init, +); diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c index c027f4de72..9fc640ceea 100644 --- a/lib/northbound_sysrepo.c +++ b/lib/northbound_sysrepo.c @@ -32,7 +32,7 @@ #include <sysrepo/values.h> #include <sysrepo/xpath.h> -DEFINE_MTYPE_STATIC(LIB, SYSREPO, "Sysrepo module") +DEFINE_MTYPE_STATIC(LIB, SYSREPO, "Sysrepo module"); static struct debug nb_dbg_client_sysrepo = {0, "Northbound client: Sysrepo"}; @@ -768,4 +768,5 @@ static int frr_sr_module_init(void) FRR_MODULE_SETUP(.name = "frr_sysrepo", .version = FRR_VERSION, .description = "FRR sysrepo integration module", - .init = frr_sr_module_init, ) + .init = frr_sr_module_init, +); diff --git a/lib/plist.c b/lib/plist.c index fe4689becd..92c8b8ee55 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -33,10 +33,10 @@ #include "plist_int.h" -DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST, "Prefix List") -DEFINE_MTYPE_STATIC(LIB, MPREFIX_LIST_STR, "Prefix List Str") -DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_ENTRY, "Prefix List Entry") -DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_TRIE, "Prefix List Trie Table") +DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST, "Prefix List"); +DEFINE_MTYPE_STATIC(LIB, MPREFIX_LIST_STR, "Prefix List Str"); +DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_ENTRY, "Prefix List Entry"); +DEFINE_MTYPE_STATIC(LIB, PREFIX_LIST_TRIE, "Prefix List Trie Table"); /* not currently changeable, code assumes bytes further down */ #define PLC_BITS 8 diff --git a/lib/prefix.c b/lib/prefix.c index 5e5c2d89a8..afc4d3d5c2 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -32,8 +32,8 @@ #include "printfrr.h" #include "vxlan.h" -DEFINE_MTYPE_STATIC(LIB, PREFIX, "Prefix") -DEFINE_MTYPE_STATIC(LIB, PREFIX_FLOWSPEC, "Prefix Flowspec") +DEFINE_MTYPE_STATIC(LIB, PREFIX, "Prefix"); +DEFINE_MTYPE_STATIC(LIB, PREFIX_FLOWSPEC, "Prefix Flowspec"); /* Maskbit. */ static const uint8_t maskbit[] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, diff --git a/lib/privs.c b/lib/privs.c index 5ca3c0d886..49761af871 100644 --- a/lib/privs.c +++ b/lib/privs.c @@ -28,7 +28,7 @@ #include "lib_errors.h" #include "lib/queue.h" -DEFINE_MTYPE_STATIC(LIB, PRIVS, "Privilege information") +DEFINE_MTYPE_STATIC(LIB, PRIVS, "Privilege information"); /* * Different capabilities/privileges apis have different characteristics: some diff --git a/lib/pullwr.c b/lib/pullwr.c index 0c326f29d4..15563d2471 100644 --- a/lib/pullwr.c +++ b/lib/pullwr.c @@ -48,8 +48,8 @@ struct pullwr { int64_t maxspin; /* PULLWR_MAXSPIN */ }; -DEFINE_MTYPE_STATIC(LIB, PULLWR_HEAD, "pull-driven write controller") -DEFINE_MTYPE_STATIC(LIB, PULLWR_BUF, "pull-driven write buffer") +DEFINE_MTYPE_STATIC(LIB, PULLWR_HEAD, "pull-driven write controller"); +DEFINE_MTYPE_STATIC(LIB, PULLWR_BUF, "pull-driven write buffer"); static int pullwr_run(struct thread *t); diff --git a/lib/qobj.c b/lib/qobj.c index cb3254cbe9..c6cb36c058 100644 --- a/lib/qobj.c +++ b/lib/qobj.c @@ -43,7 +43,7 @@ static int qobj_cmp(const struct qobj_node *na, const struct qobj_node *nb) } DECLARE_HASH(qobj_nodes, struct qobj_node, nodehash, - qobj_cmp, qobj_hash) + qobj_cmp, qobj_hash); static pthread_rwlock_t nodes_lock; static struct qobj_nodes_head nodes = { }; diff --git a/lib/qobj.h b/lib/qobj.h index 400ae0151c..5012c98d74 100644 --- a/lib/qobj.h +++ b/lib/qobj.h @@ -83,7 +83,7 @@ struct qobj_nodetype { RESERVED_SPACE_STRUCT(qobj_nodetype_capnp, capnp, 256) }; -PREDECL_HASH(qobj_nodes) +PREDECL_HASH(qobj_nodes); /* anchor to be embedded somewhere in the object's struct */ struct qobj_node { @@ -92,7 +92,7 @@ struct qobj_node { const struct qobj_nodetype *type; }; -#define QOBJ_FIELDS struct qobj_node qobj_node; +#define QOBJ_FIELDS struct qobj_node qobj_node /* call these at the end of any _create function (QOBJ_REG) * and beginning of any _destroy function (QOBJ_UNREG) */ @@ -118,16 +118,19 @@ void *qobj_get_typed(uint64_t id, const struct qobj_nodetype *type); /* type declarations */ #define DECLARE_QOBJ_TYPE(structname) \ - extern const struct qobj_nodetype qobj_t_##structname; + extern const struct qobj_nodetype qobj_t_##structname \ + /* end */ #define DEFINE_QOBJ_TYPE(structname) \ const struct qobj_nodetype qobj_t_##structname = { \ .node_member_offset = \ - (ptrdiff_t)offsetof(struct structname, qobj_node)}; + (ptrdiff_t)offsetof(struct structname, qobj_node)} \ + /* end */ #define DEFINE_QOBJ_TYPE_INIT(structname, ...) \ const struct qobj_nodetype qobj_t_##structname = { \ .node_member_offset = \ (ptrdiff_t)offsetof(struct structname, qobj_node), \ - __VA_ARGS__}; + __VA_ARGS__} \ + /* end */ /* ID dereference with typecheck. * will return NULL if id not found or wrong type. */ diff --git a/lib/resolver.c b/lib/resolver.c index c01284e29e..c2153e0a5e 100644 --- a/lib/resolver.c +++ b/lib/resolver.c @@ -21,7 +21,7 @@ #include "command.h" #include "xref.h" -XREF_SETUP() +XREF_SETUP(); struct resolver_state { ares_channel channel; diff --git a/lib/ringbuf.c b/lib/ringbuf.c index 26c4e744b4..49221e7cb3 100644 --- a/lib/ringbuf.c +++ b/lib/ringbuf.c @@ -22,7 +22,7 @@ #include "ringbuf.h" #include "memory.h" -DEFINE_MTYPE_STATIC(LIB, RINGBUFFER, "Ring buffer") +DEFINE_MTYPE_STATIC(LIB, RINGBUFFER, "Ring buffer"); struct ringbuf *ringbuf_new(size_t size) { diff --git a/lib/routemap.c b/lib/routemap.c index 7714086672..b836b55aad 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -33,17 +33,17 @@ #include "lib_errors.h" #include "table.h" -DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP, "Route map") -DEFINE_MTYPE(LIB, ROUTE_MAP_NAME, "Route map name") -DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_INDEX, "Route map index") -DEFINE_MTYPE(LIB, ROUTE_MAP_RULE, "Route map rule") -DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_RULE_STR, "Route map rule str") -DEFINE_MTYPE(LIB, ROUTE_MAP_COMPILED, "Route map compiled") -DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_DEP, "Route map dependency") -DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_DEP_DATA, "Route map dependency data") - -DEFINE_QOBJ_TYPE(route_map_index) -DEFINE_QOBJ_TYPE(route_map) +DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP, "Route map"); +DEFINE_MTYPE(LIB, ROUTE_MAP_NAME, "Route map name"); +DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_INDEX, "Route map index"); +DEFINE_MTYPE(LIB, ROUTE_MAP_RULE, "Route map rule"); +DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_RULE_STR, "Route map rule str"); +DEFINE_MTYPE(LIB, ROUTE_MAP_COMPILED, "Route map compiled"); +DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_DEP, "Route map dependency"); +DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_DEP_DATA, "Route map dependency data"); + +DEFINE_QOBJ_TYPE(route_map_index); +DEFINE_QOBJ_TYPE(route_map); #define IPv4_PREFIX_LIST "ip address prefix-list" #define IPv6_PREFIX_LIST "ipv6 address prefix-list" diff --git a/lib/routemap.h b/lib/routemap.h index 3e208c8cb5..bad3ca6d3d 100644 --- a/lib/routemap.h +++ b/lib/routemap.h @@ -32,9 +32,9 @@ extern "C" { #endif -DECLARE_MTYPE(ROUTE_MAP_NAME) -DECLARE_MTYPE(ROUTE_MAP_RULE) -DECLARE_MTYPE(ROUTE_MAP_COMPILED) +DECLARE_MTYPE(ROUTE_MAP_NAME); +DECLARE_MTYPE(ROUTE_MAP_RULE); +DECLARE_MTYPE(ROUTE_MAP_COMPILED); /* Route map's type. */ enum route_map_type { RMAP_PERMIT, RMAP_DENY, RMAP_ANY }; @@ -190,9 +190,9 @@ struct route_map_index { /* List of match/sets contexts. */ TAILQ_HEAD(, routemap_hook_context) rhclist; - QOBJ_FIELDS + QOBJ_FIELDS; }; -DECLARE_QOBJ_TYPE(route_map_index) +DECLARE_QOBJ_TYPE(route_map_index); /* Route map list structure. */ struct route_map { @@ -225,9 +225,9 @@ struct route_map { struct route_table *ipv4_prefix_table; struct route_table *ipv6_prefix_table; - QOBJ_FIELDS + QOBJ_FIELDS; }; -DECLARE_QOBJ_TYPE(route_map) +DECLARE_QOBJ_TYPE(route_map); /* Prototypes. */ extern void route_map_init(void); diff --git a/lib/routing_nb.h b/lib/routing_nb.h index ffba631a10..bdd12b262b 100644 --- a/lib/routing_nb.h +++ b/lib/routing_nb.h @@ -24,7 +24,7 @@ int routing_control_plane_protocols_control_plane_protocol_destroy( * callbacks for routing to handle configuration events * based on the control plane protocol */ -DECLARE_HOOK(routing_conf_event, (struct nb_cb_create_args *args), (args)) +DECLARE_HOOK(routing_conf_event, (struct nb_cb_create_args *args), (args)); void routing_control_plane_protocols_register_vrf_dependency(void); diff --git a/lib/routing_nb_config.c b/lib/routing_nb_config.c index 17698d2b87..f66f32015d 100644 --- a/lib/routing_nb_config.c +++ b/lib/routing_nb_config.c @@ -24,7 +24,7 @@ #include "routing_nb.h" -DEFINE_HOOK(routing_conf_event, (struct nb_cb_create_args *args), (args)) +DEFINE_HOOK(routing_conf_event, (struct nb_cb_create_args *args), (args)); /* * XPath: /frr-routing:routing/control-plane-protocols/control-plane-protocol diff --git a/lib/skiplist.c b/lib/skiplist.c index b79dfa6772..fc42857418 100644 --- a/lib/skiplist.c +++ b/lib/skiplist.c @@ -63,8 +63,8 @@ #include "lib_errors.h" #include "network.h" -DEFINE_MTYPE_STATIC(LIB, SKIP_LIST, "Skip List") -DEFINE_MTYPE_STATIC(LIB, SKIP_LIST_NODE, "Skip Node") +DEFINE_MTYPE_STATIC(LIB, SKIP_LIST, "Skip List"); +DEFINE_MTYPE_STATIC(LIB, SKIP_LIST_NODE, "Skip Node"); #define BitsInRandom 31 diff --git a/lib/smux.h b/lib/smux.h index 57128b7928..c063833e41 100644 --- a/lib/smux.h +++ b/lib/smux.h @@ -157,7 +157,7 @@ extern void oid_copy_int(oid oid[], int *val); extern void oid2string(oid oid[], int len, char *string); extern void oid_copy_str(oid oid[], const char *string, int len); -DECLARE_HOOK(agentx_enabled, (), ()) +DECLARE_HOOK(agentx_enabled, (), ()); #ifdef __cplusplus } diff --git a/lib/sockunion.c b/lib/sockunion.c index c701da1e03..d65235b41c 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -29,7 +29,7 @@ #include "lib_errors.h" #include "printfrr.h" -DEFINE_MTYPE_STATIC(LIB, SOCKUNION, "Socket union") +DEFINE_MTYPE_STATIC(LIB, SOCKUNION, "Socket union"); const char *inet_sutop(const union sockunion *su, char *str) { diff --git a/lib/spf_backoff.c b/lib/spf_backoff.c index ac6dd29f06..a273e93463 100644 --- a/lib/spf_backoff.c +++ b/lib/spf_backoff.c @@ -33,8 +33,8 @@ #include "thread.h" #include "vty.h" -DEFINE_MTYPE_STATIC(LIB, SPF_BACKOFF, "SPF backoff") -DEFINE_MTYPE_STATIC(LIB, SPF_BACKOFF_NAME, "SPF backoff name") +DEFINE_MTYPE_STATIC(LIB, SPF_BACKOFF, "SPF backoff"); +DEFINE_MTYPE_STATIC(LIB, SPF_BACKOFF_NAME, "SPF backoff name"); static bool debug_spf_backoff = false; #define backoff_debug(...) \ diff --git a/lib/srcdest_table.c b/lib/srcdest_table.c index ef82b7ac01..a115507192 100644 --- a/lib/srcdest_table.c +++ b/lib/srcdest_table.c @@ -30,7 +30,7 @@ #include "table.h" #include "printfrr.h" -DEFINE_MTYPE_STATIC(LIB, ROUTE_SRC_NODE, "Route source node") +DEFINE_MTYPE_STATIC(LIB, ROUTE_SRC_NODE, "Route source node"); /* ----- functions to manage rnodes _with_ srcdest table ----- */ struct srcdest_rnode { diff --git a/lib/stream.c b/lib/stream.c index ef73c2fdc9..904ee73b10 100644 --- a/lib/stream.c +++ b/lib/stream.c @@ -31,8 +31,8 @@ #include "frr_pthread.h" #include "lib_errors.h" -DEFINE_MTYPE_STATIC(LIB, STREAM, "Stream") -DEFINE_MTYPE_STATIC(LIB, STREAM_FIFO, "Stream FIFO") +DEFINE_MTYPE_STATIC(LIB, STREAM, "Stream"); +DEFINE_MTYPE_STATIC(LIB, STREAM_FIFO, "Stream FIFO"); /* Tests whether a position is valid */ #define GETP_VALID(S, G) ((G) <= (S)->endp) diff --git a/lib/strlcat.c b/lib/strlcat.c index 39773d9ac8..a046822a94 100644 --- a/lib/strlcat.c +++ b/lib/strlcat.c @@ -64,10 +64,8 @@ size_t strlcat(char *__restrict dest, (which the static_assert checks), then by the pigeonhole principle, the two input strings must overlap, which is undefined. */ -#if __STDC_VERSION__ >= 201112L _Static_assert(sizeof(uintptr_t) == sizeof(size_t), "theoretical maximum object size covers address space"); -#endif return dest_length + src_length; } #endif /* HAVE_STRLCAT */ diff --git a/lib/subdir.am b/lib/subdir.am index 38d1a3f773..bfd367b134 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -313,7 +313,7 @@ if SNMP lib_LTLIBRARIES += lib/libfrrsnmp.la endif -lib_libfrrsnmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu99 +lib_libfrrsnmp_la_CFLAGS = $(WERROR) $(SNMP_CFLAGS) -std=gnu11 lib_libfrrsnmp_la_LDFLAGS = -version-info 0:0:0 lib_libfrrsnmp_la_LIBADD = $(SNMP_LIBS) lib_libfrrsnmp_la_SOURCES = \ diff --git a/lib/table.c b/lib/table.c index 89e32182b5..dfd92c6189 100644 --- a/lib/table.c +++ b/lib/table.c @@ -29,8 +29,8 @@ #include "sockunion.h" #include "libfrr_trace.h" -DEFINE_MTYPE_STATIC(LIB, ROUTE_TABLE, "Route table") -DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node") +DEFINE_MTYPE_STATIC(LIB, ROUTE_TABLE, "Route table"); +DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node"); static void route_table_free(struct route_table *); @@ -41,7 +41,7 @@ static int route_table_hash_cmp(const struct route_node *a, } DECLARE_HASH(rn_hash_node, struct route_node, nodehash, route_table_hash_cmp, - prefix_hash_key) + prefix_hash_key); /* * route_table_init_with_delegate */ diff --git a/lib/table.h b/lib/table.h index 5d620d332b..7e383dce80 100644 --- a/lib/table.h +++ b/lib/table.h @@ -31,7 +31,7 @@ extern "C" { #endif -DECLARE_MTYPE(ROUTE_NODE) +DECLARE_MTYPE(ROUTE_NODE); /* * Forward declarations. @@ -59,7 +59,7 @@ struct route_table_delegate_t_ { route_table_destroy_node_func_t destroy_node; }; -PREDECL_HASH(rn_hash_node) +PREDECL_HASH(rn_hash_node); /* Routing table top structure. */ struct route_table { diff --git a/lib/termtable.c b/lib/termtable.c index b22a1ad387..ddf8822853 100644 --- a/lib/termtable.c +++ b/lib/termtable.c @@ -24,7 +24,7 @@ #include "memory.h" #include "termtable.h" -DEFINE_MTYPE_STATIC(LIB, TTABLE, "ASCII table") +DEFINE_MTYPE_STATIC(LIB, TTABLE, "ASCII table"); /* clang-format off */ const struct ttable_style ttable_styles[] = { diff --git a/lib/thread.c b/lib/thread.c index af01c75a44..866090341e 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -38,12 +38,12 @@ #include "libfrr_trace.h" #include "libfrr.h" -DEFINE_MTYPE_STATIC(LIB, THREAD, "Thread") -DEFINE_MTYPE_STATIC(LIB, THREAD_MASTER, "Thread master") -DEFINE_MTYPE_STATIC(LIB, THREAD_POLL, "Thread Poll Info") -DEFINE_MTYPE_STATIC(LIB, THREAD_STATS, "Thread stats") +DEFINE_MTYPE_STATIC(LIB, THREAD, "Thread"); +DEFINE_MTYPE_STATIC(LIB, THREAD_MASTER, "Thread master"); +DEFINE_MTYPE_STATIC(LIB, THREAD_POLL, "Thread Poll Info"); +DEFINE_MTYPE_STATIC(LIB, THREAD_STATS, "Thread stats"); -DECLARE_LIST(thread_list, struct thread, threaditem) +DECLARE_LIST(thread_list, struct thread, threaditem); struct cancel_req { int flags; @@ -68,7 +68,7 @@ static int thread_timer_cmp(const struct thread *a, const struct thread *b) return 0; } -DECLARE_HEAP(thread_timer_list, struct thread, timeritem, thread_timer_cmp) +DECLARE_HEAP(thread_timer_list, struct thread, timeritem, thread_timer_cmp); #if defined(__APPLE__) #include <mach/mach.h> diff --git a/lib/thread.h b/lib/thread.h index cdef531ad4..af68331131 100644 --- a/lib/thread.h +++ b/lib/thread.h @@ -41,8 +41,8 @@ struct rusage_t { #define GETRUSAGE(X) thread_getrusage(X) -PREDECL_LIST(thread_list) -PREDECL_HEAP(thread_timer_list) +PREDECL_LIST(thread_list); +PREDECL_HEAP(thread_timer_list); struct fd_handler { /* number of pfd that fit in the allocated space of pfds. This is a diff --git a/lib/typerb.h b/lib/typerb.h index fca45e20d1..60e6d09016 100644 --- a/lib/typerb.h +++ b/lib/typerb.h @@ -65,7 +65,8 @@ struct typed_rb_entry *typed_rb_next(const struct typed_rb_entry *rbe); #define _PREDECL_RBTREE(prefix) \ struct prefix ## _head { struct typed_rb_root rr; }; \ -struct prefix ## _item { struct typed_rb_entry re; }; +struct prefix ## _item { struct typed_rb_entry re; }; \ +MACRO_REQUIRE_SEMICOLON() /* end */ #define INIT_RBTREE_UNIQ(var) { } #define INIT_RBTREE_NONUNIQ(var) { } @@ -140,7 +141,7 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \ { \ return h->rr.count; \ } \ -/* ... */ +MACRO_REQUIRE_SEMICOLON() /* end */ #define PREDECL_RBTREE_UNIQ(prefix) \ _PREDECL_RBTREE(prefix) @@ -161,8 +162,8 @@ macro_inline const type *prefix ## _const_find(const struct prefix##_head *h, \ } \ TYPESAFE_FIND(prefix, type) \ \ -_DECLARE_RBTREE(prefix, type, field, prefix ## __cmp, prefix ## __cmp) \ -/* ... */ +_DECLARE_RBTREE(prefix, type, field, prefix ## __cmp, prefix ## __cmp); \ +MACRO_REQUIRE_SEMICOLON() /* end */ #define PREDECL_RBTREE_NONUNIQ(prefix) \ _PREDECL_RBTREE(prefix) @@ -188,8 +189,8 @@ macro_inline int prefix ## __cmp_uq(const struct typed_rb_entry *a, \ return 0; \ } \ \ -_DECLARE_RBTREE(prefix, type, field, prefix ## __cmp, prefix ## __cmp_uq) \ -/* ... */ +_DECLARE_RBTREE(prefix, type, field, prefix ## __cmp, prefix ## __cmp_uq); \ +MACRO_REQUIRE_SEMICOLON() /* end */ #ifdef __cplusplus } diff --git a/lib/typesafe.c b/lib/typesafe.c index 69796e2d81..76705fad0d 100644 --- a/lib/typesafe.c +++ b/lib/typesafe.c @@ -25,9 +25,9 @@ #include "memory.h" #include "network.h" -DEFINE_MTYPE_STATIC(LIB, TYPEDHASH_BUCKET, "Typed-hash bucket") -DEFINE_MTYPE_STATIC(LIB, SKIPLIST_OFLOW, "Skiplist overflow") -DEFINE_MTYPE_STATIC(LIB, HEAP_ARRAY, "Typed-heap array") +DEFINE_MTYPE_STATIC(LIB, TYPEDHASH_BUCKET, "Typed-hash bucket"); +DEFINE_MTYPE_STATIC(LIB, SKIPLIST_OFLOW, "Skiplist overflow"); +DEFINE_MTYPE_STATIC(LIB, HEAP_ARRAY, "Typed-heap array"); #if 0 static void hash_consistency_check(struct thash_head *head) diff --git a/lib/typesafe.h b/lib/typesafe.h index e134316dd9..27e7be1286 100644 --- a/lib/typesafe.h +++ b/lib/typesafe.h @@ -105,15 +105,16 @@ static inline void typesafe_list_add(struct slist_head *head, /* use as: * - * PREDECL_LIST(namelist) + * PREDECL_LIST(namelist); * struct name { * struct namelist_item nlitem; * } - * DECLARE_LIST(namelist, struct name, nlitem) + * DECLARE_LIST(namelist, struct name, nlitem); */ #define PREDECL_LIST(prefix) \ struct prefix ## _head { struct slist_head sh; }; \ -struct prefix ## _item { struct slist_item si; }; +struct prefix ## _item { struct slist_item si; }; \ +MACRO_REQUIRE_SEMICOLON() /* end */ #define INIT_LIST(var) { .sh = { .last_next = &var.sh.first, }, } @@ -191,7 +192,7 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \ { \ return h->sh.count; \ } \ -/* ... */ +MACRO_REQUIRE_SEMICOLON() /* end */ /* don't use these structs directly */ struct dlist_item { @@ -218,7 +219,8 @@ static inline void typesafe_dlist_add(struct dlist_head *head, */ #define PREDECL_DLIST(prefix) \ struct prefix ## _head { struct dlist_head dh; }; \ -struct prefix ## _item { struct dlist_item di; }; +struct prefix ## _item { struct dlist_item di; }; \ +MACRO_REQUIRE_SEMICOLON() /* end */ #define INIT_DLIST(var) { .dh = { \ .hitem = { &var.dh.hitem, &var.dh.hitem }, }, } @@ -295,7 +297,7 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \ { \ return h->dh.count; \ } \ -/* ... */ +MACRO_REQUIRE_SEMICOLON() /* end */ /* note: heap currently caps out at 4G items */ @@ -319,7 +321,8 @@ struct heap_head { #define PREDECL_HEAP(prefix) \ struct prefix ## _head { struct heap_head hh; }; \ -struct prefix ## _item { struct heap_item hi; }; +struct prefix ## _item { struct heap_item hi; }; \ +MACRO_REQUIRE_SEMICOLON() /* end */ #define INIT_HEAP(var) { } @@ -402,7 +405,7 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \ { \ return h->hh.count; \ } \ -/* ... */ +MACRO_REQUIRE_SEMICOLON() /* end */ extern void typesafe_heap_resize(struct heap_head *head, bool grow); extern void typesafe_heap_pushdown(struct heap_head *head, uint32_t index, @@ -438,7 +441,8 @@ struct ssort_head { */ #define _PREDECL_SORTLIST(prefix) \ struct prefix ## _head { struct ssort_head sh; }; \ -struct prefix ## _item { struct ssort_item si; }; +struct prefix ## _item { struct ssort_item si; }; \ +MACRO_REQUIRE_SEMICOLON() /* end */ #define INIT_SORTLIST_UNIQ(var) { } #define INIT_SORTLIST_NONUNIQ(var) { } @@ -537,10 +541,10 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \ { \ return h->sh.count; \ } \ -/* ... */ +MACRO_REQUIRE_SEMICOLON() /* end */ #define DECLARE_SORTLIST_UNIQ(prefix, type, field, cmpfn) \ - _DECLARE_SORTLIST(prefix, type, field, cmpfn, cmpfn) \ + _DECLARE_SORTLIST(prefix, type, field, cmpfn, cmpfn); \ \ macro_inline const type *prefix ## _const_find(const struct prefix##_head *h, \ const type *item) \ @@ -555,7 +559,7 @@ macro_inline const type *prefix ## _const_find(const struct prefix##_head *h, \ return container_of(sitem, type, field.si); \ } \ TYPESAFE_FIND(prefix, type) \ -/* ... */ +MACRO_REQUIRE_SEMICOLON() /* end */ #define DECLARE_SORTLIST_NONUNIQ(prefix, type, field, cmpfn) \ macro_inline int _ ## prefix ## _cmp(const type *a, const type *b) \ @@ -569,8 +573,8 @@ macro_inline int _ ## prefix ## _cmp(const type *a, const type *b) \ return 1; \ return 0; \ } \ - _DECLARE_SORTLIST(prefix, type, field, cmpfn, _ ## prefix ## _cmp) \ -/* ... */ + _DECLARE_SORTLIST(prefix, type, field, cmpfn, _ ## prefix ## _cmp); \ +MACRO_REQUIRE_SEMICOLON() /* end */ /* hash, "sorted" by hash value @@ -616,7 +620,8 @@ extern void typesafe_hash_shrink(struct thash_head *head); */ #define PREDECL_HASH(prefix) \ struct prefix ## _head { struct thash_head hh; }; \ -struct prefix ## _item { struct thash_item hi; }; +struct prefix ## _item { struct thash_item hi; }; \ +MACRO_REQUIRE_SEMICOLON() /* end */ #define INIT_HASH(var) { } @@ -734,7 +739,7 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \ { \ return h->hh.count; \ } \ -/* ... */ +MACRO_REQUIRE_SEMICOLON() /* end */ /* skiplist, sorted. * can be used as priority queue with add / pop @@ -769,7 +774,8 @@ struct sskip_head { */ #define _PREDECL_SKIPLIST(prefix) \ struct prefix ## _head { struct sskip_head sh; }; \ -struct prefix ## _item { struct sskip_item si; }; +struct prefix ## _item { struct sskip_item si; }; \ +MACRO_REQUIRE_SEMICOLON() /* end */ #define INIT_SKIPLIST_UNIQ(var) { } #define INIT_SKIPLIST_NONUNIQ(var) { } @@ -840,7 +846,7 @@ macro_pure size_t prefix ## _count(const struct prefix##_head *h) \ { \ return h->sh.count; \ } \ -/* ... */ +MACRO_REQUIRE_SEMICOLON() /* end */ #define PREDECL_SKIPLIST_UNIQ(prefix) \ _PREDECL_SKIPLIST(prefix) @@ -862,8 +868,8 @@ macro_inline const type *prefix ## _const_find(const struct prefix##_head *h, \ TYPESAFE_FIND(prefix, type) \ \ _DECLARE_SKIPLIST(prefix, type, field, \ - prefix ## __cmp, prefix ## __cmp) \ -/* ... */ + prefix ## __cmp, prefix ## __cmp); \ +MACRO_REQUIRE_SEMICOLON() /* end */ #define PREDECL_SKIPLIST_NONUNIQ(prefix) \ _PREDECL_SKIPLIST(prefix) @@ -890,8 +896,8 @@ macro_inline int prefix ## __cmp_uq(const struct sskip_item *a, \ } \ \ _DECLARE_SKIPLIST(prefix, type, field, \ - prefix ## __cmp, prefix ## __cmp_uq) \ -/* ... */ + prefix ## __cmp, prefix ## __cmp_uq); \ +MACRO_REQUIRE_SEMICOLON() /* end */ extern struct sskip_item *typesafe_skiplist_add(struct sskip_head *head, diff --git a/lib/vector.c b/lib/vector.c index 0631e836f6..565c49fd59 100644 --- a/lib/vector.c +++ b/lib/vector.c @@ -23,8 +23,8 @@ #include "vector.h" #include "memory.h" -DEFINE_MTYPE_STATIC(LIB, VECTOR, "Vector") -DEFINE_MTYPE_STATIC(LIB, VECTOR_INDEX, "Vector index") +DEFINE_MTYPE_STATIC(LIB, VECTOR, "Vector"); +DEFINE_MTYPE_STATIC(LIB, VECTOR_INDEX, "Vector index"); /* Initialize vector : allocate memory and return vector. */ vector vector_init(unsigned int size) @@ -42,10 +42,10 @@ /* default VRF name value used when VRF backend is not NETNS */ #define VRF_DEFAULT_NAME_INTERNAL "default" -DEFINE_MTYPE_STATIC(LIB, VRF, "VRF") -DEFINE_MTYPE_STATIC(LIB, VRF_BITMAP, "VRF bit-map") +DEFINE_MTYPE_STATIC(LIB, VRF, "VRF"); +DEFINE_MTYPE_STATIC(LIB, VRF_BITMAP, "VRF bit-map"); -DEFINE_QOBJ_TYPE(vrf) +DEFINE_QOBJ_TYPE(vrf); static __inline int vrf_id_compare(const struct vrf *, const struct vrf *); static __inline int vrf_name_compare(const struct vrf *, const struct vrf *); @@ -95,13 +95,13 @@ struct vrf { /* Back pointer to namespace context */ void *ns_ctxt; - QOBJ_FIELDS + QOBJ_FIELDS; }; RB_HEAD(vrf_id_head, vrf); RB_PROTOTYPE(vrf_id_head, vrf, id_entry, vrf_id_compare) RB_HEAD(vrf_name_head, vrf); RB_PROTOTYPE(vrf_name_head, vrf, name_entry, vrf_name_compare) -DECLARE_QOBJ_TYPE(vrf) +DECLARE_QOBJ_TYPE(vrf); /* Allow VRF with netns as backend */ enum vrf_backend_type { @@ -56,9 +56,9 @@ #include "lib/vty_clippy.c" #endif -DEFINE_MTYPE_STATIC(LIB, VTY, "VTY") -DEFINE_MTYPE_STATIC(LIB, VTY_OUT_BUF, "VTY output buffer") -DEFINE_MTYPE_STATIC(LIB, VTY_HIST, "VTY history") +DEFINE_MTYPE_STATIC(LIB, VTY, "VTY"); +DEFINE_MTYPE_STATIC(LIB, VTY_OUT_BUF, "VTY output buffer"); +DEFINE_MTYPE_STATIC(LIB, VTY_HIST, "VTY history"); /* Vty events */ enum event { diff --git a/lib/wheel.c b/lib/wheel.c index 5bdd6292f9..1a0469b256 100644 --- a/lib/wheel.c +++ b/lib/wheel.c @@ -24,8 +24,8 @@ #include "wheel.h" #include "log.h" -DEFINE_MTYPE_STATIC(LIB, TIMER_WHEEL, "Timer Wheel") -DEFINE_MTYPE_STATIC(LIB, TIMER_WHEEL_LIST, "Timer Wheel Slot List") +DEFINE_MTYPE_STATIC(LIB, TIMER_WHEEL, "Timer Wheel"); +DEFINE_MTYPE_STATIC(LIB, TIMER_WHEEL_LIST, "Timer Wheel Slot List"); static int debug_timer_wheel = 0; diff --git a/lib/workqueue.c b/lib/workqueue.c index 8eabdf52e7..2a8326c056 100644 --- a/lib/workqueue.c +++ b/lib/workqueue.c @@ -28,9 +28,9 @@ #include "command.h" #include "log.h" -DEFINE_MTYPE(LIB, WORK_QUEUE, "Work queue") -DEFINE_MTYPE_STATIC(LIB, WORK_QUEUE_ITEM, "Work queue item") -DEFINE_MTYPE_STATIC(LIB, WORK_QUEUE_NAME, "Work queue name string") +DEFINE_MTYPE(LIB, WORK_QUEUE, "Work queue"); +DEFINE_MTYPE_STATIC(LIB, WORK_QUEUE_ITEM, "Work queue item"); +DEFINE_MTYPE_STATIC(LIB, WORK_QUEUE_NAME, "Work queue name string"); /* master list of work_queues */ static struct list _work_queues; diff --git a/lib/workqueue.h b/lib/workqueue.h index 7c610f5dd6..b076ed0d28 100644 --- a/lib/workqueue.h +++ b/lib/workqueue.h @@ -30,7 +30,7 @@ extern "C" { #endif -DECLARE_MTYPE(WORK_QUEUE) +DECLARE_MTYPE(WORK_QUEUE); /* Hold time for the initial schedule of a queue run, in millisec */ #define WORK_QUEUE_DEFAULT_HOLD 50 diff --git a/lib/xref.h b/lib/xref.h index b3243fa058..b1cb172b41 100644 --- a/lib/xref.h +++ b/lib/xref.h @@ -162,7 +162,7 @@ extern const struct xref * const __stop_xref_array[1] DSO_LOCAL; xref_block_add(&_xref_block); \ } \ asm(XREF_NOTE); \ - /* end */ + MACRO_REQUIRE_SEMICOLON() /* end */ /* the following blurb emits an ELF note indicating start and end of the xref * array in the binary. This is technically the "correct" entry point for diff --git a/lib/yang.c b/lib/yang.c index 383dc9f5eb..df3b07fb09 100644 --- a/lib/yang.c +++ b/lib/yang.c @@ -27,8 +27,8 @@ #include <libyang/user_types.h> -DEFINE_MTYPE_STATIC(LIB, YANG_MODULE, "YANG module") -DEFINE_MTYPE_STATIC(LIB, YANG_DATA, "YANG data structure") +DEFINE_MTYPE_STATIC(LIB, YANG_MODULE, "YANG module"); +DEFINE_MTYPE_STATIC(LIB, YANG_DATA, "YANG data structure"); /* libyang container. */ struct ly_ctx *ly_native_ctx; diff --git a/lib/yang_translator.c b/lib/yang_translator.c index 1f64675d6a..5b1d96f24c 100644 --- a/lib/yang_translator.c +++ b/lib/yang_translator.c @@ -26,9 +26,9 @@ #include "yang_translator.h" #include "frrstr.h" -DEFINE_MTYPE_STATIC(LIB, YANG_TRANSLATOR, "YANG Translator") -DEFINE_MTYPE_STATIC(LIB, YANG_TRANSLATOR_MODULE, "YANG Translator Module") -DEFINE_MTYPE_STATIC(LIB, YANG_TRANSLATOR_MAPPING, "YANG Translator Mapping") +DEFINE_MTYPE_STATIC(LIB, YANG_TRANSLATOR, "YANG Translator"); +DEFINE_MTYPE_STATIC(LIB, YANG_TRANSLATOR_MODULE, "YANG Translator Module"); +DEFINE_MTYPE_STATIC(LIB, YANG_TRANSLATOR_MAPPING, "YANG Translator Mapping"); /* Generate the yang_translators tree. */ static inline int yang_translator_compare(const struct yang_translator *a, diff --git a/lib/zassert.h b/lib/zassert.h index e6b254ee8d..527282c4f2 100644 --- a/lib/zassert.h +++ b/lib/zassert.h @@ -28,14 +28,7 @@ extern void _zlog_assert_failed(const char *assertion, const char *file, __attribute__((noreturn)); #undef __ASSERT_FUNCTION - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L #define __ASSERT_FUNCTION __func__ -#elif defined(__GNUC__) -#define __ASSERT_FUNCTION __FUNCTION__ -#else -#define __ASSERT_FUNCTION NULL -#endif #define zassert(EX) \ ((void)((EX) ? 0 : (_zlog_assert_failed(#EX, __FILE__, __LINE__, \ diff --git a/lib/zclient.c b/lib/zclient.c index c5e844933c..c78937c1ec 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -42,8 +42,8 @@ #include "srte.h" #include "printfrr.h" -DEFINE_MTYPE_STATIC(LIB, ZCLIENT, "Zclient") -DEFINE_MTYPE_STATIC(LIB, REDIST_INST, "Redistribution instance IDs") +DEFINE_MTYPE_STATIC(LIB, ZCLIENT, "Zclient"); +DEFINE_MTYPE_STATIC(LIB, REDIST_INST, "Redistribution instance IDs"); /* Zebra client events. */ enum event { ZCLIENT_SCHEDULE, ZCLIENT_READ, ZCLIENT_CONNECT }; diff --git a/lib/zebra.h b/lib/zebra.h index ded44ac636..5c3d91ba74 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -80,21 +80,6 @@ /* misc include group */ #include <stdarg.h> -#if !(defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) -/* Not C99; do we need to define va_copy? */ -#ifndef va_copy -#ifdef __va_copy -#define va_copy(DST,SRC) __va_copy(DST,SRC) -#else -/* Now we are desperate; this should work on many typical platforms. - But this is slightly dangerous, because the standard does not require - va_copy to be a macro. */ -#define va_copy(DST,SRC) memcpy(&(DST), &(SRC), sizeof(va_list)) -#warning "Not C99 and no va_copy macro available, falling back to memcpy" -#endif /* __va_copy */ -#endif /* !va_copy */ -#endif /* !C99 */ - #ifdef HAVE_LCAPS #include <sys/capability.h> diff --git a/lib/zlog.c b/lib/zlog.c index 51509e24f4..7304854648 100644 --- a/lib/zlog.c +++ b/lib/zlog.c @@ -54,15 +54,15 @@ #include "zlog.h" #include "libfrr_trace.h" -DEFINE_MTYPE_STATIC(LIB, LOG_MESSAGE, "log message") -DEFINE_MTYPE_STATIC(LIB, LOG_TLSBUF, "log thread-local buffer") +DEFINE_MTYPE_STATIC(LIB, LOG_MESSAGE, "log message"); +DEFINE_MTYPE_STATIC(LIB, LOG_TLSBUF, "log thread-local buffer"); DEFINE_HOOK(zlog_init, (const char *progname, const char *protoname, unsigned short instance, uid_t uid, gid_t gid), - (progname, protoname, instance, uid, gid)) -DEFINE_KOOH(zlog_fini, (), ()) + (progname, protoname, instance, uid, gid)); +DEFINE_KOOH(zlog_fini, (), ()); DEFINE_HOOK(zlog_aux_init, (const char *prefix, int prio_min), - (prefix, prio_min)) + (prefix, prio_min)); char zlog_prefix[128]; size_t zlog_prefixsz; diff --git a/lib/zlog.h b/lib/zlog.h index 4fdb47bb95..140392bae6 100644 --- a/lib/zlog.h +++ b/lib/zlog.h @@ -203,7 +203,7 @@ extern size_t zlog_msg_ts(struct zlog_msg *msg, char *out, size_t outsz, * additional options. It MUST be the first field in that larger struct. */ -PREDECL_ATOMLIST(zlog_targets) +PREDECL_ATOMLIST(zlog_targets); struct zlog_target { struct zlog_targets_item head; @@ -247,17 +247,17 @@ extern void zlog_init(const char *progname, const char *protoname, unsigned short instance, uid_t uid, gid_t gid); DECLARE_HOOK(zlog_init, (const char *progname, const char *protoname, unsigned short instance, uid_t uid, gid_t gid), - (progname, protoname, instance, uid, gid)) + (progname, protoname, instance, uid, gid)); extern void zlog_fini(void); -DECLARE_KOOH(zlog_fini, (), ()) +DECLARE_KOOH(zlog_fini, (), ()); /* for tools & test programs, i.e. anything not a daemon. * (no cleanup needed at exit) */ extern void zlog_aux_init(const char *prefix, int prio_min); DECLARE_HOOK(zlog_aux_init, (const char *prefix, int prio_min), - (prefix, prio_min)) + (prefix, prio_min)); extern void zlog_startup_end(void); diff --git a/lib/zlog_targets.c b/lib/zlog_targets.c index 8f4c2a46a8..f258a8fbbd 100644 --- a/lib/zlog_targets.c +++ b/lib/zlog_targets.c @@ -31,13 +31,13 @@ * absolute end. */ -DECLARE_MGROUP(LOG) -DEFINE_MGROUP_ACTIVEATEXIT(LOG, "logging subsystem") +DECLARE_MGROUP(LOG); +DEFINE_MGROUP_ACTIVEATEXIT(LOG, "logging subsystem"); -DEFINE_MTYPE_STATIC(LOG, LOG_FD, "log file target") -DEFINE_MTYPE_STATIC(LOG, LOG_FD_NAME, "log file name") -DEFINE_MTYPE_STATIC(LOG, LOG_FD_ROTATE, "log file rotate helper") -DEFINE_MTYPE_STATIC(LOG, LOG_SYSL, "syslog target") +DEFINE_MTYPE_STATIC(LOG, LOG_FD, "log file target"); +DEFINE_MTYPE_STATIC(LOG, LOG_FD_NAME, "log file name"); +DEFINE_MTYPE_STATIC(LOG, LOG_FD_ROTATE, "log file rotate helper"); +DEFINE_MTYPE_STATIC(LOG, LOG_SYSL, "syslog target"); struct zlt_fd { struct zlog_target zt; |
