Commit b57caaae authored by Kees Cook's avatar Kees Cook Committed by Yann E. MORIN

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: default avatarKees Cook <keescook@chromium.org>
Tested-by: default avatar"Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: default avatar"Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: default avatar"Yann E. MORIN" <yann.morin.1998@free.fr>
parent 490f1617
...@@ -136,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym) ...@@ -136,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym)
return NULL; return NULL;
} }
static int sym_get_range_val(struct symbol *sym, int base) static long sym_get_range_val(struct symbol *sym, int base)
{ {
sym_calc_value(sym); sym_calc_value(sym);
switch (sym->type) { switch (sym->type) {
...@@ -155,7 +155,7 @@ static int sym_get_range_val(struct symbol *sym, int base) ...@@ -155,7 +155,7 @@ static int sym_get_range_val(struct symbol *sym, int base)
static void sym_validate_range(struct symbol *sym) static void sym_validate_range(struct symbol *sym)
{ {
struct property *prop; struct property *prop;
int base, val, val2; long base, val, val2;
char str[64]; char str[64];
switch (sym->type) { switch (sym->type) {
...@@ -179,9 +179,9 @@ static void sym_validate_range(struct symbol *sym) ...@@ -179,9 +179,9 @@ static void sym_validate_range(struct symbol *sym)
return; return;
} }
if (sym->type == S_INT) if (sym->type == S_INT)
sprintf(str, "%d", val2); sprintf(str, "%ld", val2);
else else
sprintf(str, "0x%x", val2); sprintf(str, "0x%lx", val2);
sym->curr.val = strdup(str); sym->curr.val = strdup(str);
} }
...@@ -594,7 +594,7 @@ bool sym_string_valid(struct symbol *sym, const char *str) ...@@ -594,7 +594,7 @@ bool sym_string_valid(struct symbol *sym, const char *str)
bool sym_string_within_range(struct symbol *sym, const char *str) bool sym_string_within_range(struct symbol *sym, const char *str)
{ {
struct property *prop; struct property *prop;
int val; long val;
switch (sym->type) { switch (sym->type) {
case S_STRING: case S_STRING:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment