[Mesa-dev] [PATCH mesa 03/12] nouveau: fix memset(0) of non-trivial structs

Ilia Mirkin imirkin at alum.mit.edu
Mon Oct 29 17:23:22 UTC 2018


Is this legal in C++98? I don't think we require C++11 mesa-wide, at
least not yet...
On Mon, Oct 29, 2018 at 1:16 PM Eric Engestrom <eric.engestrom at intel.com> wrote:
>
> Signed-off-by: Eric Engestrom <eric.engestrom at intel.com>
> ---
>  src/gallium/drivers/nouveau/codegen/nv50_ir.cpp        | 3 +--
>  src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp | 2 +-
>  2 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp
> index 49425b98b9137058c986..b543f731db6f07ecab0d 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir.cpp
> @@ -905,8 +905,7 @@ Instruction::isCommutationLegal(const Instruction *i) const
>  TexInstruction::TexInstruction(Function *fn, operation op)
>     : Instruction(fn, op, TYPE_F32)
>  {
> -   memset(&tex, 0, sizeof(tex));
> -
> +   tex = {};
>     tex.rIndirectSrc = -1;
>     tex.sIndirectSrc = -1;
>
> diff --git a/src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp b/src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp
> index 9193a01f189874a7fb38..f9f4cf7e7a46532efce9 100644
> --- a/src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp
> +++ b/src/gallium/drivers/nouveau/codegen/nv50_ir_target.cpp
> @@ -454,7 +454,7 @@ CodeEmitter::addInterp(int ipa, int reg, FixupApply apply)
>        if (!fixupInfo)
>           return false;
>        if (n == 0)
> -         memset(fixupInfo, 0, sizeof(FixupInfo));
> +         *fixupInfo = {};
>     }
>     ++fixupInfo->count;
>
> --
> Cheers,
>   Eric
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list