summaryrefslogtreecommitdiff
path: root/filter
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2019-07-15 12:03:13 +0200
committerMaria Matejka <mq@ucw.cz>2019-07-15 12:03:13 +0200
commit547be53b8cefc6d346cf13dcedb3e527c3472b06 (patch)
treeb084823c86dd6317ced6a8b9e628cad20dd3e0a2 /filter
parentbfa15a642f8e262af5c18ba5898597a20bdf4e2f (diff)
Filter: Don't fail badly when trying to access non-existent route in config time
Diffstat (limited to 'filter')
-rw-r--r--filter/decl.m42
-rw-r--r--filter/filter.c4
2 files changed, 2 insertions, 4 deletions
diff --git a/filter/decl.m4 b/filter/decl.m4
index aa4ab576..b1cdaf0d 100644
--- a/filter/decl.m4
+++ b/filter/decl.m4
@@ -189,7 +189,7 @@ m4_define(SYMBOL, `FID_MEMBER(struct symbol *, sym, [[strcmp(f1->sym->name, f2->
m4_define(RTC, `FID_MEMBER(struct rtable_config *, rtc, [[strcmp(f1->rtc->name, f2->rtc->name)]], route table %s, item->rtc->name)')
m4_define(STATIC_ATTR, `FID_MEMBER(struct f_static_attr, sa, f1->sa.sa_code != f2->sa.sa_code,,)')
m4_define(DYNAMIC_ATTR, `FID_MEMBER(struct f_dynamic_attr, da, f1->da.ea_code != f2->da.ea_code,,)')
-m4_define(ACCESS_RTE, `NEVER_CONSTANT()')
+m4_define(ACCESS_RTE, `FID_HIC(,[[do { if (!fs->rte) runtime("No route to access"); } while (0)]],NEVER_CONSTANT())')
# 2) Code wrapping
# The code produced in 1xx temporary diversions is a raw code without
diff --git a/filter/filter.c b/filter/filter.c
index beb2457d..089618f4 100644
--- a/filter/filter.c
+++ b/filter/filter.c
@@ -210,7 +210,6 @@ interpret(struct filter_state *fs, const struct f_line *line, struct f_val *val)
#define falloc(size) lp_alloc(fs->pool, size)
#define fpool fs->pool
-#define ACCESS_RTE do { if (!fs->rte) runtime("No route to access"); } while (0)
#define ACCESS_EATTRS do { if (!fs->eattrs) f_cache_eattrs(fs); } while (0)
#include "filter/inst-interpret.c"
@@ -221,7 +220,6 @@ interpret(struct filter_state *fs, const struct f_line *line, struct f_val *val)
#undef runtime
#undef falloc
#undef fpool
-#undef ACCESS_RTE
#undef ACCESS_EATTRS
}
}
@@ -400,7 +398,7 @@ f_eval_int(const struct f_line *expr)
LOG_BUFFER_INIT(filter_state.buf);
if (interpret(&filter_state, expr, &val) > F_RETURN)
- cf_error("Runtime error while evaluating expression");
+ cf_error("Runtime error while evaluating expression; see log for details");
if (val.type != T_INT)
cf_error("Integer expression expected");