Skip to content

Commit

Permalink
kconfig: allow "hex" and "range" to support longs
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Kees Cook authored and Yann E. MORIN committed Jun 29, 2013
1 parent 490f161 commit b57caaa
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions scripts/kconfig/symbol.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym)
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);
switch (sym->type) {
Expand All @@ -155,7 +155,7 @@ static int sym_get_range_val(struct symbol *sym, int base)
static void sym_validate_range(struct symbol *sym)
{
struct property *prop;
int base, val, val2;
long base, val, val2;
char str[64];

switch (sym->type) {
Expand All @@ -179,9 +179,9 @@ static void sym_validate_range(struct symbol *sym)
return;
}
if (sym->type == S_INT)
sprintf(str, "%d", val2);
sprintf(str, "%ld", val2);
else
sprintf(str, "0x%x", val2);
sprintf(str, "0x%lx", val2);
sym->curr.val = strdup(str);
}

Expand Down Expand Up @@ -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)
{
struct property *prop;
int val;
long val;

switch (sym->type) {
case S_STRING:
Expand Down

0 comments on commit b57caaa

Please sign in to comment.