summaryrefslogtreecommitdiffstats
path: root/src/core/settings.c
diff options
context:
space:
mode:
authorMichael Brown2009-01-31 08:32:20 +0100
committerMichael Brown2009-01-31 08:32:20 +0100
commitd2b0081740de9e31fb28f7c6761bbf78835c07d7 (patch)
tree70d98d9d5cedcde988af9bdfe4af460550491b0a /src/core/settings.c
parent[scsi] Cope with targets that send multiple CHECK CONDITIONS at power-on (diff)
downloadipxe-d2b0081740de9e31fb28f7c6761bbf78835c07d7.tar.gz
ipxe-d2b0081740de9e31fb28f7c6761bbf78835c07d7.tar.xz
ipxe-d2b0081740de9e31fb28f7c6761bbf78835c07d7.zip
[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/settings.c')
-rw-r--r--src/core/settings.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/core/settings.c b/src/core/settings.c
index 09033bd9..2c886fdf 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 );