]> git.puffer.fish Git - matthieu/frr.git/commitdiff
lib: formatting
authorDonald Lee <dlqs@gmx.com>
Sat, 17 Jul 2021 22:25:54 +0000 (06:25 +0800)
committerDonald Lee <dlqs@gmx.com>
Mon, 19 Jul 2021 15:28:01 +0000 (23:28 +0800)
Signed-off-by: Donald Lee <dlqs@gmx.com>
bgpd/bgp_routemap.c
lib/frrscript.c
lib/frrscript.h

index 9146e90fbfcbe046e18589d33fde92d5d5d46f10..5bdc37c9adff2356decacaba19b4b6cfab79c260 100644 (file)
@@ -396,7 +396,8 @@ route_match_script(void *rule, const struct prefix *prefix, void *object)
                return RMAP_NOMATCH;
        }
 
-       long long* action = frrscript_get_result(fs, routematch_function, "action", lua_tointegerp);
+       long long *action = frrscript_get_result(fs, routematch_function,
+                                                "action", lua_tointegerp);
 
        int status = RMAP_NOMATCH;
 
index b3f8a9f6f50db455f0f6b7c37e7f8983b18b51ba..b385ad7eaa7bd2ae7051f684c7fbde97776390e3 100644 (file)
@@ -205,12 +205,12 @@ void *frrscript_get_result(struct frrscript *fs, const char *function_name,
 
        lfs = hash_lookup(fs->lua_function_hash, &lookup);
 
-       if (lfs == NULL) {
+       if (lfs == NULL)
                return NULL;
-       }
 
        /* results table is idx 1 on the stack, getfield pushes our item to idx
-        * 2*/
+        * 2
+        */
        lua_getfield(lfs->L, 1, name);
        if (lua_isnil(lfs->L, -1)) {
                lua_pop(lfs->L, 1);
@@ -259,6 +259,7 @@ int frrscript_load(struct frrscript *fs, const char *function_name,
 
        /* Set up the Lua script */
        lua_State *L = luaL_newstate();
+
        frrlua_export_logging(L);
 
        char script_name[MAXPATHLEN * 2];
index d756b49533722c2dc967242a02b87b6510539d71..e76d14c1f43e9290399504b8039fbd2f4eb9e8f9 100644 (file)
@@ -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;                                                                                                                 \
+                                       });                                                                                                                        \
        })
 
 /*