From: Maria Matejka Date: Thu, 13 Nov 2025 20:40:21 +0000 (+0100) Subject: Conf: Implicit symbols should not generate warnings when overriding keywords X-Git-Tag: v3.2.0~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f50c0f7da08c8eeeb002d00d9801cf8c37cb36fd;p=thirdparty%2Fbird.git Conf: Implicit symbols should not generate warnings when overriding keywords --- diff --git a/conf/cf-lex.l b/conf/cf-lex.l index c47674bc7..0f1277caa 100644 --- a/conf/cf-lex.l +++ b/conf/cf-lex.l @@ -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); diff --git a/conf/conf.h b/conf/conf.h index d5019398d..040ad5bef 100644 --- a/conf/conf.h +++ b/conf/conf.h @@ -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_; }) diff --git a/nest/rt-table.c b/nest/rt-table.c index 9eab1b907..8cb052bf5 100644 --- a/nest/rt-table.c +++ b/nest/rt-table.c @@ -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 diff --git a/sysdep/unix/io-loop.c b/sysdep/unix/io-loop.c index edef74e56..5091c73b8 100644 --- a/sysdep/unix/io-loop.c +++ b/sysdep/unix/io-loop.c @@ -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); }