aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2013-07-18 14:32:01 -0400
committerYann E. MORIN <yann.morin.1998@free.fr>2013-08-15 16:48:06 -0400
commit129784abc982ccac43322c2f175f3ca735c2ca73 (patch)
tree710f56ad4108a4cb853db699b8e75970360213f0 /scripts
parentc3286ee337b0586a8ae2b4f13c33e3de5d71139e (diff)
kconfig: switch to "long long" for sanity
Instead of using "long" for kconfig "hex" and "range" values, which may change in size depending on the host architecture, use "long long". This will allow values greater than INT_MAX on 32-bit hosts when cross compiling. Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/kconfig/symbol.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index a76b8fd1db4f..c9a6775565bf 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -136,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym)
136 return NULL; 136 return NULL;
137} 137}
138 138
139static long sym_get_range_val(struct symbol *sym, int base) 139static long long sym_get_range_val(struct symbol *sym, int base)
140{ 140{
141 sym_calc_value(sym); 141 sym_calc_value(sym);
142 switch (sym->type) { 142 switch (sym->type) {
@@ -149,13 +149,14 @@ static long sym_get_range_val(struct symbol *sym, int base)
149 default: 149 default:
150 break; 150 break;
151 } 151 }
152 return strtol(sym->curr.val, NULL, base); 152 return strtoll(sym->curr.val, NULL, base);
153} 153}
154 154
155static void sym_validate_range(struct symbol *sym) 155static void sym_validate_range(struct symbol *sym)
156{ 156{
157 struct property *prop; 157 struct property *prop;
158 long base, val, val2; 158 int base;
159 long long val, val2;
159 char str[64]; 160 char str[64];
160 161
161 switch (sym->type) { 162 switch (sym->type) {
@@ -171,7 +172,7 @@ static void sym_validate_range(struct symbol *sym)
171 prop = sym_get_range_prop(sym); 172 prop = sym_get_range_prop(sym);
172 if (!prop) 173 if (!prop)
173 return; 174 return;
174 val = strtol(sym->curr.val, NULL, base); 175 val = strtoll(sym->curr.val, NULL, base);
175 val2 = sym_get_range_val(prop->expr->left.sym, base); 176 val2 = sym_get_range_val(prop->expr->left.sym, base);
176 if (val >= val2) { 177 if (val >= val2) {
177 val2 = sym_get_range_val(prop->expr->right.sym, base); 178 val2 = sym_get_range_val(prop->expr->right.sym, base);
@@ -179,9 +180,9 @@ static void sym_validate_range(struct symbol *sym)
179 return; 180 return;
180 } 181 }
181 if (sym->type == S_INT) 182 if (sym->type == S_INT)
182 sprintf(str, "%ld", val2); 183 sprintf(str, "%lld", val2);
183 else 184 else
184 sprintf(str, "0x%lx", val2); 185 sprintf(str, "0x%llx", val2);
185 sym->curr.val = strdup(str); 186 sym->curr.val = strdup(str);
186} 187}
187 188
@@ -594,7 +595,7 @@ bool sym_string_valid(struct symbol *sym, const char *str)
594bool sym_string_within_range(struct symbol *sym, const char *str) 595bool sym_string_within_range(struct symbol *sym, const char *str)
595{ 596{
596 struct property *prop; 597 struct property *prop;
597 long val; 598 long long val;
598 599
599 switch (sym->type) { 600 switch (sym->type) {
600 case S_STRING: 601 case S_STRING:
@@ -605,7 +606,7 @@ bool sym_string_within_range(struct symbol *sym, const char *str)
605 prop = sym_get_range_prop(sym); 606 prop = sym_get_range_prop(sym);
606 if (!prop) 607 if (!prop)
607 return true; 608 return true;
608 val = strtol(str, NULL, 10); 609 val = strtoll(str, NULL, 10);
609 return val >= sym_get_range_val(prop->expr->left.sym, 10) && 610 return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
610 val <= sym_get_range_val(prop->expr->right.sym, 10); 611 val <= sym_get_range_val(prop->expr->right.sym, 10);
611 case S_HEX: 612 case S_HEX:
@@ -614,7 +615,7 @@ bool sym_string_within_range(struct symbol *sym, const char *str)
614 prop = sym_get_range_prop(sym); 615 prop = sym_get_range_prop(sym);
615 if (!prop) 616 if (!prop)
616 return true; 617 return true;
617 val = strtol(str, NULL, 16); 618 val = strtoll(str, NULL, 16);
618 return val >= sym_get_range_val(prop->expr->left.sym, 16) && 619 return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
619 val <= sym_get_range_val(prop->expr->right.sym, 16); 620 val <= sym_get_range_val(prop->expr->right.sym, 16);
620 case S_BOOLEAN: 621 case S_BOOLEAN: