diff options
author | Michael Brown <mcb30@etherboot.org> | 2009-01-31 07:32:20 +0000 |
---|---|---|
committer | Michael Brown <mcb30@etherboot.org> | 2009-01-31 07:32:20 +0000 |
commit | d2b0081740de9e31fb28f7c6761bbf78835c07d7 (patch) | |
tree | 70d98d9d5cedcde988af9bdfe4af460550491b0a /src/core | |
parent | b111bdfb000b22a41961ae9d3d2920a9c43d84f8 (diff) | |
download | ipxe-d2b0081740de9e31fb28f7c6761bbf78835c07d7.tar.gz |
[settings] Avoid duplicate settings block names
Automatically unregister any settings with the same name (and position
within the settings tree) as a newly registered settings block.
This functionality is generalised out from dhcp.c.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/settings.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/core/settings.c b/src/core/settings.c index 09033bd91..2c886fdf6 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -183,12 +183,17 @@ static void reprioritise_settings ( struct settings *settings ) { * @ret rc Return status code */ int register_settings ( struct settings *settings, struct settings *parent ) { + struct settings *old_settings; /* NULL parent => add to settings root */ assert ( settings != NULL ); if ( parent == NULL ) parent = &settings_root; + /* Remove any existing settings with the same name */ + if ( ( old_settings = find_child_settings ( parent, settings->name ) )) + unregister_settings ( old_settings ); + /* Add to list of settings */ ref_get ( settings->refcnt ); ref_get ( parent->refcnt ); |