[sw/silicon_creator] Use memset to initialize epmp_state This commit improves the initialization of `epmp_state` in `rom_epmp.c` and `rom_epmp_test.c` by replacing the temporary that was initialized and copied over with a single call to `memset`. Signed-off-by: Alphan Ulusoy <alphan@google.com>
diff --git a/sw/device/silicon_creator/rom/BUILD b/sw/device/silicon_creator/rom/BUILD index 914288f..f127db4 100644 --- a/sw/device/silicon_creator/rom/BUILD +++ b/sw/device/silicon_creator/rom/BUILD
@@ -145,6 +145,7 @@ "//hw/top_earlgrey/sw/autogen:top_earlgrey", "//sw/device/lib/base:bitfield", "//sw/device/lib/base:csr", + "//sw/device/lib/base:memory", "//sw/device/silicon_creator/lib:epmp_state", "//sw/device/silicon_creator/lib/drivers:lifecycle", ],
diff --git a/sw/device/silicon_creator/rom/rom_epmp.c b/sw/device/silicon_creator/rom/rom_epmp.c index 9663893..b2cf46a 100644 --- a/sw/device/silicon_creator/rom/rom_epmp.c +++ b/sw/device/silicon_creator/rom/rom_epmp.c
@@ -6,6 +6,7 @@ #include "sw/device/lib/base/bitfield.h" #include "sw/device/lib/base/csr.h" +#include "sw/device/lib/base/memory.h" #include "hw/top_earlgrey/sw/autogen/top_earlgrey.h" @@ -85,7 +86,7 @@ // The actual hardware configuration is performed separately, either by reset // logic or in assembly. This code must be kept in sync with any changes // to the hardware configuration. - epmp_state = (epmp_state_t){0}; + memset(&epmp_state, 0, sizeof(epmp_state)); epmp_state_configure_tor(1, rom_text, kEpmpPermLockedReadExecute); epmp_state_configure_napot(2, rom, kEpmpPermLockedReadOnly); epmp_state_configure_napot(5, eflash, kEpmpPermLockedReadOnly);
diff --git a/sw/device/silicon_creator/rom/rom_epmp_test.c b/sw/device/silicon_creator/rom/rom_epmp_test.c index d583b39..dbf80b5 100644 --- a/sw/device/silicon_creator/rom/rom_epmp_test.c +++ b/sw/device/silicon_creator/rom/rom_epmp_test.c
@@ -375,7 +375,7 @@ LOG_INFO("Starting ROM ePMP functional test."); // Initialize shadow copy of the ePMP register configuration. - epmp_state = (epmp_state_t){0}; + memset(&epmp_state, 0, sizeof(epmp_state)); rom_epmp_state_init(kLcStateProd); CHECK(epmp_state_check() == kErrorOk);