mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-02 14:33:18 +02:00
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> Reviewed-on: https://review.coreboot.org/c/flashrom/+/55267 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
@ -156,14 +156,12 @@ static int stlinkv3_command(uint8_t *command, size_t command_length,
|
||||
*/
|
||||
static int stlinkv3_get_clk(uint32_t *bridge_input_clk, libusb_device_handle *stlinkv3_handle)
|
||||
{
|
||||
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;
|
||||
@ -234,9 +232,7 @@ static int stlinkv3_spi_calc_prescaler(uint16_t reqested_freq_in_kHz,
|
||||
static int stlinkv3_check_version(enum fw_version_check_result *result, libusb_device_handle *stlinkv3_handle)
|
||||
{
|
||||
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;
|
||||
@ -256,7 +252,7 @@ static int stlinkv3_check_version(enum fw_version_check_result *result, libusb_d
|
||||
|
||||
static int stlinkv3_spi_open(uint16_t reqested_freq_in_kHz, libusb_device_handle *stlinkv3_handle)
|
||||
{
|
||||
uint8_t command[16];
|
||||
uint8_t command[16] = { 0 };
|
||||
uint8_t answer[2];
|
||||
uint16_t SCK_freq_in_kHz;
|
||||
enum spi_prescaler prescaler;
|
||||
@ -284,8 +280,6 @@ static int stlinkv3_spi_open(uint16_t reqested_freq_in_kHz, libusb_device_handle
|
||||
}
|
||||
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;
|
||||
@ -305,11 +299,9 @@ static int stlinkv3_spi_open(uint16_t reqested_freq_in_kHz, libusb_device_handle
|
||||
|
||||
static int stlinkv3_get_last_readwrite_status(uint32_t *status, libusb_device_handle *stlinkv3_handle)
|
||||
{
|
||||
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;
|
||||
|
||||
@ -325,11 +317,9 @@ static int stlinkv3_get_last_readwrite_status(uint32_t *status, libusb_device_ha
|
||||
|
||||
static int stlinkv3_spi_set_SPI_NSS(enum spi_nss_level nss_level, libusb_device_handle *stlinkv3_handle)
|
||||
{
|
||||
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);
|
||||
@ -350,7 +340,7 @@ static int stlinkv3_spi_transmit(const struct flashctx *flash,
|
||||
{
|
||||
struct stlinkv3_spi_data *stlinkv3_data = flash->mst->spi.data;
|
||||
libusb_device_handle *stlinkv3_handle = stlinkv3_data->handle;
|
||||
uint8_t command[16];
|
||||
uint8_t command[16] = { 0 };
|
||||
int rc = 0;
|
||||
int actual_length = 0;
|
||||
uint32_t rw_status = 0;
|
||||
@ -361,8 +351,6 @@ static int stlinkv3_spi_transmit(const struct flashctx *flash,
|
||||
return -1;
|
||||
}
|
||||
|
||||
memset(command, 0, sizeof(command));
|
||||
|
||||
command[0] = STLINK_BRIDGE_COMMAND;
|
||||
command[1] = STLINK_BRIDGE_WRITE_SPI;
|
||||
command[2] = (uint8_t)write_cnt;
|
||||
@ -452,11 +440,9 @@ transmit_err:
|
||||
static int stlinkv3_spi_shutdown(void *data)
|
||||
{
|
||||
struct stlinkv3_spi_data *stlinkv3_data = 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;
|
||||
|
Reference in New Issue
Block a user