[Piglit] [PATCH 2/2] shader_runner: Fix get_ints on 32-bit systems.
Mark Janes
mark.a.janes at intel.com
Mon Jun 6 22:56:09 UTC 2016
Kenneth Graunke <kenneth at whitecape.org> writes:
> 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) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
with this check removed, the series corrects all 32 bit failures
introduced by b7eb469, and is
Tested-by: Mark Janes <mark.a.janes at intel.com>
> printf("Could not parse as signed integer\n");
> return false;
> }
> --
> 2.8.3
More information about the Piglit
mailing list