If the structure is a non-static local variable, most compilers will silently inject an intrinsic call to memcpy in function initialization.  This leads to an intermittent linker error.

 

If the compiler you use automatically supports an intrinsic memcpy in the given architecture or optimizes out the memcpy, it will build for you and you won’t know you need to link to an intrinsic support library in order to build cross platform.  This leads to code that builds for you, but not for me.

 

Regards,

-Ken.

 

From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of Bret Barkelew via groups.io
Sent: Thursday, September 24, 2020 6:23 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] ECC: Won't somebody PLEASE think of the... test structures.

 

ERROR - EFI coding style error

ERROR - *Error code: 5007

ERROR - *There should be no initialization of a variable as part of its declaration

ERROR - *file: //home/corthon/_uefi/edk2_qemu_ci/edk2/MdeModulePkg/Library/VariablePolicyLib/VariablePolicyUnitTest/VariablePolicyUnitTest.c

ERROR - *Line number: 333

ERROR - *Variable Name: MatchCheckPolicy

 

EccCheck no likey:

SIMPLE_VARIABLE_POLICY_ENTRY   ValidationPolicy = {

    {

      VARIABLE_POLICY_ENTRY_REVISION,

      sizeof(VARIABLE_POLICY_ENTRY) + sizeof(TEST_VAR_1_NAME),

      sizeof(VARIABLE_POLICY_ENTRY),

      TEST_GUID_1,

      TEST_POLICY_MIN_SIZE_NULL,

      TEST_POLICY_MAX_SIZE_NULL,

      TEST_POLICY_ATTRIBUTES_NULL,

      TEST_POLICY_ATTRIBUTES_NULL,

      VARIABLE_POLICY_TYPE_NO_LOCK

    },

    TEST_VAR_1_NAME

  };

 

But you can’t init this structure separately without addressing each field.

Can a brother get an override?

 

- Bret