Quellcode durchsuchen

[settings] Rewrite unrelicensable portions of settings.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown vor 9 Jahren
Ursprung
Commit
70124dd3be
1 geänderte Dateien mit 13 neuen und 6 gelöschten Zeilen
  1. 13
    6
      src/core/settings.c

+ 13
- 6
src/core/settings.c Datei anzeigen

@@ -15,9 +15,13 @@
15 15
  * along with this program; if not, write to the Free Software
16 16
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 17
  * 02110-1301, USA.
18
+ *
19
+ * You can also choose to distribute this program under the terms of
20
+ * the Unmodified Binary Distribution Licence (as given in the file
21
+ * COPYING.UBDL), provided that you have satisfied its requirements.
18 22
  */
19 23
 
20
-FILE_LICENCE ( GPL2_OR_LATER );
24
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
21 25
 
22 26
 #include <stdint.h>
23 27
 #include <stdlib.h>
@@ -337,17 +341,20 @@ struct settings * autovivify_child_settings ( struct settings *parent,
337 341
  */
338 342
 const char * settings_name ( struct settings *settings ) {
339 343
 	static char buf[16];
340
-	char tmp[ sizeof ( buf ) ];
344
+	char tmp[ 1 /* '.' */ + sizeof ( buf ) ];
341 345
 
342 346
 	/* Find target settings block */
343 347
 	settings = settings_target ( settings );
344 348
 
345 349
 	/* Construct name */
346
-	for ( buf[2] = buf[0] = 0 ; settings ; settings = settings->parent ) {
347
-		memcpy ( tmp, buf, sizeof ( tmp ) );
348
-		snprintf ( buf, sizeof ( buf ), ".%s%s", settings->name, tmp );
350
+	buf[0] = '\0';
351
+	tmp[0] = '\0';
352
+	for ( ; settings->parent ; settings = settings->parent ) {
353
+		memcpy ( ( tmp + 1 ), buf, ( sizeof ( tmp ) - 1 ) );
354
+		snprintf ( buf, sizeof ( buf ), "%s%s", settings->name, tmp );
355
+		tmp[0] = '.';
349 356
 	}
350
-	return ( buf + 2 );
357
+	return buf;
351 358
 }
352 359
 
353 360
 /**

Laden…
Abbrechen
Speichern