浏览代码

[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
 /******************************************************************************

正在加载...
取消
保存