[Piglit] [PATCH 2/2] shader_runner: Fix get_ints on 32-bit systems.

Kenneth Graunke kenneth at whitecape.org
Mon Jun 6 20:59:59 UTC 2016


The new ARB_vertex_attrib_64bit tests specify integer uniform values
as hex, such as 0xc21620c5.  As an integer value, this is beyond LONG_MAX
on 32-bit systems.  The intent is to parse it as an unsigned hex value and
bitcast it.

However, we still need to handle parsing values with negative signs.

Using strtoll and truncating works.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
---
 tests/shaders/shader_runner.c | 2 +-
 tests/util/piglit-vbo.cpp     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/tests/shaders/shader_runner.c b/tests/shaders/shader_runner.c
index 94c7826..56fd97c 100644
--- a/tests/shaders/shader_runner.c
+++ b/tests/shaders/shader_runner.c
@@ -1398,7 +1398,7 @@ get_ints(const char *line, int *ints, unsigned count)
 	unsigned i;
 
 	for (i = 0; i < count; i++)
-		ints[i] = strtol(line, (char **) &line, 0);
+		ints[i] = strtoll(line, (char **) &line, 0);
 }
 
 
diff --git a/tests/util/piglit-vbo.cpp b/tests/util/piglit-vbo.cpp
index fd7e72a..50e6731 100644
--- a/tests/util/piglit-vbo.cpp
+++ b/tests/util/piglit-vbo.cpp
@@ -387,8 +387,8 @@ vertex_attrib_description::parse_datum(const char **text, void *data) const
 		break;
 	}
 	case GL_INT: {
-		long value = (long) strtoll(*text, &endptr, 0);
-		if (errno == ERANGE) {
+		long long value = strtoll(*text, &endptr, 0);
+		if (errno == ERANGE || (unsigned long long) value > 0xFFFFFFFFull) {
 			printf("Could not parse as signed integer\n");
 			return false;
 		}
-- 
2.8.3



More information about the Piglit mailing list