[Mesa-dev] [PATCH] glsl: add default switch case to silence uninitialized variable warning
Brian Paul
brianp at vmware.com
Fri Aug 23 13:55:14 PDT 2013
On 08/23/2013 02:39 PM, Matt Turner wrote:
> 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
> };
>
gcc 4.8.1 on Fedora 19:
../../../src/glsl/ast_to_hir.cpp: In function 'void
apply_type_qualifier_to_variable(const ast_type_qualifier*,
ir_variable*, _mesa_glsl_parse_state*, YYLTYPE*, bool, bool)':
../../../src/glsl/ast_to_hir.cpp:1917:66: warning: 'limit' may be used
uninitialized in this function [-Wmaybe-uninitialized]
"(%d)", qual->binding, elements, limit);
^
../../../src/glsl/ast_to_hir.cpp:1901:16: note: 'limit' was declared here
unsigned limit;
^
-Brian
More information about the mesa-dev
mailing list