Selaa lähdekoodia

[settings] Rewrite unrelicensable portions of settings.c

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 vuotta sitten
vanhempi
commit
70124dd3be
1 muutettua tiedostoa jossa 13 lisäystä ja 6 poistoa
  1. 13
    6
      src/core/settings.c

+ 13
- 6
src/core/settings.c Näytä tiedosto

15
  * along with this program; if not, write to the Free Software
15
  * along with this program; if not, write to the Free Software
16
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17
  * 02110-1301, USA.
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
 #include <stdint.h>
26
 #include <stdint.h>
23
 #include <stdlib.h>
27
 #include <stdlib.h>
337
  */
341
  */
338
 const char * settings_name ( struct settings *settings ) {
342
 const char * settings_name ( struct settings *settings ) {
339
 	static char buf[16];
343
 	static char buf[16];
340
-	char tmp[ sizeof ( buf ) ];
344
+	char tmp[ 1 /* '.' */ + sizeof ( buf ) ];
341
 
345
 
342
 	/* Find target settings block */
346
 	/* Find target settings block */
343
 	settings = settings_target ( settings );
347
 	settings = settings_target ( settings );
344
 
348
 
345
 	/* Construct name */
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
 /**

Loading…
Peruuta
Tallenna