[Mesa-dev] [PATCH] nir: only dereference undef after NULL check.

Jason Ekstrand jason at jlekstrand.net
Sun Apr 17 21:11:37 UTC 2016


On Apr 17, 2016 1:56 PM, "Dave Airlie" <airlied at gmail.com> wrote:
>
> From: Dave Airlie <airlied at redhat.com>
>
> Pointed out by coverity.
>
> Signed-off-by: Dave Airlie <airlied at redhat.com>
> ---
>  src/compiler/nir/nir_builder.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/compiler/nir/nir_builder.h
b/src/compiler/nir/nir_builder.h
> index 29b13fb..1425dba 100644
> --- a/src/compiler/nir/nir_builder.h
> +++ b/src/compiler/nir/nir_builder.h
> @@ -79,10 +79,10 @@ nir_ssa_undef(nir_builder *build, unsigned
num_components, unsigned bit_size)
>  {
>     nir_ssa_undef_instr *undef =
>        nir_ssa_undef_instr_create(build->shader, num_components,
bit_size);
> -   undef->def.bit_size = bit_size;
>     if (!undef)
>        return NULL;
>
> +   undef->def.bit_size = bit_size;

You can just can this line instead.  We just passed bit_size into the
constructor function.

>     nir_instr_insert(nir_before_cf_list(&build->impl->body),
&undef->instr);
>
>     return &undef->def;
> --
> 2.5.5
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160417/e64ef913/attachment.html>


More information about the mesa-dev mailing list