Skip to content

Commit 6262afa

Browse files
committed
kconfig: default to zero if int/hex symbol lacks default property
When a default property is missing in an int or hex symbol, it defaults to an empty string, which is not a valid symbol value. It results in an incorrect .config, and can also lead to an infinite loop in scripting. Use "0" for int and "0x0" for hex as a default value. Signed-off-by: Masahiro Yamada <[email protected]> Reviewed-by: Yoann Congal <[email protected]>
1 parent 4e244c1 commit 6262afa

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

scripts/kconfig/symbol.c

+12-5
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,11 @@ void sym_calc_value(struct symbol *sym)
338338

339339
switch (sym->type) {
340340
case S_INT:
341+
newval.val = "0";
342+
break;
341343
case S_HEX:
344+
newval.val = "0x0";
345+
break;
342346
case S_STRING:
343347
newval.val = "";
344348
break;
@@ -746,14 +750,17 @@ const char *sym_get_string_default(struct symbol *sym)
746750
case yes: return "y";
747751
}
748752
case S_INT:
753+
if (!str[0])
754+
str = "0";
755+
break;
749756
case S_HEX:
750-
return str;
751-
case S_STRING:
752-
return str;
753-
case S_UNKNOWN:
757+
if (!str[0])
758+
str = "0x0";
759+
break;
760+
default:
754761
break;
755762
}
756-
return "";
763+
return str;
757764
}
758765

759766
const char *sym_get_string_value(struct symbol *sym)

0 commit comments

Comments
 (0)