mirror of https://github.com/ipxe/ipxe.git
[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.pull/1/head
parent
b111bdfb00
commit
d2b0081740
|
@ -183,12 +183,17 @@ static void reprioritise_settings ( struct settings *settings ) {
|
||||||
* @ret rc Return status code
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int register_settings ( struct settings *settings, struct settings *parent ) {
|
int register_settings ( struct settings *settings, struct settings *parent ) {
|
||||||
|
struct settings *old_settings;
|
||||||
|
|
||||||
/* NULL parent => add to settings root */
|
/* NULL parent => add to settings root */
|
||||||
assert ( settings != NULL );
|
assert ( settings != NULL );
|
||||||
if ( parent == NULL )
|
if ( parent == NULL )
|
||||||
parent = &settings_root;
|
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 */
|
/* Add to list of settings */
|
||||||
ref_get ( settings->refcnt );
|
ref_get ( settings->refcnt );
|
||||||
ref_get ( parent->refcnt );
|
ref_get ( parent->refcnt );
|
||||||
|
|
Loading…
Reference in New Issue