Skip to content

Commit b57caaa

Browse files
keesyann-morin-1998
authored andcommitted
kconfig: allow "hex" and "range" to support longs
The parsing routines for Kconfig files use strtol(), but store and render values as int. Switch types and formating to long to support a wider range of values. For example, 0x80000000 wasn't representable. Signed-off-by: Kees Cook <keescook@chromium.org> Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
1 parent 490f161 commit b57caaa

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎scripts/kconfig/symbol.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym)
136136
return NULL;
137137
}
138138

139-
static int sym_get_range_val(struct symbol *sym, int base)
139+
static long sym_get_range_val(struct symbol *sym, int base)
140140
{
141141
sym_calc_value(sym);
142142
switch (sym->type) {
@@ -155,7 +155,7 @@ static int sym_get_range_val(struct symbol *sym, int base)
155155
static void sym_validate_range(struct symbol *sym)
156156
{
157157
struct property *prop;
158-
int base, val, val2;
158+
long base, val, val2;
159159
char str[64];
160160

161161
switch (sym->type) {
@@ -179,9 +179,9 @@ static void sym_validate_range(struct symbol *sym)
179179
return;
180180
}
181181
if (sym->type == S_INT)
182-
sprintf(str, "%d", val2);
182+
sprintf(str, "%ld", val2);
183183
else
184-
sprintf(str, "0x%x", val2);
184+
sprintf(str, "0x%lx", val2);
185185
sym->curr.val = strdup(str);
186186
}
187187

@@ -594,7 +594,7 @@ bool sym_string_valid(struct symbol *sym, const char *str)
594594
bool sym_string_within_range(struct symbol *sym, const char *str)
595595
{
596596
struct property *prop;
597-
int val;
597+
long val;
598598

599599
switch (sym->type) {
600600
case S_STRING:

0 commit comments

Comments
 (0)