]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Conf: Implicit symbols should not generate warnings when overriding keywords
authorMaria Matejka <mq@ucw.cz>
Thu, 13 Nov 2025 20:40:21 +0000 (21:40 +0100)
committerMaria Matejka <mq@ucw.cz>
Thu, 13 Nov 2025 20:40:21 +0000 (21:40 +0100)
conf/cf-lex.l
conf/conf.h
nest/rt-table.c
sysdep/unix/io-loop.c

index c47674bc7a1f5842646c3237286ec2a6f0120d32..0f1277caade5aa5093575f458746bb9191a9d8c3 100644 (file)
@@ -682,9 +682,6 @@ cf_localize_symbol(struct config *conf, struct symbol *sym)
   if (cf_symbol_is_local(conf, sym))
     cf_error("Symbol '%s' already defined", sym->name);
 
-  if (sym->class == SYM_KEYWORD)
-    cf_warn("Symbol '%s' overrides existing keyword", sym->name);
-
   /* Not allocated here yet, doing it now. */
   cf_swap_soft_scope(conf);
   return cf_new_symbol(conf->current_scope, conf->pool, conf->mem, sym->name);
index d5019398dda3fc21ef5fd88bcab1b0e0b41ddaeb..040ad5befaa7915212c260a7b95b2e52dbfc621b 100644 (file)
@@ -297,7 +297,17 @@ struct symbol *cf_root_symbol(const byte *, struct sym_scope *);
  * scope, it's the same @sym as passed to the function.
  */
 #define cf_define_symbol(conf_, osym_, type_, var_, def_) ({ \
-    struct symbol *sym_ = cf_localize_symbol(conf_, osym_); \
+    struct symbol *sym_ = osym_; \
+    if (sym_->class == SYM_KEYWORD) cf_warn("Symbol '%s' overrides existing keyword", sym_->name); \
+    sym_ = cf_localize_symbol(conf_, sym_); \
+    sym_->class = type_; \
+    sym_->var_ = def_; \
+    sym_; })
+
+#define cf_implicit_symbol(conf_, name_, type_, var_, def_) ({ \
+    struct symbol *sym_ = cf_get_symbol(conf_, name_); \
+    if (sym_->class && sym_->class != SYM_KEYWORD) bug("Implicit symbol '%s' overrides another one", sym_->name); \
+    sym_ = cf_localize_symbol(conf_, sym_); \
     sym_->class = type_; \
     sym_->var_ = def_; \
     sym_; })
index 9eab1b907e7a84964633fa4aa906e83686a1dd52..8cb052bf5849a05bd1b2819504960b83cd1addf6 100644 (file)
@@ -4076,8 +4076,8 @@ rt_preconfig(struct config *c)
 {
   init_list(&c->tables);
 
-  c->def_tables[NET_IP4] = cf_define_symbol(c, cf_get_symbol(c, "master4"), SYM_TABLE, table, NULL);
-  c->def_tables[NET_IP6] = cf_define_symbol(c, cf_get_symbol(c, "master6"), SYM_TABLE, table, NULL);
+  c->def_tables[NET_IP4] = cf_implicit_symbol(c, "master4", SYM_TABLE, table, NULL);
+  c->def_tables[NET_IP6] = cf_implicit_symbol(c, "master6", SYM_TABLE, table, NULL);
 }
 
 void
index edef74e564ff9b43b8237eba3ea493c13121e9bc..5091c73b84a78d60d091877f9ede9c4f6e894384 100644 (file)
@@ -1460,8 +1460,8 @@ thread_group_finalize_config(void)
     thread_group_config_add_tail(&new_config->thread_group, tgc);
     new_config->default_thread_group = tgc;
 
-    tgc->symbol = cf_define_symbol(
-       new_config, cf_get_symbol(new_config, "worker"),
+    tgc->symbol = cf_implicit_symbol(
+       new_config, "worker",
        SYM_THREAD_GROUP, thread_group, tgc);
 
     /* Default express thread group */
@@ -1469,8 +1469,8 @@ thread_group_finalize_config(void)
     *tgc = thread_group_config_default_express;
     thread_group_config_add_tail(&new_config->thread_group, tgc);
 
-    tgc->symbol = cf_define_symbol(
-       new_config, cf_get_symbol(new_config, "express"),
+    tgc->symbol = cf_implicit_symbol(
+       new_config, "express",
        SYM_THREAD_GROUP, thread_group, tgc);
   }