From 47dd87363292e326e971d53f4a3b9e58edb6a3c6 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Sun, 29 Nov 2020 17:43:16 -0500 Subject: [PATCH] lib: change encoder_func signature None of the core lua_push* functions return anything, and it helps to not have to wrap those when using them as function pointers for our encoder system, so change the type of our custom encoders to return void as well. Signed-off-by: Quentin Young --- lib/frrlua.c | 23 ++++++----------------- lib/frrlua.h | 12 ++++++------ lib/frrscript.h | 2 +- 3 files changed, 13 insertions(+), 24 deletions(-) diff --git a/lib/frrlua.c b/lib/frrlua.c index ac28082680..c8a04fb3dc 100644 --- a/lib/frrlua.c +++ b/lib/frrlua.c @@ -57,7 +57,7 @@ int frrlua_table_get_integer(lua_State *L, const char *key) * datatypes. */ -int lua_pushprefix(lua_State *L, const struct prefix *prefix) +void lua_pushprefix(lua_State *L, const struct prefix *prefix) { char buffer[100]; @@ -70,11 +70,9 @@ int lua_pushprefix(lua_State *L, const struct prefix *prefix) lua_setfield(L, -2, "length"); lua_pushinteger(L, prefix->family); lua_setfield(L, -2, "family"); - - return 0; } -int lua_pushinterface(lua_State *L, const struct interface *ifp) +void lua_pushinterface(lua_State *L, const struct interface *ifp) { zlog_debug("frrlua: pushing interface table"); @@ -101,11 +99,9 @@ int lua_pushinterface(lua_State *L, const struct interface *ifp) lua_setfield(L, -2, "link_ifindex"); lua_pushinteger(L, ifp->ll_type); lua_setfield(L, -2, "linklayer_type"); - - return 0; } -int lua_pushinaddr(lua_State *L, const struct in_addr *addr) +void lua_pushinaddr(lua_State *L, const struct in_addr *addr) { zlog_debug("frrlua: pushing inaddr table"); @@ -117,12 +113,10 @@ int lua_pushinaddr(lua_State *L, const struct in_addr *addr) lua_setfield(L, -2, "value"); lua_pushstring(L, buf); lua_setfield(L, -2, "string"); - - return 0; } -int lua_pushin6addr(lua_State *L, const struct in6_addr *addr) +void lua_pushin6addr(lua_State *L, const struct in6_addr *addr) { zlog_debug("frrlua: pushing in6addr table"); @@ -134,11 +128,9 @@ int lua_pushin6addr(lua_State *L, const struct in6_addr *addr) lua_setfield(L, -2, "value"); lua_pushstring(L, buf); lua_setfield(L, -2, "string"); - - return 0; } -int lua_pushsockunion(lua_State *L, const union sockunion *su) +void lua_pushsockunion(lua_State *L, const union sockunion *su) { zlog_debug("frrlua: pushing sockunion table"); @@ -151,14 +143,11 @@ int lua_pushsockunion(lua_State *L, const union sockunion *su) lua_setfield(L, -2, "value"); lua_pushstring(L, buf); lua_setfield(L, -2, "string"); - - return 0; } -int lua_pushtimet(lua_State *L, const time_t *time) +void lua_pushtimet(lua_State *L, const time_t *time) { lua_pushinteger(L, *time); - return 0; } /* diff --git a/lib/frrlua.h b/lib/frrlua.h index a411751172..8db5cec586 100644 --- a/lib/frrlua.h +++ b/lib/frrlua.h @@ -35,34 +35,34 @@ extern "C" { /* * Pushes a new table containing relevant fields from a prefix structure. */ -int lua_pushprefix(lua_State *L, const struct prefix *prefix); +void lua_pushprefix(lua_State *L, const struct prefix *prefix); /* * Pushes a new table containing relevant fields from an interface structure. */ -int lua_pushinterface(lua_State *L, const struct interface *ifp); +void lua_pushinterface(lua_State *L, const struct interface *ifp); /* * Pushes a new table containing both numeric and string representations of an * in_addr to the stack. */ -int lua_pushinaddr(lua_State *L, const struct in_addr *addr); +void lua_pushinaddr(lua_State *L, const struct in_addr *addr); /* * Pushes a new table containing both numeric and string representations of an * in6_addr to the stack. */ -int lua_pushin6addr(lua_State *L, const struct in6_addr *addr); +void lua_pushin6addr(lua_State *L, const struct in6_addr *addr); /* * Pushes a time_t to the stack. */ -int lua_pushtimet(lua_State *L, const time_t *time); +void lua_pushtimet(lua_State *L, const time_t *time); /* * Pushes a table representing a sockunion to the stack. */ -int lua_pushsockunion(lua_State *L, const union sockunion *su); +void lua_pushsockunion(lua_State *L, const union sockunion *su); /* * Retrieve an integer from table on the top of the stack. diff --git a/lib/frrscript.h b/lib/frrscript.h index 21cd352881..44067bf0b4 100644 --- a/lib/frrscript.h +++ b/lib/frrscript.h @@ -28,7 +28,7 @@ extern "C" { #define FRRSCRIPT_PATH "/etc/frr/scripts" -typedef int (*encoder_func)(lua_State *, const void *); +typedef void (*encoder_func)(lua_State *, const void *); struct frrscript { /* Script name */