Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: cleanup PacketResponseNG init #2536

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions client/src/cmdhfmfhard.c
Original file line number Diff line number Diff line change
@@ -1565,18 +1565,8 @@ static int acquire_nonces(uint8_t blockNo, uint8_t keyType, uint8_t *key, uint8_
FILE *fnonces = NULL;

// init to ZERO
PacketResponseNG resp = {
.cmd = 0,
.length = 0,
.magic = 0,
.status = 0,
.crc = 0,
.ng = false,
};
resp.oldarg[0] = 0;
resp.oldarg[1] = 0;
resp.oldarg[2] = 0;
memset(resp.data.asBytes, 0, PM3_CMD_DATA_SIZE);
PacketResponseNG resp;
memset(&resp, 0, sizeof(resp));

uint8_t write_buf[9];
char progress_text[80];
13 changes: 2 additions & 11 deletions client/src/cmdlf.c
Original file line number Diff line number Diff line change
@@ -426,18 +426,9 @@ int CmdLFCommandRead(const char *Cmd) {
clearCommandBuffer();
SendCommandNG(CMD_LF_MOD_THEN_ACQ_RAW_ADC, (uint8_t *)&payload, PAYLOAD_HEADER_SIZE + cmd_len + 1);

PacketResponseNG resp;
// init to ZERO
resp.cmd = 0,
resp.length = 0,
resp.magic = 0,
resp.status = 0,
resp.crc = 0,
resp.ng = false,
resp.oldarg[0] = 0;
resp.oldarg[1] = 0;
resp.oldarg[2] = 0;
memset(resp.data.asBytes, 0, PM3_CMD_DATA_SIZE);
PacketResponseNG resp;
memset(&resp, 0, sizeof(resp));

i = 10;
// 20sec wait loop
13 changes: 2 additions & 11 deletions client/src/cmdlfem4x50.c
Original file line number Diff line number Diff line change
@@ -1259,18 +1259,9 @@ static int CmdEM4x50Sim(const char *Cmd) {

PrintAndLogEx(INFO, "Press " _GREEN_("pm3 button") " or " _GREEN_("<Enter>") " to abort simulation");
PacketResponseNG resp;
// init to ZERO
resp.cmd = 0,
resp.length = 0,
resp.magic = 0,
resp.status = 0,
resp.crc = 0,
resp.ng = false,
resp.oldarg[0] = 0;
resp.oldarg[1] = 0;
resp.oldarg[2] = 0;
memset(resp.data.asBytes, 0, PM3_CMD_DATA_SIZE);
PacketResponseNG resp;
memset(&resp, 0, sizeof(resp));

bool keypress;
do {
28 changes: 5 additions & 23 deletions client/src/comms.c
Original file line number Diff line number Diff line change
@@ -1030,18 +1030,9 @@ size_t WaitForRawDataTimeout(uint8_t *buffer, size_t len, size_t ms_timeout, boo
*/
bool WaitForResponseTimeoutW(uint32_t cmd, PacketResponseNG *response, size_t ms_timeout, bool show_warning) {

PacketResponseNG resp;
// init to ZERO
resp.cmd = 0,
resp.length = 0,
resp.magic = 0,
resp.status = 0,
resp.crc = 0,
resp.ng = false,
resp.oldarg[0] = 0;
resp.oldarg[1] = 0;
resp.oldarg[2] = 0;
memset(resp.data.asBytes, 0, PM3_CMD_DATA_SIZE);
PacketResponseNG resp;
memset(&resp, 0, sizeof(resp));

if (response == NULL) {
response = &resp;
@@ -1118,23 +1109,14 @@ bool GetFromDevice(DeviceMemType_t memtype, uint8_t *dest, uint32_t bytes, uint3

if (dest == NULL) return false;

// init to ZERO
PacketResponseNG resp;
memset(&resp, 0, sizeof(resp));

if (response == NULL) {
response = &resp;
}

// init to ZERO
resp.cmd = 0,
resp.length = 0,
resp.magic = 0,
resp.status = 0,
resp.crc = 0,
resp.ng = false,
resp.oldarg[0] = 0;
resp.oldarg[1] = 0;
resp.oldarg[2] = 0;
memset(resp.data.asBytes, 0, PM3_CMD_DATA_SIZE);

if (bytes == 0) return true;