diff options
author | Glenn Brown | 2011-03-22 18:49:03 +0100 |
---|---|---|
committer | Michael Brown | 2011-03-22 20:55:05 +0100 |
commit | f732fa28c87e76d5627ce593a8078f4124c06173 (patch) | |
tree | 35b92f93c920000c9371f39771a61217c0b4a3a5 /src/core/settings.c | |
parent | [settings] Use concat_args() in "set" command (diff) | |
download | ipxe-f732fa28c87e76d5627ce593a8078f4124c06173.tar.gz ipxe-f732fa28c87e76d5627ce593a8078f4124c06173.tar.xz ipxe-f732fa28c87e76d5627ce593a8078f4124c06173.zip |
[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>
Diffstat (limited to 'src/core/settings.c')
-rw-r--r-- | src/core/settings.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/core/settings.c b/src/core/settings.c index a080904c..6b3e7411 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -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 * @ret name Settings block name */ -static const char * settings_name ( struct settings *settings ) { - static char buf[64]; +const char * settings_name ( struct settings *settings ) { + static char buf[16]; 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 ) ); - snprintf ( buf, sizeof ( buf ), "%s%c%s", settings->name, - ( count++ ? '.' : '\0' ), tmp ); + snprintf ( buf, sizeof ( buf ), ".%s%s", settings->name, tmp ); } - return ( buf + 1 ); + return ( buf + 2 ); } /** |