From 99e822fa18a322f7bf0d32ce99eab534d5614469 Mon Sep 17 00:00:00 2001 From: Paul Berry Date: Tue, 17 Dec 2013 09:54:38 -0800 Subject: mesa: Improve static error checking of arrays sized by MESA_SHADER_TYPES. This patch replaces the following pattern: foo bar[MESA_SHADER_TYPES] = { ... }; With: foo bar[] = { ... }; STATIC_ASSERT(Elements(bar) == MESA_SHADER_TYPES); This way, when a new shader type is added in a future version of Mesa, we will get a compile error to remind us that the array needs to be updated. Reviewed-by: Brian Paul --- src/mesa/program/program.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mesa') diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h index 353ccab4789..135271caf9a 100644 --- a/src/mesa/program/program.h +++ b/src/mesa/program/program.h @@ -210,11 +210,12 @@ _mesa_program_target_to_index(GLenum v) static inline GLenum _mesa_program_index_to_target(GLuint i) { - static const GLenum enums[MESA_SHADER_TYPES] = { + static const GLenum enums[] = { GL_VERTEX_PROGRAM_ARB, GL_GEOMETRY_PROGRAM_NV, GL_FRAGMENT_PROGRAM_ARB }; + STATIC_ASSERT(Elements(enums) == MESA_SHADER_TYPES); if(i >= MESA_SHADER_TYPES) return 0; else -- cgit v1.2.3