]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[settings] Expose settings_name()
authorGlenn Brown <glenn@myri.com>
Tue, 22 Mar 2011 17:49:03 +0000 (17:49 +0000)
committerMichael Brown <mcb30@ipxe.org>
Tue, 22 Mar 2011 19:55:05 +0000 (19:55 +0000)
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>
src/core/settings.c
src/include/ipxe/settings.h

index a080904c54334863393895fefc4edca50e4a995b..6b3e74115a72d8d85e69d160bb9920b5e3b09c7e 100644 (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
  * @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 );
 }
 
 /**
index b2b63f8ad1f068d8aeca752b1f63102e86802994..5c54168320ddb6d158c152975a746b092039bd46 100644 (file)
@@ -245,6 +245,7 @@ extern int fetch_uuid_setting ( struct settings *settings,
 extern void clear_settings ( struct settings *settings );
 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 setting * find_setting ( const char *name );