Преглед на файлове

[settings] Fix setting_cmp() to handle nameless settings

setting_cmp() compares by option tag and then by name.  Empty names
will always match, which gives us a false positive.

Fix by explicitly checking for empty names.

Modified-by: Michael Brown <mcb30@etherboot.org>
Signed-off-by: Michael Brown <mcb30@etherboot.org>
tags/v0.9.8
Shao Miller преди 15 години
родител
ревизия
68973f1c49
променени са 1 файла, в които са добавени 6 реда и са изтрити 2 реда
  1. 6
    2
      src/core/settings.c

+ 6
- 2
src/core/settings.c Целия файл

@@ -782,8 +782,12 @@ int setting_cmp ( struct setting *a, struct setting *b ) {
782 782
 	if ( a->tag && ( a->tag == b->tag ) )
783 783
 		return 0;
784 784
 
785
-	/* Otherwise, compare the names */
786
-	return strcmp ( a->name, b->name );
785
+	/* Otherwise, if the settings have names, compare them */
786
+	if ( a->name && b->name && a->name[0] )
787
+		return strcmp ( a->name, b->name );
788
+
789
+	/* Otherwise, return a non-match */
790
+	return ( ! 0 );
787 791
 }
788 792
 
789 793
 /******************************************************************************

Loading…
Отказ
Запис