[Piglit] [PATCH 2/2] shader_runner: Fix get_ints on 32-bit systems.
Kenneth Graunke
kenneth at whitecape.org
Mon Jun 6 23:02:04 UTC 2016
On Monday, June 6, 2016 3:56:09 PM PDT Mark Janes wrote:
> 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>
Right, the value > 0xFFFFFFFFull bit is bogus - the sign bit gets
extended. I've just dropped this locally. It removes a bit of sanity
checking for bogus values written in .shader_test files, but we don't
sanity check most values, either.
--Ken
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <https://lists.freedesktop.org/archives/piglit/attachments/20160606/448292d3/attachment.sig>
More information about the Piglit
mailing list