From 2faab06ed3bfad11fceb1108614420c1b9edbd5d Mon Sep 17 00:00:00 2001 From: Donald Lee Date: Tue, 10 Aug 2021 04:36:30 +0800 Subject: [PATCH] lib: Add polymorphic noop macro Co-authored-by: Quentin Young Signed-off-by: Quentin Young Signed-off-by: Donald Lee --- lib/frrscript.c | 2 ++ lib/frrscript.h | 13 ++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/frrscript.c b/lib/frrscript.c index 50410fb58b..acdd1df67b 100644 --- a/lib/frrscript.c +++ b/lib/frrscript.c @@ -25,6 +25,8 @@ DEFINE_MTYPE_STATIC(LIB, SCRIPT, "Scripting"); struct frrscript_names_head frrscript_names_hash; +void _lua_decode_noop(lua_State *L, ...) {} + /* * Wrapper for frrscript_names_add * Use this to register hook calls when a daemon starts up diff --git a/lib/frrscript.h b/lib/frrscript.h index df49b5718c..a662a808d7 100644 --- a/lib/frrscript.h +++ b/lib/frrscript.h @@ -180,6 +180,11 @@ void frrscript_fini(void); assert(lua_gettop(lfs->L) == 1); \ } while (0) +/* + * Noop function. Used below where we need a noop decoder for any type. + */ +void _lua_decode_noop(lua_State *, ...); + /* * Maps the type of value to its encoder/decoder. * Add new mappings here. @@ -220,13 +225,7 @@ struct in6_addr * : lua_decode_in6addr, \ union sockunion * : lua_decode_sockunion, \ char * : lua_decode_stringp, \ struct attr * : lua_decode_attr, \ -struct peer * : lua_decode_noop, \ -const struct prefix * : lua_decode_noop, \ -const struct ipaddr * : lua_decode_noop, \ -const struct ethaddr * : lua_decode_noop, \ -const struct nexthop_group * : lua_decode_noop, \ -const struct nexthop * : lua_decode_noop, \ -struct zebra_dplane_ctx * : lua_decode_noop \ +default : _lua_decode_noop \ )((L), -1, (value)) /*