glsl: Silence some warnings at -Og
authorAdam Jackson <ajax@redhat.com>
Tue, 26 Jan 2021 19:04:14 +0000 (14:04 -0500)
committerMarge Bot <eric+marge@anholt.net>
Thu, 18 Feb 2021 20:59:43 +0000 (20:59 +0000)
   ./src/compiler/glsl/link_uniforms.cpp: In member function ‘virtual void parcel_out_uniform_storage::visit_field(const glsl_type*, const char*, bool, const glsl_type*, glsl_interface_packing, bool)’:
   ../src/compiler/glsl/link_uniforms.cpp:1171:61: warning: ‘id’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    1171 |       calculate_array_size_and_stride(prog, &this->uniforms[id],

   ../src/compiler/glsl/link_uniform_initializers.cpp: In function ‘gl_uniform_storage* linker::get_storage(gl_shader_program*, const char*)’:
   ../src/compiler/glsl/link_uniform_initializers.cpp:41:42: warning: ‘id’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      41 |       return &prog->data->UniformStorage[id];

Can't happen, but flow control apparently can't prove it.

Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8724>

src/compiler/glsl/link_uniforms.cpp

index 6518ec1..f0e2295 100644 (file)
@@ -1039,7 +1039,7 @@ private:
       assert(!type->without_array()->is_interface());
       assert(!(type->is_array() && type->fields.array->is_array()));
 
-      unsigned id;
+      unsigned id = 0;
       bool found = this->map->get(id, name);
       assert(found);