Skip to content
Snippets Groups Projects

tests: Read integer uniforms with strtol() and strtoul().

Merged Giovanni Mascellani requested to merge giomasce/vkd3d:strtol into master
2 unresolved threads

Because %i sscanf() converters are deprecated, and in practice clamp to [-2^31, 2^31) on 32 bit.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Elizabeth Figura approved this merge request

    approved this merge request

  • added 1 commit

    • b850db67 - tests: Read integer uniforms with strtol() and strtoul().

    Compare with previous version

  • Giovanni Mascellani changed title from tests: Read integer uniforms with strotol() and strtoul(). to tests: Read integer uniforms with strtol() and strtoul().

    changed title from tests: Read integer uniforms with strotol() and strtoul(). to tests: Read integer uniforms with strtol() and strtoul().

    • +static void read_int(const char **line, int *ptr)

      I think "ptr" is a bit of an awkward name for this. Likewise for read_uint().

      +static void read_int4(const char **line, int (*v)[4])

      The "natural" type for "v" would seem struct ivec4. I imagine the choice of passing an array was largely dictated by the set_uniforms() interface, but perhaps it shouldn't be? Likewise for read_uint4().

    • Fixed. I guess we already assume that struct ivec4 and struct uvec4 will always be packed, right? More or less as we already assumed that int[4] is packed.

    • Please register or sign in to reply
  • added 1 commit

    • 364adf49 - tests: Read integer uniforms with strtol() and strtoul().

    Compare with previous version

  • Fixed. I guess we already assume that struct ivec4 and struct uvec4 will always be packed, right? More or less as we already assumed that int[4] is packed.

    We do in practice assume a specific memory layout for these structures, yes.

    • I just noticed this, but:

      +static void read_int(const char **line, int *i)
      +{
      +    char *rest;
      +    long val;
      +
      +    errno = 0;
      +    val = strtol(*line, &rest, 0);
      +
      +    if (errno != 0)
      +        fatal_error("Malformed int constant '%s'.\n", *line);
      +
      +    *i = val;
      +    if (*i != val)
      +        fatal_error("Out of range int constant '%s'.\n", *line);

      Here and to some extent above, I don't think we can just print "*line"; there may be additional data beyond "rest" that we'd also output.

      We may also want to make sure "*rest" is either '\0' or a whitespace character.

    • Here and to some extent above, I don't think we can just print "*line"; there may be additional data beyond "rest" that we'd also output.

      This is already happening in various other places. See for example how the probe command is parsed. I guess the point of view is that the shader runner is a developer-facing tool, so we prefer a simpler code even if it results in somewhat less polished error messages.

      We may also want to make sure "*rest" is either '\0' or a whitespace character.

      Ok, that makes sense.

    • Please register or sign in to reply
  • added 1 commit

    • 104a9429 - tests: Read integer uniforms with strtol() and strtoul().

    Compare with previous version

  • Here and to some extent above, I don't think we can just print "*line"; there may be additional data beyond "rest" that we'd also output.

    This is already happening in various other places. See for example how the probe command is parsed. I guess the point of view is that the shader runner is a developer-facing tool, so we prefer a simpler code even if it results in somewhat less polished error messages.

    I suppose, but I don't think it's that much more complicated to instead do something like

    fatal_error("Out of range integer constant '%.*s'.\n", (int)(rest - *line), *line);
  • This is already happening in various other places. See for example how the probe command is parsed. I guess the point of view is that the shader runner is a developer-facing tool, so we prefer a simpler code even if it results in somewhat less polished error messages.

    In a sense, although it was less an intentional decision towards simplicity as a decision not to put in the effort to make it well-written.

  • added 1 commit

    • d7616f87 - tests: Read integer uniforms with strtol() and strtoul().

    Compare with previous version

  • Henri Verbeet approved this merge request

    approved this merge request

  • Alexandre Julliard added 13 commits

    added 13 commits

    Compare with previous version

  • Alexandre Julliard approved this merge request

    approved this merge request

Please register or sign in to reply
Loading