summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>2017-05-19 14:45:17 +0200
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>2017-05-22 09:51:03 +0200
commitb741bc770e9dfa60021d474ae679efe6bf0fd068 (patch)
tree5b343398d2bd9676b08aad778637eafd9b634543 /tests
parent0b31b69a095da9da7624a7be7bb8873cf5a96b44 (diff)
parser_utils: do not overwrite value when no digits are found
"If there were no digits at all, strtol() stores the original value of nptr in *endptr (and returns 0)." If the parsing helper functions are used inside a loop like the "fb tex 2d x" command, the parsed value is overwritten with zero and this ends up by reporting "No texture bound at 0". Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/shaders/parser_utils.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/shaders/parser_utils.c b/tests/shaders/parser_utils.c
index 3b1400c47..79984ad6c 100644
--- a/tests/shaders/parser_utils.c
+++ b/tests/shaders/parser_utils.c
@@ -56,9 +56,10 @@ parse_ints(const char *s, int *i, unsigned n, const char **rest)
unsigned j;
for (j = 0; j < n; j++) {
- i[j] = strtoll(s = end, (char **)&end, 0);
+ int v = strtoll(s = end, (char **)&end, 0);
if (s == end)
break;
+ i[j] = v;
}
if (rest)
@@ -74,9 +75,10 @@ parse_uints(const char *s, unsigned *u, unsigned n, const char **rest)
unsigned j;
for (j = 0; j < n; j++) {
- u[j] = strtoul(s = end, (char **)&end, 0);
+ unsigned v = strtoul(s = end, (char **)&end, 0);
if (s == end)
break;
+ u[j] = v;
}
if (rest)
@@ -92,9 +94,10 @@ parse_int64s(const char *s, int64_t *i, unsigned n, const char **rest)
unsigned j;
for (j = 0; j < n; j++) {
- i[j] = strtoll(s = end, (char **)&end, 0);
+ int64_t v = strtoll(s = end, (char **)&end, 0);
if (s == end)
break;
+ i[j] = v;
}
if (rest)
@@ -110,9 +113,10 @@ parse_uint64s(const char *s, uint64_t *u, unsigned n, const char **rest)
unsigned j;
for (j = 0; j < n; j++) {
- u[j] = strtoull(s = end, (char **)&end, 0);
+ uint64_t v = strtoull(s = end, (char **)&end, 0);
if (s == end)
break;
+ u[j] = v;
}
if (rest)
@@ -128,9 +132,10 @@ parse_floats(const char *s, float *f, unsigned n, const char **rest)
unsigned j;
for (j = 0; j < n; j++) {
- f[j] = strtof_hex(s = end, (char **)&end);
+ float v = strtof_hex(s = end, (char **)&end);
if (s == end)
break;
+ f[j] = v;
}
if (rest)
@@ -146,9 +151,10 @@ parse_doubles(const char *s, double *d, unsigned n, const char **rest)
unsigned j;
for (j = 0; j < n; j++) {
- d[j] = strtod_hex(s = end, (char **)&end);
+ double v = strtod_hex(s = end, (char **)&end);
if (s == end)
break;
+ d[j] = v;
}
if (rest)