treewide: Drop unnecessary uses of memset/memcpy
Simply provide an initialiser or use a direct assignment instead.
Change-Id: I07385375cd8eec8a95874001b402b2c17ec09e09
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/55267
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/71372
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c
index fbb9b1b..d09b0d5 100644
--- a/stlinkv3_spi.c
+++ b/stlinkv3_spi.c
@@ -153,14 +153,12 @@
*/
static int stlinkv3_get_clk(uint32_t *bridge_input_clk)
{
- uint8_t command[16];
+ uint8_t command[16] = { 0 };
uint8_t answer[12];
if (bridge_input_clk == NULL)
return -1;
- memset(command, 0, sizeof(command));
-
command[0] = STLINK_BRIDGE_COMMAND;
command[1] = STLINK_BRIDGE_GET_CLOCK;
command[2] = STLINK_SPI_COM;
@@ -227,9 +225,7 @@
static int stlinkv3_check_version(enum fw_version_check_result *result)
{
uint8_t answer[12];
- uint8_t command[16];
-
- memset(command, 0, sizeof(command));
+ uint8_t command[16] = { 0 };
command[0] = ST_GETVERSION_EXT;
command[1] = 0x80;
@@ -246,7 +242,7 @@
static int stlinkv3_spi_open(uint16_t reqested_freq_in_kHz)
{
- uint8_t command[16];
+ uint8_t command[16] = { 0 };
uint8_t answer[2];
uint16_t SCK_freq_in_kHz;
enum spi_prescaler prescaler;
@@ -273,8 +269,6 @@
}
msg_pinfo("SCK frequency set to %d kHz\n", SCK_freq_in_kHz);
- memset(command, 0, sizeof(command));
-
command[0] = STLINK_BRIDGE_COMMAND;
command[1] = STLINK_BRIDGE_INIT_SPI;
command[2] = SPI_DIRECTION_2LINES_FULLDUPLEX;
@@ -291,11 +285,9 @@
static int stlinkv3_get_last_readwrite_status(uint32_t *status)
{
- uint8_t command[16];
+ uint8_t command[16] = { 0 };
uint16_t answer[4];
- memset(command, 0, sizeof(command));
-
command[0] = STLINK_BRIDGE_COMMAND;
command[1] = STLINK_BRIDGE_GET_RWCMD_STATUS;
@@ -310,11 +302,9 @@
static int stlinkv3_spi_set_SPI_NSS(enum spi_nss_level nss_level)
{
- uint8_t command[16];
+ uint8_t command[16] = { 0 };
uint8_t answer[2];
- memset(command, 0, sizeof(command));
-
command[0] = STLINK_BRIDGE_COMMAND;
command[1] = STLINK_BRIDGE_CS_SPI;
command[2] = (uint8_t) (nss_level);
@@ -330,7 +320,7 @@
const unsigned char *write_arr,
unsigned char *read_arr)
{
- uint8_t command[16];
+ uint8_t command[16] = { 0 };
int rc = 0;
int actual_length = 0;
uint32_t rw_status = 0;
@@ -341,8 +331,6 @@
return -1;
}
- memset(command, 0, sizeof(command));
-
command[0] = STLINK_BRIDGE_COMMAND;
command[1] = STLINK_BRIDGE_WRITE_SPI;
command[2] = (uint8_t)write_cnt;
@@ -431,11 +419,9 @@
static int stlinkv3_spi_shutdown(void *data)
{
- uint8_t command[16];
+ uint8_t command[16] = { 0 };
uint8_t answer[2];
- memset(command, 0, sizeof(command));
-
command[0] = STLINK_BRIDGE_COMMAND;
command[1] = STLINK_BRIDGE_CLOSE;
command[2] = STLINK_SPI_COM;