mesa: Fix bogus strncmp
authorIan Romanick <ian.d.romanick@intel.com>
Tue, 24 May 2016 17:10:40 +0000 (10:10 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Wed, 1 Jun 2016 18:11:25 +0000 (11:11 -0700)
The string "[0]\0" is the same as "[0]" as far as the C string datatype
is concerned.  That string has length 3.  strncmp(s, length_3_string, 4)
is the same as strcmp(s, length_3_string), so make it be strcmp.

v2: Not the same as strncmp(..., 3).  Noticed by Ilia.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Cc: "12.0" <mesa-stable@lists.freedesktop.org>
src/mesa/main/shader_query.cpp

index 28d8147efe0a697b39be2c8a9c33ed6a67935089..eec933c217620e8a97f24261230a1d92b4c037c6 100644 (file)
@@ -505,7 +505,7 @@ _mesa_program_resource_find_name(struct gl_shader_program *shProg,
       if (rname_last_square_bracket) {
          baselen_without_array_index -= strlen(rname_last_square_bracket);
          rname_has_array_index_zero =
-            (strncmp(rname_last_square_bracket, "[0]\0", 4) == 0) &&
+            (strcmp(rname_last_square_bracket, "[0]") == 0) &&
             (baselen_without_array_index == strlen(name));
       }