aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMasahiro Yamada2023-11-26 01:35:59 +0900
committerMasahiro Yamada2023-12-03 19:01:25 +0900
commit6262afa10ef7cc8fdf39b81a36f9546b68810431 (patch)
tree53ab8ef7d3468722586c718a28c38a004c98f6c6
parent4e244c10eab345a735c5052688e4a55bddce5bf7 (diff)
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 <masahiroy@kernel.org> Reviewed-by: Yoann Congal <yoann.congal@smile.fr>
-rw-r--r--scripts/kconfig/symbol.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index f7075d148ac7..a5a4f9153eb7 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -338,7 +338,11 @@ void sym_calc_value(struct symbol *sym)
switch (sym->type) {
case S_INT:
+ newval.val = "0";
+ break;
case S_HEX:
+ newval.val = "0x0";
+ break;
case S_STRING:
newval.val = "";
break;
@@ -746,14 +750,17 @@ const char *sym_get_string_default(struct symbol *sym)
case yes: return "y";
}
case S_INT:
+ if (!str[0])
+ str = "0";
+ break;
case S_HEX:
- return str;
- case S_STRING:
- return str;
- case S_UNKNOWN:
+ if (!str[0])
+ str = "0x0";
+ break;
+ default:
break;
}
- return "";
+ return str;
}
const char *sym_get_string_value(struct symbol *sym)