summaryrefslogtreecommitdiff
path: root/lib/frrscript.h
diff options
context:
space:
mode:
authorDonald Lee <dlqs@gmx.com>2021-07-18 06:25:54 +0800
committerDonald Lee <dlqs@gmx.com>2021-07-19 23:28:01 +0800
commit2ce634e2ad6cdfddb79e00cda01f21280d521279 (patch)
tree464be67314a491632cd13167cc10a94f85c05199 /lib/frrscript.h
parent596b44af8a51c79a7e23447c8c45baf0d6638a63 (diff)
lib: formatting
Signed-off-by: Donald Lee <dlqs@gmx.com>
Diffstat (limited to 'lib/frrscript.h')
-rw-r--r--lib/frrscript.h59
1 files changed, 30 insertions, 29 deletions
diff --git a/lib/frrscript.h b/lib/frrscript.h
index d756b49533..e76d14c1f4 100644
--- a/lib/frrscript.h
+++ b/lib/frrscript.h
@@ -146,7 +146,7 @@ void frrscript_init(const char *scriptdir);
*/
#define ENCODE_ARGS_WITH_STATE(L, value) \
_Generic((value), \
-int: lua_pushinteger, \
+int : lua_pushinteger, \
long long * : lua_pushintegerp, \
struct prefix * : lua_pushprefix, \
struct interface * : lua_pushinterface, \
@@ -180,9 +180,8 @@ const struct prefix * : lua_decode_noop \
* Call Lua function state (abstraction for a single Lua function)
*
* lfs
- * The Lua function to call; this should have been loaded in by frrscript_load().
- * nargs
- * Number of arguments the function accepts
+ * The Lua function to call; this should have been loaded in by
+ * frrscript_load(). nargs Number of arguments the function accepts
*
* Returns:
* 0 if the script ran successfully, nonzero otherwise.
@@ -201,31 +200,33 @@ int _frrscript_call_lua(struct lua_function_state *lfs, int nargs);
* Returns:
* 0 if the script ran successfully, nonzero otherwise.
*/
-#define frrscript_call(fs, f, ...) \
- ({ \
- struct lua_function_state lookup = {.name = f}; \
- struct lua_function_state *lfs; \
- lfs = hash_lookup(fs->lua_function_hash, &lookup); \
- lfs == NULL ? ({ \
- zlog_err( \
- "frrscript: '%s.lua': '%s': tried to call this function but it was not loaded", \
- fs->name, f); \
- 1; \
- }) \
- : ({ \
- MAP_LISTS(ENCODE_ARGS, ##__VA_ARGS__); \
- _frrscript_call_lua(lfs, PP_NARG(__VA_ARGS__)); \
- }) != 0 \
- ? ({ \
- zlog_err( \
- "frrscript: '%s.lua': '%s': this function called but returned non-zero exit code. No variables modified.", \
- fs->name, f); \
- 1; \
- }) \
- : ({ \
- MAP_LISTS(DECODE_ARGS, ##__VA_ARGS__); \
- 0; \
- }); \
+#define frrscript_call(fs, f, ...) \
+ ({ \
+ struct lua_function_state lookup = {.name = f}; \
+ struct lua_function_state *lfs; \
+ lfs = hash_lookup(fs->lua_function_hash, &lookup); \
+ lfs == NULL ? ({ \
+ zlog_err( \
+ "frrscript: '%s.lua': '%s': tried to call this function but it was not loaded", \
+ fs->name, f); \
+ 1; \
+ }) \
+ : ({ \
+ MAP_LISTS(ENCODE_ARGS, ##__VA_ARGS__); \
+ _frrscript_call_lua( \
+ lfs, PP_NARG(__VA_ARGS__)); \
+ }) != 0 \
+ ? ({ \
+ zlog_err( \
+ "frrscript: '%s.lua': '%s': this function called but returned non-zero exit code. No variables modified.", \
+ fs->name, f); \
+ 1; \
+ }) \
+ : ({ \
+ MAP_LISTS(DECODE_ARGS, \
+ ##__VA_ARGS__); \
+ 0; \
+ }); \
})
/*