Browse Source

[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 years ago
parent
commit
68973f1c49
1 changed files with 6 additions and 2 deletions
  1. 6
    2
      src/core/settings.c

+ 6
- 2
src/core/settings.c View File

782
 	if ( a->tag && ( a->tag == b->tag ) )
782
 	if ( a->tag && ( a->tag == b->tag ) )
783
 		return 0;
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…
Cancel
Save