mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-20 20:50:44 +00:00
CLEANUP: config: detect double registration of a config section
In an effort to make the config parser more robust, we should validate that everything we register is not already registered. Most cfg_register_* functions unfortunately return void and just perform a LIST_ADDQ(), so they will have to change for this. At least cfg_register_section() does perform a bit of checks and is easy to check for such errors, so let's start with this one. Future patches will definitely have to focus on the remaining functions and ensure unicity of all config parsers.
This commit is contained in:
parent
379d9c7c14
commit
5e4261b0e4
@ -9098,6 +9098,13 @@ int cfg_register_section(char *section_name,
|
||||
{
|
||||
struct cfg_section *cs;
|
||||
|
||||
list_for_each_entry(cs, §ions, list) {
|
||||
if (strcmp(cs->section_name, section_name) == 0) {
|
||||
Alert("register section '%s': already registered.\n", section_name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
cs = calloc(1, sizeof(*cs));
|
||||
if (!cs) {
|
||||
Alert("register section '%s': out of memory.\n", section_name);
|
||||
|
Loading…
Reference in New Issue
Block a user