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

Showing the changes to scripts (1 of 1 file). Show all

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
136136 return NULL;
137137 }
138138
139−static long sym_get_range_val(struct symbol *sym, int base)
139+static long long sym_get_range_val(struct symbol *sym, int base)
140140 {
141141 sym_calc_value(sym);
142142 switch (sym->type) {
@@ -149,13 +149,14 @@ static long sym_get_range_val(struct symbol *sym, int base) · 6 unmodified lines
149149 default:
150150 break;
151151 }
152− return strtol(sym->curr.val, NULL, base);
152+ return strtoll(sym->curr.val, NULL, base);
153153 }
154154
155155 static void sym_validate_range(struct symbol *sym)
156156 {
157157 struct property *prop;
158− long base, val, val2;
158+ int base;
159+ long long val, val2;
159160 char str[64];
160161
161162 switch (sym->type) {
@@ -171,7 +172,7 @@ static void sym_validate_range(struct symbol *sym) · 9 unmodified lines
171172 prop = sym_get_range_prop(sym);
172173 if (!prop)
173174 return;
174− val = strtol(sym->curr.val, NULL, base);
175+ val = strtoll(sym->curr.val, NULL, base);
175176 val2 = sym_get_range_val(prop->expr->left.sym, base);
176177 if (val >= val2) {
177178 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
179180 return;
180181 }
181182 if (sym->type == S_INT)
182− sprintf(str, "%ld", val2);
183+ sprintf(str, "%lld", val2);
183184 else
184− sprintf(str, "0x%lx", val2);
185+ sprintf(str, "0x%llx", val2);
185186 sym->curr.val = strdup(str);
186187 }
187188
@@ -594,7 +595,7 @@ bool sym_string_valid(struct symbol *sym, const char *str) · 406 unmodified lines
594595 bool sym_string_within_range(struct symbol *sym, const char *str)
595596 {
596597 struct property *prop;
597− long val;
598+ long long val;
598599
599600 switch (sym->type) {
600601 case S_STRING:
@@ -605,7 +606,7 @@ bool sym_string_within_range(struct symbol *sym, const char *str) · 4 unmodified lines
605606 prop = sym_get_range_prop(sym);
606607 if (!prop)
607608 return true;
608− val = strtol(str, NULL, 10);
609+ val = strtoll(str, NULL, 10);
609610 return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
610611 val <= sym_get_range_val(prop->expr->right.sym, 10);
611612 case S_HEX:
@@ -614,7 +615,7 @@ bool sym_string_within_range(struct symbol *sym, const char *str) · 2 unmodified lines
614615 prop = sym_get_range_prop(sym);
615616 if (!prop)
616617 return true;
617− val = strtol(str, NULL, 16);
618+ val = strtoll(str, NULL, 16);
618619 return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
619620 val <= sym_get_range_val(prop->expr->right.sym, 16);
620621 case S_BOOLEAN: