[Mesa-dev] [PATCH] glsl: add default switch case to silence uninitialized variable warning

Matt Turner mattst88 at gmail.com
Fri Aug 23 13:39:54 PDT 2013


On Fri, Aug 23, 2013 at 1:24 PM, Brian Paul <brianp at vmware.com> wrote:
> ---
>  src/glsl/ast_to_hir.cpp |    3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/src/glsl/ast_to_hir.cpp b/src/glsl/ast_to_hir.cpp
> index feff586..24efec6 100644
> --- a/src/glsl/ast_to_hir.cpp
> +++ b/src/glsl/ast_to_hir.cpp
> @@ -1933,6 +1933,9 @@ validate_binding_qualifier(struct _mesa_glsl_parse_state *state,
>        case fragment_shader:
>           limit = ctx->Const.FragmentProgram.MaxTextureImageUnits;
>           break;
> +      default:
> +         limit = 0;
> +         assert(!"Unexpected shader type");
>        }
>
>        if (max_index >= limit) {
> --
> 1.7.10.4

I can't see why this would be necessary, since the switch statement
switches over a variable of type _mesa_glsl_parser_targets, and the
switch has cases for all elements in the enum.

enum _mesa_glsl_parser_targets {
   vertex_shader,
   geometry_shader,
   fragment_shader
};


More information about the mesa-dev mailing list