[Mesa-dev] [PATCH 4/8] nir: Silence missing field initializer warnings for vectors in nir_constant_expressions

Kenneth Graunke kenneth at whitecape.org
Wed Dec 16 12:36:02 PST 2015


On Monday, December 14, 2015 03:34:28 PM Ian Romanick wrote:
> From: Ian Romanick <ian.d.romanick at intel.com>
> 
> nir/nir_constant_expressions.c: In function 'evaluate_ball2':
> nir/nir_constant_expressions.c:279:7: warning: missing initializer for field 'z' of 'struct bool_vec' [-Wmissing-field-initializers]
>        };
>        ^
> nir/nir_constant_expressions.c:234:10: note: 'z' declared here
>     bool z;
>           ^
> 
> Number of total warnings in my build reduced from 1643 to 1574
> (reduction of 69).
> 
> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
> ---
>  src/glsl/nir/nir_constant_expressions.py | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/glsl/nir/nir_constant_expressions.py b/src/glsl/nir/nir_constant_expressions.py
> index 32784f6..81dd67f 100644
> --- a/src/glsl/nir/nir_constant_expressions.py
> +++ b/src/glsl/nir/nir_constant_expressions.py
> @@ -239,6 +239,13 @@ evaluate_${name}(unsigned num_components, nir_const_value *_src)
>              _src[${j}].${op.input_types[j][:1]}[${k}],
>           % endif
>        % endfor
> +      % for k in range(op.input_sizes[j], 4):
> +         % if op.input_types[j] == "bool":
> +            false,
> +         % else:
> +            0,
> +         % endif
> +      % endfor

I'd be tempted to simplify this to:

      % for k in range(op.input_sizes[j], 4):
         0,
      % endfor

0 will be implicitly converted to bool.  (I'd rather keep the generator
as simple as possible, since it's the code that people actually read and
maintain...)

With that change,
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

>        };
>     % endfor
>  
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20151216/ad9fea08/attachment.sig>


More information about the mesa-dev mailing list