History

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.

Kees Cook committed 13 years ago

Commit 129784a1 parent c3286ee1 file · +10 −9Browse files

Unified · Split

scripts/kconfig/symbol.c+10−9
@@ -136,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym) · 135 unmodified lines
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) · 6 unmodified lines
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) · 9 unmodified lines
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) · 1 unmodified line
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 else184 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) · 406 unmodified lines
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) · 4 unmodified lines
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) · 2 unmodified lines
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: