cosmetics

This commit is contained in:
tharexde 2020-11-20 22:03:19 +01:00
commit 86b9d2c620
2 changed files with 12 additions and 22 deletions

View file

@ -1180,7 +1180,6 @@ static int write(uint32_t word, uint32_t addresses) {
// for saving data and should return with ACK // for saving data and should return with ACK
if (check_ack(false)) if (check_ack(false))
return PM3_SUCCESS; return PM3_SUCCESS;
} }
} }
} else { } else {
@ -1224,7 +1223,6 @@ static int write_password(uint32_t password, uint32_t new_password) {
if (check_ack(false)) if (check_ack(false))
if (check_ack(false)) if (check_ack(false))
return PM3_SUCCESS; return PM3_SUCCESS;
} }
} }
} else { } else {
@ -1232,7 +1230,7 @@ static int write_password(uint32_t password, uint32_t new_password) {
Dbprintf("error in command request"); Dbprintf("error in command request");
} }
return PM3_ESOFT; return PM3_EFAILED;
} }
void em4x50_write(em4x50_data_t *etd) { void em4x50_write(em4x50_data_t *etd) {

View file

@ -1187,10 +1187,11 @@ int CmdEM4x50Restore(const char *Cmd) {
int uidLen = 0, fnLen = 0, pwdLen = 0, status = 0; int uidLen = 0, fnLen = 0, pwdLen = 0, status = 0;
uint8_t pwd[4] = {0x0}, uid[4] = {0x0}; uint8_t pwd[4] = {0x0}, uid[4] = {0x0};
uint8_t data[DUMP_FILESIZE] = {0x0};
size_t bytes_read = 0; size_t bytes_read = 0;
char filename[FILE_PATH_SIZE] = {0}; char filename[FILE_PATH_SIZE] = {0};
em4x50_data_t etd = {.pwd_given = false}; em4x50_data_t etd = {.pwd_given = false};
uint8_t data[DUMP_FILESIZE] = {0x0}; PacketResponseNG resp;
CLIParserContext *ctx; CLIParserContext *ctx;
CLIParserInit(&ctx, "lf em 4x50_restore", CLIParserInit(&ctx, "lf em 4x50_restore",
@ -1260,25 +1261,20 @@ int CmdEM4x50Restore(const char *Cmd) {
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_LF_EM4X50_RESTORE, (uint8_t *)&etd, sizeof(etd)); SendCommandNG(CMD_LF_EM4X50_RESTORE, (uint8_t *)&etd, sizeof(etd));
PacketResponseNG resp;
if (!WaitForResponseTimeout(CMD_LF_EM4X50_RESTORE, &resp, 2 * TIMEOUT)) { if (!WaitForResponseTimeout(CMD_LF_EM4X50_RESTORE, &resp, 2 * TIMEOUT)) {
PrintAndLogEx(FAILED, "Timeout while waiting for reply."); PrintAndLogEx(FAILED, "Timeout while waiting for reply.");
return PM3_ETIMEOUT; return PM3_ETIMEOUT;
} }
status = resp.status; status = resp.status;
if (status == PM3_SUCCESS)
if (status == PM3_ETEAROFF) {
return PM3_SUCCESS;
} else if (status != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "Restore " _RED_("failed"));
return status;
}
PrintAndLogEx(SUCCESS, "Restore " _GREEN_("ok")); PrintAndLogEx(SUCCESS, "Restore " _GREEN_("ok"));
else
PrintAndLogEx(FAILED, "Restore " _RED_("failed"));
PrintAndLogEx(INFO, "Finished restoring"); PrintAndLogEx(INFO, "Finished restoring");
return PM3_SUCCESS; return status;
} }
//============================================================================== //==============================================================================
@ -1343,16 +1339,12 @@ int CmdEM4x50Sim(const char *Cmd) {
clearCommandBuffer(); clearCommandBuffer();
SendCommandNG(CMD_LF_EM4X50_SIM, 0, 0); SendCommandNG(CMD_LF_EM4X50_SIM, 0, 0);
WaitForResponse(CMD_LF_EM4X50_SIM, &resp); WaitForResponse(CMD_LF_EM4X50_SIM, &resp);
if (resp.status == PM3_ETEAROFF) { if (resp.status == PM3_SUCCESS)
return PM3_SUCCESS;
} else if (resp.status == PM3_ENODATA) {
PrintAndLogEx(FAILED, "No valid em4x50 data in flash memory.");
return PM3_ENODATA;
}
PrintAndLogEx(INFO, "Done"); PrintAndLogEx(INFO, "Done");
return PM3_SUCCESS; else
PrintAndLogEx(FAILED, "No valid em4x50 data in flash memory.");
return resp.status;
} }