mirror of
https://github.com/ipxe/ipxe
synced 2025-12-23 05:21:49 +03:00
[settings] Apply settings block name in register_settings()
Pass the settings block name as a parameter to register_settings(), rather than defining it with settings_init() (and then possibly changing it by directly manipulating settings->name). Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
@@ -204,8 +204,7 @@ void nvo_init ( struct nvo_block *nvo, struct nvs_device *nvs,
|
||||
struct nvo_fragment *fragments, struct refcnt *refcnt ) {
|
||||
nvo->nvs = nvs;
|
||||
nvo->fragments = fragments;
|
||||
settings_init ( &nvo->settings, &nvo_settings_operations, refcnt,
|
||||
"nvo", 0 );
|
||||
settings_init ( &nvo->settings, &nvo_settings_operations, refcnt, 0 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,7 +249,7 @@ int register_nvo ( struct nvo_block *nvo, struct settings *parent ) {
|
||||
|
||||
/* Verify and register options */
|
||||
nvo_init_dhcpopts ( nvo );
|
||||
if ( ( rc = register_settings ( &nvo->settings, parent ) ) != 0 )
|
||||
if ( ( rc = register_settings ( &nvo->settings, parent, "nvo" ) ) != 0 )
|
||||
goto err_register;
|
||||
|
||||
DBGC ( nvo, "NVO %p registered\n", nvo );
|
||||
|
||||
@@ -281,9 +281,9 @@ static struct settings * autovivify_child_settings ( struct settings *parent,
|
||||
return NULL;
|
||||
}
|
||||
memcpy ( new_child->name, name, sizeof ( new_child->name ) );
|
||||
generic_settings_init ( &new_child->generic, NULL, new_child->name );
|
||||
generic_settings_init ( &new_child->generic, NULL );
|
||||
settings = &new_child->generic.settings;
|
||||
register_settings ( settings, parent );
|
||||
register_settings ( settings, parent, new_child->name );
|
||||
return settings;
|
||||
}
|
||||
|
||||
@@ -422,9 +422,11 @@ static void reprioritise_settings ( struct settings *settings ) {
|
||||
*
|
||||
* @v settings Settings block
|
||||
* @v parent Parent settings block, or NULL
|
||||
* @v name Settings block name
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
int register_settings ( struct settings *settings, struct settings *parent ) {
|
||||
int register_settings ( struct settings *settings, struct settings *parent,
|
||||
const char *name ) {
|
||||
struct settings *old_settings;
|
||||
|
||||
/* NULL parent => add to settings root */
|
||||
@@ -432,6 +434,9 @@ int register_settings ( struct settings *settings, struct settings *parent ) {
|
||||
if ( parent == NULL )
|
||||
parent = &settings_root;
|
||||
|
||||
/* Apply settings block name */
|
||||
settings->name = name;
|
||||
|
||||
/* Remove any existing settings with the same name */
|
||||
if ( ( old_settings = find_child_settings ( parent, settings->name ) ))
|
||||
unregister_settings ( old_settings );
|
||||
|
||||
Reference in New Issue
Block a user