glsl: Fix off-by-one error in array size check assertion
authorIan Romanick <ian.d.romanick@intel.com>
Wed, 18 Nov 2015 02:35:00 +0000 (18:35 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Thu, 19 Nov 2015 02:35:56 +0000 (18:35 -0800)
Apparently, this has been a bug since 2010 (c30f6e5d).

Also use ARRAY_SIZE instead of open coding it.

Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Cc: mesa-stable@lists.freedesktop.org
src/glsl/ir.cpp

index 8b5ba71..80cbdbf 100644 (file)
@@ -1425,8 +1425,7 @@ static const char * const tex_opcode_strs[] = { "tex", "txb", "txl", "txd", "txf
 
 const char *ir_texture::opcode_string()
 {
-   assert((unsigned int) op <=
-         sizeof(tex_opcode_strs) / sizeof(tex_opcode_strs[0]));
+   assert((unsigned int) op < ARRAY_SIZE(tex_opcode_strs));
    return tex_opcode_strs[op];
 }