]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: macro for recursive interpretation of instructions
authorJan Maria Matejka <mq@ucw.cz>
Wed, 2 May 2018 10:34:35 +0000 (12:34 +0200)
committerJan Maria Matejka <mq@ucw.cz>
Tue, 29 May 2018 10:35:06 +0000 (12:35 +0200)
filter/filter.c

index 2b22bfa3a74510559e1feeac62e1c473f59aebbb..66a9e05ee09ca5148fd691d29b1634eca4301715 100644 (file)
@@ -590,16 +590,18 @@ static struct tbf rl_runtime_err = TBF_DEFAULT_LOG_LIMITS;
     return res; \
   } while(0)
 
-#define ARG_ANY(n) \
-    v##n = interpret(what->a##n.p); \
-    if (v##n.type & T_RETURN) \
-      return v##n;
+#define ARG_ANY(n) INTERPRET(v##n, what->a##n.p)
 
 #define ARG(n,t) ARG_ANY(n) \
     if (v##n.type != t) \
       runtime("Argument %d of instruction %s must be of type %02x, got %02x", \
          n, f_instruction_name(what->fi_code), t, v##n.type);
 
+#define INTERPRET(val, what_) \
+    val = interpret(what_); \
+    if (val.type & T_RETURN) \
+      return val;
+
 #define ACCESS_RTE \
   do { if (!f_rte) runtime("No route to access"); } while (0)
 
@@ -747,7 +749,8 @@ interpret(struct f_inst *what)
       while (tt) {
        *vv = lp_alloc(f_pool, sizeof(struct f_path_mask));
        if (tt->kind == PM_ASN_EXPR) {
-         struct f_val res = interpret((struct f_inst *) tt->val);
+         struct f_val res;
+         INTERPRET(res, (struct f_inst *) tt->val);
          (*vv)->kind = PM_ASN;
          if (res.type != T_INT) {
            runtime( "Error resolving path mask template: value not an integer" );
@@ -1312,9 +1315,7 @@ interpret(struct f_inst *what)
       }
       /* It is actually possible to have t->data NULL */
 
-      res = interpret(t->data);
-      if (res.type & T_RETURN)
-       return res;
+      INTERPRET(res, t->data);
     }
     break;
   case FI_IP_MASK: /* IP.MASK(val) */