[Piglit] [PATCH 1/2] shader_runner: Fix integer vbo attribute parsing on 32-bit systems.

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

The new ARB_vertex_attrib_64bit tests specify integer vertex attributes
with hex values, 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 should work.  It breaks the errno-based
range validation, but we can still at least try to reject some cases.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
 tests/util/piglit-vbo.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/util/piglit-vbo.cpp b/tests/util/piglit-vbo.cpp
index 1bdd9da..fd7e72a 100644
--- a/tests/util/piglit-vbo.cpp
+++ b/tests/util/piglit-vbo.cpp
@@ -387,7 +387,7 @@ vertex_attrib_description::parse_datum(const char **text, void *data) const
 	case GL_INT: {
-		long value = strtol(*text, &endptr, 0);
+		long value = (long) strtoll(*text, &endptr, 0);
 		if (errno == ERANGE) {
 			printf("Could not parse as signed integer\n");
 			return false;

More information about the Piglit mailing list