[Mesa-dev] [PATCH] glsl: Initialize assignment_generator member variables.

Kenneth Graunke kenneth at whitecape.org
Tue Sep 24 11:58:01 PDT 2013


On 09/23/2013 10:06 PM, Vinson Lee wrote:
> Fixes "Uninitialized pointer field" defect reported by Coverity.
> 
> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
> ---
>  src/glsl/lower_variable_index_to_cond_assign.cpp | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/src/glsl/lower_variable_index_to_cond_assign.cpp b/src/glsl/lower_variable_index_to_cond_assign.cpp
> index 21674b5..8086c03 100644
> --- a/src/glsl/lower_variable_index_to_cond_assign.cpp
> +++ b/src/glsl/lower_variable_index_to_cond_assign.cpp
> @@ -192,6 +192,12 @@ struct assignment_generator
>     ir_variable* var;
>  
>     assignment_generator()
> +     : base_ir(NULL),
> +       rvalue(NULL),
> +       old_index(NULL),
> +       is_write(false),
> +       write_mask(0),
> +       var(NULL)
>     {
>     }
>  
> 

I'm fine with this patch, but I wonder if we shouldn't make the
constructor take (at least some of) these as parameters.

The code using this does:
      assignment_generator ag;
      ag.rvalue = orig_base;
      ag.base_ir = base_ir;
      ag.old_index = index;
      ag.var = var;
      if (orig_assign) {
         ag.is_write = true;
         ag.write_mask = orig_assign->write_mask;
      } else {
         ag.is_write = false;
      }

It might be nicer to just do:

      assignment_generator ag(orig_base, base_ir, index, var);

Not sure about the other parameters.

Regardless,
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>


More information about the mesa-dev mailing list