From b0dbbd3683afeafcf45bfb79c9a2c0a01f88d14d Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sat, 13 Jul 2019 00:38:30 +0200 Subject: [PATCH] make style --- armsrc/appmain.c | 4 ++-- armsrc/hitag2.c | 2 +- armsrc/lfsampling.c | 24 +++++++++---------- armsrc/mifaresim.c | 4 ++-- bootrom/bootrom.c | 2 +- client/cmdhf15.c | 2 +- client/cmdlf.c | 6 ++--- client/cmdlfem4x.c | 10 ++++---- client/cmdlft55xx.c | 8 +++---- client/cmdusart.c | 2 +- client/comms.c | 2 +- client/deprecated-hid-flasher/flasher/sleep.h | 22 ++++++++--------- client/flash.c | 2 +- client/util.c | 15 ++++++------ common/lfdemod.c | 6 ++--- 15 files changed, 55 insertions(+), 56 deletions(-) diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 3213fbe14..facce653c 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -347,9 +347,9 @@ void SendVersion(void) { strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1); #if defined(__clang__) - strncat(VersionString, " compiled with Clang/LLVM "__VERSION__"\n", sizeof(VersionString) - strlen(VersionString) - 1); + strncat(VersionString, " compiled with Clang/LLVM "__VERSION__"\n", sizeof(VersionString) - strlen(VersionString) - 1); #elif defined(__GNUC__) || defined(__GNUG__) - strncat(VersionString, " compiled with GCC "__VERSION__"\n", sizeof(VersionString) - strlen(VersionString) - 1); + strncat(VersionString, " compiled with GCC "__VERSION__"\n", sizeof(VersionString) - strlen(VersionString) - 1); #endif strncat(VersionString, "\n [ FPGA ]\n ", sizeof(VersionString) - strlen(VersionString) - 1); diff --git a/armsrc/hitag2.c b/armsrc/hitag2.c index 46e9a43dd..682dd950a 100644 --- a/armsrc/hitag2.c +++ b/armsrc/hitag2.c @@ -434,7 +434,7 @@ static bool hitag2_password(uint8_t *rx, const size_t rxlen, uint8_t *tx, size_t break; } } - + return true; } diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c index c5a075e7a..c88401229 100644 --- a/armsrc/lfsampling.c +++ b/armsrc/lfsampling.c @@ -136,11 +136,11 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag uint32_t sample_total_numbers = 0; uint32_t sample_total_saved = 0; uint32_t cancel_counter = 0; - + uint16_t checker = 0; - + while (true) { - if ( checker == 1000 ) { + if (checker == 1000) { if (BUTTON_PRESS() || data_available()) break; else @@ -148,7 +148,7 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag } else { ++checker; } - + WDT_HIT(); if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) { @@ -293,11 +293,11 @@ void doT55x7Acquisition(size_t sample_size) { bool startFound = false; bool highFound = false; bool lowFound = false; - + uint16_t checker = 0; - - while ( skipCnt < 1000 && (i < bufsize)) { - if ( checker == 1000 ) { + + while (skipCnt < 1000 && (i < bufsize)) { + if (checker == 1000) { if (BUTTON_PRESS() || data_available()) break; else @@ -371,9 +371,9 @@ void doCotagAcquisition(size_t sample_size) { uint16_t noise_counter = 0; uint16_t checker = 0; - + while ((i < bufsize) && (noise_counter < (COTAG_T1 << 1))) { - if ( checker == 1000 ) { + if (checker == 1000) { if (BUTTON_PRESS() || data_available()) break; else @@ -431,9 +431,9 @@ uint32_t doCotagAcquisitionManchester() { uint8_t curr = 0, prev = 0; uint16_t noise_counter = 0; uint16_t checker = 0; - + while ((sample_counter < bufsize) && (noise_counter < (COTAG_T1 << 1))) { - if ( checker == 1000 ) { + if (checker == 1000) { if (BUTTON_PRESS() || data_available()) break; else diff --git a/armsrc/mifaresim.c b/armsrc/mifaresim.c index 714beb284..8f21882be 100644 --- a/armsrc/mifaresim.c +++ b/armsrc/mifaresim.c @@ -606,8 +606,8 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain) { if (receivedCmd_len == 9 && receivedCmd[1] == 0x70) { if (memcmp(&receivedCmd[2], responses[uid_index].response, 4) == 0) { bool cl_finished = (uid_len == 4 && uid_index == UIDBCC1) || - (uid_len == 7 && uid_index == UIDBCC2) || - (uid_len == 10 && uid_index == UIDBCC3); + (uid_len == 7 && uid_index == UIDBCC2) || + (uid_len == 10 && uid_index == UIDBCC3); EmSendPrecompiledCmd(&responses[cl_finished ? SAK : SAKuid]); if (DBGLEVEL >= DBG_EXTENDED) Dbprintf("SELECT CLx %02x%02x%02x%02x received", receivedCmd[2], receivedCmd[3], receivedCmd[4], receivedCmd[5]); if (cl_finished) { diff --git a/bootrom/bootrom.c b/bootrom/bootrom.c index e889bb7da..4e92bc95b 100644 --- a/bootrom/bootrom.c +++ b/bootrom/bootrom.c @@ -122,7 +122,7 @@ void UsbPacketReceived(uint8_t *packet, int len) { switch (c->cmd) { case CMD_DEVICE_INFO: { dont_ack = 1; - arg0 = DEVICE_INFO_FLAG_BOOTROM_PRESENT | + arg0 = DEVICE_INFO_FLAG_BOOTROM_PRESENT | DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM | DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH | DEVICE_INFO_FLAG_UNDERSTANDS_CHIP_INFO; diff --git a/client/cmdhf15.c b/client/cmdhf15.c index 9a40d03cd..9d5f3802d 100644 --- a/client/cmdhf15.c +++ b/client/cmdhf15.c @@ -1348,7 +1348,7 @@ static int CmdHF15CSetUID(const char *Cmd) { data[3][5] = uid[1]; data[3][6] = uid[0]; - for (int i=0; i<4; i++) { + for (int i = 0; i < 4; i++) { AddCrc15(data[i], 7); clearCommandBuffer(); diff --git a/client/cmdlf.c b/client/cmdlf.c index 8459eca3a..389e76ca9 100644 --- a/client/cmdlf.c +++ b/client/cmdlf.c @@ -957,7 +957,7 @@ static bool CheckChipType(bool getDeviceData) { retval = true; goto out; } - + //check for t55xx chip... if (tryDetectP1(true)) { PrintAndLogEx(SUCCESS, "\nChipset detection : " _GREEN_("T55xx") "found"); @@ -1084,8 +1084,8 @@ int CmdLFfind(const char *Cmd) { } out: // identify chipset - if ( CheckChipType(isOnline) == false ) { - PrintAndLogEx(DEBUG, "Automatic chip type detection " _RED_("failed") ); + if (CheckChipType(isOnline) == false) { + PrintAndLogEx(DEBUG, "Automatic chip type detection " _RED_("failed")); } return PM3_SUCCESS; } diff --git a/client/cmdlfem4x.c b/client/cmdlfem4x.c index aa0add5fa..ce9a9ea0a 100644 --- a/client/cmdlfem4x.c +++ b/client/cmdlfem4x.c @@ -1373,10 +1373,10 @@ static void printEM4x05config(uint32_t wordData) { PrintAndLogEx(NORMAL, " PSK CF: %u | %s", PSKcf, cf); PrintAndLogEx(NORMAL, " Delay: %u | %s", delay, cdelay); PrintAndLogEx(NORMAL, " LastWordR: %02u | Address of last word for default read - meaning %u blocks are output", LWR, numblks); - PrintAndLogEx(NORMAL, " ReadLogin: %u | Read login is %s", readLogin, readLogin ? _YELLOW_("required") : _GREEN_("not required") ); - PrintAndLogEx(NORMAL, " ReadHKL: %u | Read housekeeping words login is %s", readHKL, readHKL ? _YELLOW_("required") : _GREEN_("not required") ); - PrintAndLogEx(NORMAL, "WriteLogin: %u | Write login is %s", writeLogin, writeLogin ? _YELLOW_("required") : _GREEN_("not required") ); - PrintAndLogEx(NORMAL, " WriteHKL: %u | Write housekeeping words login is %s", writeHKL, writeHKL ? _YELLOW_("required") : _GREEN_("not Required") ); + PrintAndLogEx(NORMAL, " ReadLogin: %u | Read login is %s", readLogin, readLogin ? _YELLOW_("required") : _GREEN_("not required")); + PrintAndLogEx(NORMAL, " ReadHKL: %u | Read housekeeping words login is %s", readHKL, readHKL ? _YELLOW_("required") : _GREEN_("not required")); + PrintAndLogEx(NORMAL, "WriteLogin: %u | Write login is %s", writeLogin, writeLogin ? _YELLOW_("required") : _GREEN_("not required")); + PrintAndLogEx(NORMAL, " WriteHKL: %u | Write housekeeping words login is %s", writeHKL, writeHKL ? _YELLOW_("required") : _GREEN_("not Required")); PrintAndLogEx(NORMAL, " R.A.W.: %u | Read after write is %s", raw, raw ? "on" : "off"); PrintAndLogEx(NORMAL, " Disable: %u | Disable command is %s", disable, disable ? "accepted" : "not accepted"); PrintAndLogEx(NORMAL, " R.T.F.: %u | Reader talk first is %s", rtf, rtf ? _YELLOW_("enabled") : "disabled"); @@ -1396,7 +1396,7 @@ static void printEM4x05info(uint32_t block0, uint32_t serial) { snprintf(ctstr + strlen(ctstr), sizeof(ctstr) - strlen(ctstr), _YELLOW_("%s"), "EM4305"); break; case 8: - snprintf(ctstr + strlen(ctstr), sizeof(ctstr) - strlen(ctstr), _YELLOW_("%s"), "EM4205"); + snprintf(ctstr + strlen(ctstr), sizeof(ctstr) - strlen(ctstr), _YELLOW_("%s"), "EM4205"); break; case 4: snprintf(ctstr + strlen(ctstr), sizeof(ctstr) - strlen(ctstr), _YELLOW_("%s"), "Unknown"); diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index 04b2c6e9e..b1c03b514 100644 --- a/client/cmdlft55xx.c +++ b/client/cmdlft55xx.c @@ -2153,7 +2153,7 @@ bool tryDetectP1(bool getData) { } return false; } - + // try ask clock detect. it could be another type even if successful. clk = GetAskClock("", false); if (clk > 0) { @@ -2162,14 +2162,14 @@ bool tryDetectP1(bool getData) { (DemodBufferLen == 32 || DemodBufferLen == 64)) { return true; } - + st = true; if ((ASKDemod_ext("0 1 1", false, false, 1, &st) == PM3_SUCCESS) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && (DemodBufferLen == 32 || DemodBufferLen == 64)) { return true; } - + if ((ASKbiphaseDemod("0 0 0 2", false) == PM3_SUCCESS) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && (DemodBufferLen == 32 || DemodBufferLen == 64)) { @@ -2182,7 +2182,7 @@ bool tryDetectP1(bool getData) { return true; } } - + // try NRZ clock detect. it could be another type even if successful. clk = GetNrzClock("", false); //has the most false positives :( if (clk > 0) { diff --git a/client/cmdusart.c b/client/cmdusart.c index d632901ef..60b977430 100644 --- a/client/cmdusart.c +++ b/client/cmdusart.c @@ -314,7 +314,7 @@ static int CmdUsartBtFactory(const char *Cmd) { PrintAndLogEx(WARNING, "Is the add-on blue light blinking? (Say 'n' if you want to abort) [y/n]"); char input[3]; - if ((fgets(input,sizeof(input),stdin) == NULL) || (strncmp(input, "y\n", sizeof(input)) != 0)) { + if ((fgets(input, sizeof(input), stdin) == NULL) || (strncmp(input, "y\n", sizeof(input)) != 0)) { PrintAndLogEx(NORMAL, ""); PrintAndLogEx(FAILED, "Aborting."); return PM3_EOPABORTED; diff --git a/client/comms.c b/client/comms.c index 5aa704728..6fd41ecad 100644 --- a/client/comms.c +++ b/client/comms.c @@ -136,7 +136,7 @@ static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool txBufferNG.pre.ng = ng; txBufferNG.pre.length = len; txBufferNG.pre.cmd = cmd; - if ( len > 0 && data ) + if (len > 0 && data) memcpy(&txBufferNG.data, data, len); if ((conn.send_via_fpc_usart && conn.send_with_crc_on_fpc) || ((!conn.send_via_fpc_usart) && conn.send_with_crc_on_usb)) { diff --git a/client/deprecated-hid-flasher/flasher/sleep.h b/client/deprecated-hid-flasher/flasher/sleep.h index f3aac0c8f..ffb5486aa 100644 --- a/client/deprecated-hid-flasher/flasher/sleep.h +++ b/client/deprecated-hid-flasher/flasher/sleep.h @@ -6,18 +6,18 @@ #define SLEEP_H__ #ifdef _WIN32 - #include - #define msleep(n) Sleep(n) +#include +#define msleep(n) Sleep(n) #else - #include - #include - static void nsleep(uint64_t n) { - struct timespec timeout; - timeout.tv_sec = n / 1000000000; - timeout.tv_nsec = n % 1000000000; - while (nanosleep(&timeout, &timeout) && errno == EINTR); - } - #define msleep(n) nsleep(1000000 * (uint64_t)n) +#include +#include +static void nsleep(uint64_t n) { + struct timespec timeout; + timeout.tv_sec = n / 1000000000; + timeout.tv_nsec = n % 1000000000; + while (nanosleep(&timeout, &timeout) && errno == EINTR); +} +#define msleep(n) nsleep(1000000 * (uint64_t)n) #endif #endif diff --git a/client/flash.c b/client/flash.c index 3a1350c7c..5b4cd205e 100644 --- a/client/flash.c +++ b/client/flash.c @@ -347,7 +347,7 @@ static int wait_for_ack(PacketResponseNG *ack) { } // Go into flashing mode -int flash_start_flashing(int enable_bl_writes, char *serial_port_name, uint32_t * chipinfo) { +int flash_start_flashing(int enable_bl_writes, char *serial_port_name, uint32_t *chipinfo) { uint32_t state; if (enter_bootloader(serial_port_name) < 0) diff --git a/client/util.c b/client/util.c index a805b9c84..f6f89e0ff 100644 --- a/client/util.c +++ b/client/util.c @@ -61,8 +61,7 @@ int kbd_enter_pressed(void) { #include int kbd_enter_pressed(void) { int ret = 0; - while(kbhit()) - { + while (kbhit()) { ret |= getch() == '\r'; } return ret; @@ -178,8 +177,8 @@ bool CheckStringIsHEXValue(const char *value) { void hex_to_buffer(const uint8_t *buf, const uint8_t *hex_data, const size_t hex_len, const size_t hex_max_len, const size_t min_str_len, const size_t spaces_between, bool uppercase) { - if (buf == NULL ) return; - + if (buf == NULL) return; + char *tmp = (char *)buf; size_t i; memset(tmp, 0x00, hex_max_len); @@ -205,16 +204,16 @@ void hex_to_buffer(const uint8_t *buf, const uint8_t *hex_data, const size_t hex // printing and converting functions void print_hex(const uint8_t *data, const size_t len) { - if (data == NULL || len == 0 ) return; - + if (data == NULL || len == 0) return; + for (size_t i = 0; i < len; i++) printf("%02x ", data[i]); printf("\n"); } void print_hex_break(const uint8_t *data, const size_t len, uint8_t breaks) { - if (data == NULL || len == 0 ) return; - + if (data == NULL || len == 0) return; + int rownum = 0; printf("[%02d] | ", rownum); for (size_t i = 0; i < len; ++i) { diff --git a/common/lfdemod.c b/common/lfdemod.c index ef18b59ef..f8daec079 100644 --- a/common/lfdemod.c +++ b/common/lfdemod.c @@ -103,7 +103,7 @@ void computeSignalProperties(uint8_t *samples, uint32_t size) { // we can detect noise signalprop.isnoise = signalprop.amplitude < NOISE_AMPLITUDE_THRESHOLD; - if (g_debugMode) + if (g_debugMode) printSignal(); } @@ -1365,8 +1365,8 @@ static int millerRawDecode(uint8_t *bits, size_t *size, int invert) { int BiphaseRawDecode(uint8_t *bits, size_t *size, int *offset, int invert) { //sanity check if (*size < 51) return -1; - - if ( *offset < 0 ) *offset = 0; + + if (*offset < 0) *offset = 0; uint16_t bitnum = 0; uint16_t errCnt = 0;