From 607f1bb26c7df4d0686b5d467f838f2dd1c7ee41 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Sat, 24 May 2025 22:49:46 +0200 Subject: [PATCH] style --- client/src/cmdhf14a.c | 4 ++-- client/src/cmdhflto.c | 2 +- client/src/cmdhfmf.c | 22 ++++++++++++++++------ client/src/cmdhfmfu.c | 8 +++++--- client/src/cmdhftexkom.c | 2 +- client/src/cmdhfthinfilm.c | 2 +- client/src/cmdhw.c | 6 +++++- client/src/cmdlf.c | 10 +++++++--- client/src/cmdlft55xx.c | 10 +++++----- client/src/cmdlfviking.c | 2 +- client/src/cmdsmartcard.c | 6 +++--- client/src/cmdusart.c | 6 +++--- client/src/comms.c | 4 ++-- client/src/scripting.c | 2 +- 14 files changed, 53 insertions(+), 33 deletions(-) diff --git a/client/src/cmdhf14a.c b/client/src/cmdhf14a.c index 634e3c0ba..6e30b0db9 100644 --- a/client/src/cmdhf14a.c +++ b/client/src/cmdhf14a.c @@ -914,7 +914,7 @@ int CmdHF14ASim(const char *Cmd) { bool keypress = kbd_enter_pressed(); while (keypress == false) { - if (WaitForResponseTimeout(CMD_HF_MIFARE_SIMULATE, &resp, 1500) == 0) + if (WaitForResponseTimeout(CMD_HF_MIFARE_SIMULATE, &resp, 1500) == false) continue; if (resp.status != PM3_SUCCESS) @@ -4037,7 +4037,7 @@ int CmdHF14AAIDSim(const char *Cmd) { bool keypress = kbd_enter_pressed(); while (keypress == false) { - if (WaitForResponseTimeout(CMD_HF_MIFARE_SIMULATE, &resp, 1500) == 0) { + if (WaitForResponseTimeout(CMD_HF_MIFARE_SIMULATE, &resp, 1500) == false) { continue; } diff --git a/client/src/cmdhflto.c b/client/src/cmdhflto.c index b56a0d34c..51ede17ca 100644 --- a/client/src/cmdhflto.c +++ b/client/src/cmdhflto.c @@ -131,7 +131,7 @@ static int lto_send_cmd_raw(uint8_t *cmd, uint8_t len, uint8_t *response, uint16 SendCommandMIX(CMD_HF_ISO14443A_READER, arg0, arg1, 0, cmd, len); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_ACK, &resp, 1500)) { + if (WaitForResponseTimeout(CMD_ACK, &resp, 1500) == false) { if (verbose) PrintAndLogEx(WARNING, "timeout while waiting for reply"); return PM3_ETIMEOUT; } diff --git a/client/src/cmdhfmf.c b/client/src/cmdhfmf.c index 70dc058f8..41d4a1a96 100644 --- a/client/src/cmdhfmf.c +++ b/client/src/cmdhfmf.c @@ -1915,9 +1915,13 @@ static int CmdHF14AMfNested(const char *Cmd) { //TODO: single mode broken? can't SendCommandNG(CMD_HF_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t)); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_HF_MIFARE_READBL, &resp, 1500)) continue; + if (WaitForResponseTimeout(CMD_HF_MIFARE_READBL, &resp, 1500) == false) { + continue; + } - if (resp.status != PM3_SUCCESS) continue; + if (resp.status != PM3_SUCCESS) { + continue; + } uint8_t *data = resp.data.asBytes; key64 = bytes_to_num(data + 10, 6); @@ -4005,9 +4009,13 @@ static int CmdHF14AMfChk(const char *Cmd) { SendCommandNG(CMD_HF_MIFARE_READBL, (uint8_t *)&payload, sizeof(mf_readblock_t)); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_HF_MIFARE_READBL, &resp, 1500)) continue; + if (WaitForResponseTimeout(CMD_HF_MIFARE_READBL, &resp, 1500) == false) { + continue; + } - if (resp.status != PM3_SUCCESS) continue; + if (resp.status != PM3_SUCCESS) { + continue; + } uint8_t *data = resp.data.asBytes; key64 = bytes_to_num(data + 10, MIFARE_KEY_SIZE); @@ -4070,7 +4078,7 @@ out: // Disable fast mode and send a dummy command to make it effective g_conn.block_after_ACK = false; SendCommandNG(CMD_PING, NULL, 0); - if (!WaitForResponseTimeout(CMD_PING, NULL, 1000)) { + if (WaitForResponseTimeout(CMD_PING, NULL, 1000) == false) { PrintAndLogEx(WARNING, "command execution time out"); return PM3_ETIMEOUT; } @@ -6176,7 +6184,9 @@ static int CmdHF14AMfice(const char *Cmd) { clearCommandBuffer(); SendCommandMIX(CMD_HF_MIFARE_ACQ_NONCES, blockNo + keyType * 0x100, trgBlockNo + trgKeyType * 0x100, flags, NULL, 0); - if (!WaitForResponseTimeout(CMD_ACK, &resp, 3000)) goto out; + if (WaitForResponseTimeout(CMD_ACK, &resp, 3000) == false) { + goto out; + } if (resp.oldarg[0]) goto out; uint32_t items = resp.oldarg[2]; diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index f85362a23..0c3fc2e7e 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -4628,7 +4628,7 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) { // we be getting ACK that we are silently ignoring here.. - if (!WaitForResponseTimeout(CMD_HF_MFU_OTP_TEAROFF, &resp, 2000)) { + if (WaitForResponseTimeout(CMD_HF_MFU_OTP_TEAROFF, &resp, 2000) == false) { PrintAndLogEx(WARNING, "Failed"); return PM3_ESOFT; } @@ -4649,11 +4649,13 @@ static int CmdHF14AMfuOtpTearoff(const char *Cmd) { got_post = true; } } - if (! got_post) { + + if (!got_post) { PrintAndLogEx(FAILED, "Failed to read block BEFORE"); error_retries++; continue; // try again } + error_retries = 0; char prestr[20] = {0}; snprintf(prestr, sizeof(prestr), "%s", sprint_hex_inrow(pre, sizeof(pre))); @@ -4936,7 +4938,7 @@ static int CmdHF14AMfuEv1CounterTearoff(const char *Cmd) { clearCommandBuffer(); PacketResponseNG resp; SendCommandNG(CMD_HF_MFU_COUNTER_TEAROFF, (uint8_t*)&payload, sizeof(payload)); - if (!WaitForResponseTimeout(CMD_HF_MFU_COUNTER_TEAROFF, &resp, 2000)) { + if (WaitForResponseTimeout(CMD_HF_MFU_COUNTER_TEAROFF, &resp, 2000) == false) { PrintAndLogEx(WARNING, "\ntear off command failed"); continue; } diff --git a/client/src/cmdhftexkom.c b/client/src/cmdhftexkom.c index b033050ba..6993d70cf 100644 --- a/client/src/cmdhftexkom.c +++ b/client/src/cmdhftexkom.c @@ -664,7 +664,7 @@ static int CmdHFTexkomReader(const char *Cmd) { SendCommandNG(CMD_HF_ACQ_RAW_ADC, (uint8_t *)&samplesCount, sizeof(uint32_t)); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_HF_ACQ_RAW_ADC, &resp, 2500)) { + if (WaitForResponseTimeout(CMD_HF_ACQ_RAW_ADC, &resp, 2500) == false) { PrintAndLogEx(WARNING, "command execution time out"); return PM3_ETIMEOUT; } diff --git a/client/src/cmdhfthinfilm.c b/client/src/cmdhfthinfilm.c index 4e3bafdb9..fa7921dc6 100644 --- a/client/src/cmdhfthinfilm.c +++ b/client/src/cmdhfthinfilm.c @@ -187,7 +187,7 @@ int CmdHfThinFilmSim(const char *Cmd) { int ret; while (!(ret = kbd_enter_pressed())) { - if (WaitForResponseTimeout(CMD_HF_THINFILM_SIMULATE, &resp, 500) == 0) { + if (WaitForResponseTimeout(CMD_HF_THINFILM_SIMULATE, &resp, 500) == false) { continue; } diff --git a/client/src/cmdhw.c b/client/src/cmdhw.c index 7dd2cee2f..35dbde0d1 100644 --- a/client/src/cmdhw.c +++ b/client/src/cmdhw.c @@ -928,15 +928,19 @@ static int CmdTune(const char *Cmd) { SendCommandNG(CMD_MEASURE_ANTENNA_TUNING, NULL, 0); PacketResponseNG resp; PrintAndLogEx(INPLACE, "% 3i", timeout_max - timeout); - while (!WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING, &resp, 500)) { + + while (WaitForResponseTimeout(CMD_MEASURE_ANTENNA_TUNING, &resp, 500) == false) { + fflush(stdout); if (timeout >= timeout_max) { PrintAndLogEx(WARNING, "\nNo response from Proxmark3. Aborting..."); return PM3_ETIMEOUT; } + timeout++; PrintAndLogEx(INPLACE, "% 3i", timeout_max - timeout); } + PrintAndLogEx(NORMAL, ""); if (resp.status != PM3_SUCCESS) { diff --git a/client/src/cmdlf.c b/client/src/cmdlf.c index 5a2278859..0282f6c72 100644 --- a/client/src/cmdlf.c +++ b/client/src/cmdlf.c @@ -435,15 +435,17 @@ int CmdLFCommandRead(const char *Cmd) { i = 10; // 20sec wait loop - while (!WaitForResponseTimeout(CMD_LF_MOD_THEN_ACQ_RAW_ADC, &resp, 2000) && i != 0) { + while (WaitForResponseTimeout(CMD_LF_MOD_THEN_ACQ_RAW_ADC, &resp, 2000) == false && i != 0) { if (verbose) { PrintAndLogEx(NORMAL, "." NOLF); } i--; } + if (verbose) { PrintAndLogEx(NORMAL, ""); } + if (resp.status != PM3_SUCCESS) { PrintAndLogEx(WARNING, "command failed."); return PM3_ESOFT; @@ -595,7 +597,7 @@ int lf_getconfig(sample_config *config) { SendCommandNG(CMD_LF_SAMPLING_GET_CONFIG, NULL, 0); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_LF_SAMPLING_GET_CONFIG, &resp, 2000)) { + if (WaitForResponseTimeout(CMD_LF_SAMPLING_GET_CONFIG, &resp, 2000) == false) { PrintAndLogEx(WARNING, "command execution time out"); return PM3_ETIMEOUT; } @@ -797,10 +799,12 @@ static int lf_read_internal(bool realtime, bool verbose, uint64_t samples) { payload.samples = (samples > MAX_LF_SAMPLES) ? MAX_LF_SAMPLES : samples; SendCommandNG(CMD_LF_ACQ_RAW_ADC, (uint8_t *)&payload, sizeof(payload)); PacketResponseNG resp; + if (is_trigger_threshold_set) { WaitForResponse(CMD_LF_ACQ_RAW_ADC, &resp); } else { - if (!WaitForResponseTimeout(CMD_LF_ACQ_RAW_ADC, &resp, 2500)) { + + if (WaitForResponseTimeout(CMD_LF_ACQ_RAW_ADC, &resp, 2500) == false) { PrintAndLogEx(WARNING, "(lf_read) command execution time out"); return PM3_ETIMEOUT; } diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c index 7da9967f2..96184c87f 100644 --- a/client/src/cmdlft55xx.c +++ b/client/src/cmdlft55xx.c @@ -466,7 +466,7 @@ int clone_t55xx_tag(uint32_t *blockdata, uint8_t numblocks) { ng.flags = 0; SendCommandNG(CMD_LF_T55XX_WRITEBL, (uint8_t *)&ng, sizeof(ng)); - if (!WaitForResponseTimeout(CMD_LF_T55XX_WRITEBL, &resp, T55XX_WRITE_TIMEOUT)) { + if (WaitForResponseTimeout(CMD_LF_T55XX_WRITEBL, &resp, T55XX_WRITE_TIMEOUT) == false) { PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation."); return PM3_ETIMEOUT; } @@ -664,7 +664,7 @@ int t55xxWrite(uint8_t block, bool page1, bool usepwd, bool testMode, uint32_t p PacketResponseNG resp; clearCommandBuffer(); SendCommandNG(CMD_LF_T55XX_WRITEBL, (uint8_t *)&ng, sizeof(ng)); - if (!WaitForResponseTimeout(CMD_LF_T55XX_WRITEBL, &resp, 2000)) { + if (WaitForResponseTimeout(CMD_LF_T55XX_WRITEBL, &resp, 2000) == false) { PrintAndLogEx(ERR, "Error occurred, device did not ACK write operation."); return PM3_ETIMEOUT; } @@ -1992,7 +1992,7 @@ static int CmdT55xxDangerousRaw(const char *Cmd) { PacketResponseNG resp; clearCommandBuffer(); SendCommandNG(CMD_LF_T55XX_DANGERRAW, (uint8_t *)&ng, sizeof(ng)); - if (!WaitForResponseTimeout(CMD_LF_T55XX_DANGERRAW, &resp, 2000)) { + if (WaitForResponseTimeout(CMD_LF_T55XX_DANGERRAW, &resp, 2000) == false) { PrintAndLogEx(ERR, "Error occurred, device did not ACK write operation."); return PM3_ETIMEOUT; } @@ -2840,7 +2840,7 @@ bool AcquireData(uint8_t page, uint8_t block, bool pwdmode, uint32_t password, u clearCommandBuffer(); SendCommandNG(CMD_LF_T55XX_READBL, (uint8_t *)&payload, sizeof(payload)); - if (!WaitForResponseTimeout(CMD_LF_T55XX_READBL, NULL, 2500)) { + if (WaitForResponseTimeout(CMD_LF_T55XX_READBL, NULL, 2500) == false) { PrintAndLogEx(WARNING, "command execution time out"); return false; } @@ -3435,7 +3435,7 @@ static int CmdT55xxChkPwds(const char *Cmd) { PacketResponseNG resp; uint8_t timeout = 0; - while (!WaitForResponseTimeout(CMD_LF_T55XX_CHK_PWDS, &resp, 2000)) { + while (WaitForResponseTimeout(CMD_LF_T55XX_CHK_PWDS, &resp, 2000) == false) { timeout++; PrintAndLogEx(NORMAL, "." NOLF); if (timeout > 180) { diff --git a/client/src/cmdlfviking.c b/client/src/cmdlfviking.c index 83f34862a..6807e828c 100644 --- a/client/src/cmdlfviking.c +++ b/client/src/cmdlfviking.c @@ -172,7 +172,7 @@ static int CmdVikingClone(const char *Cmd) { SendCommandNG(CMD_LF_VIKING_CLONE, (uint8_t *)&payload, sizeof(payload)); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_LF_VIKING_CLONE, &resp, T55XX_WRITE_TIMEOUT)) { + if (WaitForResponseTimeout(CMD_LF_VIKING_CLONE, &resp, T55XX_WRITE_TIMEOUT) == false) { PrintAndLogEx(ERR, "Error occurred, device did not respond during write operation."); return PM3_ETIMEOUT; } diff --git a/client/src/cmdsmartcard.c b/client/src/cmdsmartcard.c index ed515a04a..46b467f94 100644 --- a/client/src/cmdsmartcard.c +++ b/client/src/cmdsmartcard.c @@ -663,7 +663,7 @@ static int CmdSmartUpgrade(const char *Cmd) { clearCommandBuffer(); SendCommandNG(CMD_SMART_UPLOAD, (uint8_t *)&upload, sizeof(upload)); - if (!WaitForResponseTimeout(CMD_SMART_UPLOAD, &resp, 2000)) { + if (WaitForResponseTimeout(CMD_SMART_UPLOAD, &resp, 2000) == false) { PrintAndLogEx(WARNING, "timeout while waiting for reply"); free(firmware); return PM3_ETIMEOUT; @@ -695,7 +695,7 @@ static int CmdSmartUpgrade(const char *Cmd) { free(firmware); SendCommandNG(CMD_SMART_UPGRADE, (uint8_t *)&payload, sizeof(payload)); - if (!WaitForResponseTimeout(CMD_SMART_UPGRADE, &resp, 2500)) { + if (WaitForResponseTimeout(CMD_SMART_UPGRADE, &resp, 2500) == false) { PrintAndLogEx(WARNING, "timeout while waiting for reply"); return PM3_ETIMEOUT; } @@ -876,7 +876,7 @@ static int CmdSmartSetClock(const char *Cmd) { clearCommandBuffer(); SendCommandNG(CMD_SMART_SETCLOCK, (uint8_t *)&payload, sizeof(payload)); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_SMART_SETCLOCK, &resp, 2500)) { + if (WaitForResponseTimeout(CMD_SMART_SETCLOCK, &resp, 2500) == false) { PrintAndLogEx(WARNING, "smart card select failed"); return PM3_ETIMEOUT; } diff --git a/client/src/cmdusart.c b/client/src/cmdusart.c index 357d20c32..b3e2bdc5d 100644 --- a/client/src/cmdusart.c +++ b/client/src/cmdusart.c @@ -35,7 +35,7 @@ static int usart_tx(uint8_t *data, size_t len) { clearCommandBuffer(); SendCommandNG(CMD_USART_TX, data, len); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_USART_TX, &resp, 1000)) { + if (WaitForResponseTimeout(CMD_USART_TX, &resp, 1000) == false) { return PM3_ETIMEOUT; } return resp.status; @@ -49,7 +49,7 @@ static int usart_rx(uint8_t *data, size_t *len, uint32_t waittime) { payload.waittime = waittime; SendCommandNG(CMD_USART_RX, (uint8_t *)&payload, sizeof(payload)); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_USART_RX, &resp, waittime + 500)) { + if (WaitForResponseTimeout(CMD_USART_RX, &resp, waittime + 500) == false) { return PM3_ETIMEOUT; } if (resp.status == PM3_SUCCESS) { @@ -99,7 +99,7 @@ static int set_usart_config(uint32_t baudrate, uint8_t parity) { payload.parity = parity; SendCommandNG(CMD_USART_CONFIG, (uint8_t *)&payload, sizeof(payload)); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_USART_CONFIG, &resp, 1000)) { + if (WaitForResponseTimeout(CMD_USART_CONFIG, &resp, 1000) == false) { return PM3_ETIMEOUT; } return resp.status; diff --git a/client/src/comms.c b/client/src/comms.c index e2684100f..2ded55ebc 100644 --- a/client/src/comms.c +++ b/client/src/comms.c @@ -871,7 +871,7 @@ int TestProxmark(pm3_device_t *dev) { #endif PacketResponseNG resp; - if (WaitForResponseTimeoutW(CMD_PING, &resp, timeout, false) == 0) { + if (WaitForResponseTimeoutW(CMD_PING, &resp, timeout, false) == false) { return PM3_ETIMEOUT; } @@ -881,7 +881,7 @@ int TestProxmark(pm3_device_t *dev) { } SendCommandNG(CMD_CAPABILITIES, NULL, 0); - if (WaitForResponseTimeoutW(CMD_CAPABILITIES, &resp, 1000, false) == 0) { + if (WaitForResponseTimeoutW(CMD_CAPABILITIES, &resp, 1000, false) == false) { return PM3_ETIMEOUT; } diff --git a/client/src/scripting.c b/client/src/scripting.c index 251a0d915..1cd1ed1a0 100644 --- a/client/src/scripting.c +++ b/client/src/scripting.c @@ -303,7 +303,7 @@ static int l_GetFromFlashMemSpiffs(lua_State *L) { // get size from spiffs itself ! SendCommandNG(CMD_SPIFFS_STAT, (uint8_t *)destfilename, 32); PacketResponseNG resp; - if (!WaitForResponseTimeout(CMD_SPIFFS_STAT, &resp, 2000)) + if (WaitForResponseTimeout(CMD_SPIFFS_STAT, &resp, 2000) == false) return returnToLuaWithError(L, "No response from the device"); len = resp.data.asDwords[0];