]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Filter: Removing the third argument hack
authorJan Maria Matejka <mq@ucw.cz>
Mon, 30 Apr 2018 11:29:05 +0000 (13:29 +0200)
committerJan Maria Matejka <mq@ucw.cz>
Tue, 29 May 2018 09:53:51 +0000 (11:53 +0200)
Just to make the code a bit more clean and easier to maintain.

filter/config.Y
filter/filter.c
filter/filter.h

index e01e02efaf4385c1528b06b107132ca3eeef5d5c..cf499b66adbe26008e28038b93c0066fde7a3bfd 100644 (file)
@@ -304,12 +304,10 @@ f_generate_lc(struct f_inst *t1, struct f_inst *t2, struct f_inst *t3)
   }
   else
   {
-    rv = cfg_allocz(sizeof(struct f_inst3));
-    rv->lineno = ifs->lino;
-    rv->fi_code = FI_LC_CONSTRUCT;
+    rv = f_new_inst(FI_LC_CONSTRUCT);
     rv->a1.p = t1;
     rv->a2.p = t2;
-    INST3(rv).p = t3;
+    rv->a3.p = t3;
   }
 
   return rv;
index 3d7b5c9f9101730ff8f677b39838f57e21be1c97..7117da4832c66242109f8324d1f46e3c63359501 100644 (file)
@@ -601,6 +601,8 @@ static struct tbf rl_runtime_err = TBF_DEFAULT_LOG_LIMITS;
 #define TWOARGS_C TWOARGS \
                   if (v1.type != v2.type) \
                    runtime( "Can't operate with values of incompatible types" );
+#define THREEARGS TWOARGS \
+                 ARG(v3, a3.p)
 #define ACCESS_RTE \
   do { if (!f_rte) runtime("No route to access"); } while (0)
 
@@ -628,7 +630,7 @@ static struct f_val
 interpret(struct f_inst *what)
 {
   struct symbol *sym;
-  struct f_val v1, v2, res = { .type = T_VOID }, *vp;
+  struct f_val v1, v2, v3, res = { .type = T_VOID }, *vp;
   unsigned u1, u2;
   int i;
   u32 as;
@@ -749,12 +751,7 @@ interpret(struct f_inst *what)
 
   case FI_LC_CONSTRUCT:
     {
-      TWOARGS;
-
-      /* Third argument hack */
-      struct f_val v3 = interpret(INST3(what).p);
-      if (v3.type & T_RETURN)
-       return v3;
+      THREEARGS;
 
       if ((v1.type != T_INT) || (v2.type != T_INT) || (v3.type != T_INT))
        runtime( "Can't operate with value of non-integer type in LC constructor" );
@@ -1664,9 +1661,7 @@ i_same(struct f_inst *f1, struct f_inst *f2)
   case FI_TYPE: ONEARG; break;
 
   case FI_LC_CONSTRUCT:
-    TWOARGS;
-    if (!i_same(INST3(f1).p, INST3(f2).p))
-      return 0;
+    THREEARGS;
     break;
 
   case FI_SET:
index 694bdfd74654e315d301ef7cb58088d531013d42..1e5fc8ffebae54ccb4696a062deeb25983b070b5 100644 (file)
@@ -93,6 +93,10 @@ struct f_inst {              /* Instruction */
     uint i;
     void *p;
   } a2;                        /* The second argument */
+  union {
+    int i;
+    void *p;
+  } a3;                        /* The third argument */
   int lineno;
 };
 
@@ -105,17 +109,6 @@ struct f_inst_roa_check {
   struct rtable_config *rtc;
 };
 
-struct f_inst3 {
-  struct f_inst i;
-  union {
-    int i;
-    void *p;
-  } a3;
-};
-
-#define INST3(x) (((struct f_inst3 *) x)->a3)
-
-
 struct f_prefix {
   net_addr net;
   u8 lo, hi;