david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[settings] Expose settings_name()

Expose settings_name(), shrink the unnecessarily large static buffer,
properly name root settings block, and simplify.

Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Glenn Brown 2011-03-22 17:49:03 +00:00 committed by Michael Brown
parent aebba8f6eb
commit f732fa28c8
2 changed files with 7 additions and 8 deletions

View File

@ -288,22 +288,20 @@ static struct settings * autovivify_child_settings ( struct settings *parent,
} }
/** /**
* Return settings block name (for debug only) * Return settings block name
* *
* @v settings Settings block * @v settings Settings block
* @ret name Settings block name * @ret name Settings block name
*/ */
static const char * settings_name ( struct settings *settings ) { const char * settings_name ( struct settings *settings ) {
static char buf[64]; static char buf[16];
char tmp[ sizeof ( buf ) ]; char tmp[ sizeof ( buf ) ];
int count;
for ( count = 0 ; settings ; settings = settings->parent ) { for ( buf[2] = buf[0] = 0 ; settings ; settings = settings->parent ) {
memcpy ( tmp, buf, sizeof ( tmp ) ); memcpy ( tmp, buf, sizeof ( tmp ) );
snprintf ( buf, sizeof ( buf ), "%s%c%s", settings->name, snprintf ( buf, sizeof ( buf ), ".%s%s", settings->name, tmp );
( count++ ? '.' : '\0' ), tmp );
} }
return ( buf + 1 ); return ( buf + 2 );
} }
/** /**

View File

@ -245,6 +245,7 @@ extern int fetch_uuid_setting ( struct settings *settings,
extern void clear_settings ( struct settings *settings ); extern void clear_settings ( struct settings *settings );
extern int setting_cmp ( struct setting *a, struct setting *b ); extern int setting_cmp ( struct setting *a, struct setting *b );
extern const char * settings_name ( struct settings *settings );
extern struct settings * find_settings ( const char *name ); extern struct settings * find_settings ( const char *name );
extern struct setting * find_setting ( const char *name ); extern struct setting * find_setting ( const char *name );