make style

This commit is contained in:
Philippe Teuwen 2019-07-13 00:38:30 +02:00
commit b0dbbd3683
15 changed files with 55 additions and 56 deletions

View file

@ -347,9 +347,9 @@ void SendVersion(void) {
strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1); strncat(VersionString, temp, sizeof(VersionString) - strlen(VersionString) - 1);
#if defined(__clang__) #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__) #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 #endif
strncat(VersionString, "\n [ FPGA ]\n ", sizeof(VersionString) - strlen(VersionString) - 1); strncat(VersionString, "\n [ FPGA ]\n ", sizeof(VersionString) - strlen(VersionString) - 1);

View file

@ -434,7 +434,7 @@ static bool hitag2_password(uint8_t *rx, const size_t rxlen, uint8_t *tx, size_t
break; break;
} }
} }
return true; return true;
} }

View file

@ -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_numbers = 0;
uint32_t sample_total_saved = 0; uint32_t sample_total_saved = 0;
uint32_t cancel_counter = 0; uint32_t cancel_counter = 0;
uint16_t checker = 0; uint16_t checker = 0;
while (true) { while (true) {
if ( checker == 1000 ) { if (checker == 1000) {
if (BUTTON_PRESS() || data_available()) if (BUTTON_PRESS() || data_available())
break; break;
else else
@ -148,7 +148,7 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag
} else { } else {
++checker; ++checker;
} }
WDT_HIT(); WDT_HIT();
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) { if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
@ -293,11 +293,11 @@ void doT55x7Acquisition(size_t sample_size) {
bool startFound = false; bool startFound = false;
bool highFound = false; bool highFound = false;
bool lowFound = false; bool lowFound = false;
uint16_t checker = 0; uint16_t checker = 0;
while ( skipCnt < 1000 && (i < bufsize)) { while (skipCnt < 1000 && (i < bufsize)) {
if ( checker == 1000 ) { if (checker == 1000) {
if (BUTTON_PRESS() || data_available()) if (BUTTON_PRESS() || data_available())
break; break;
else else
@ -371,9 +371,9 @@ void doCotagAcquisition(size_t sample_size) {
uint16_t noise_counter = 0; uint16_t noise_counter = 0;
uint16_t checker = 0; uint16_t checker = 0;
while ((i < bufsize) && (noise_counter < (COTAG_T1 << 1))) { while ((i < bufsize) && (noise_counter < (COTAG_T1 << 1))) {
if ( checker == 1000 ) { if (checker == 1000) {
if (BUTTON_PRESS() || data_available()) if (BUTTON_PRESS() || data_available())
break; break;
else else
@ -431,9 +431,9 @@ uint32_t doCotagAcquisitionManchester() {
uint8_t curr = 0, prev = 0; uint8_t curr = 0, prev = 0;
uint16_t noise_counter = 0; uint16_t noise_counter = 0;
uint16_t checker = 0; uint16_t checker = 0;
while ((sample_counter < bufsize) && (noise_counter < (COTAG_T1 << 1))) { while ((sample_counter < bufsize) && (noise_counter < (COTAG_T1 << 1))) {
if ( checker == 1000 ) { if (checker == 1000) {
if (BUTTON_PRESS() || data_available()) if (BUTTON_PRESS() || data_available())
break; break;
else else

View file

@ -606,8 +606,8 @@ void Mifare1ksim(uint16_t flags, uint8_t exitAfterNReads, uint8_t *datain) {
if (receivedCmd_len == 9 && receivedCmd[1] == 0x70) { if (receivedCmd_len == 9 && receivedCmd[1] == 0x70) {
if (memcmp(&receivedCmd[2], responses[uid_index].response, 4) == 0) { if (memcmp(&receivedCmd[2], responses[uid_index].response, 4) == 0) {
bool cl_finished = (uid_len == 4 && uid_index == UIDBCC1) || bool cl_finished = (uid_len == 4 && uid_index == UIDBCC1) ||
(uid_len == 7 && uid_index == UIDBCC2) || (uid_len == 7 && uid_index == UIDBCC2) ||
(uid_len == 10 && uid_index == UIDBCC3); (uid_len == 10 && uid_index == UIDBCC3);
EmSendPrecompiledCmd(&responses[cl_finished ? SAK : SAKuid]); 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 (DBGLEVEL >= DBG_EXTENDED) Dbprintf("SELECT CLx %02x%02x%02x%02x received", receivedCmd[2], receivedCmd[3], receivedCmd[4], receivedCmd[5]);
if (cl_finished) { if (cl_finished) {

View file

@ -122,7 +122,7 @@ void UsbPacketReceived(uint8_t *packet, int len) {
switch (c->cmd) { switch (c->cmd) {
case CMD_DEVICE_INFO: { case CMD_DEVICE_INFO: {
dont_ack = 1; dont_ack = 1;
arg0 = DEVICE_INFO_FLAG_BOOTROM_PRESENT | arg0 = DEVICE_INFO_FLAG_BOOTROM_PRESENT |
DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM | DEVICE_INFO_FLAG_CURRENT_MODE_BOOTROM |
DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH | DEVICE_INFO_FLAG_UNDERSTANDS_START_FLASH |
DEVICE_INFO_FLAG_UNDERSTANDS_CHIP_INFO; DEVICE_INFO_FLAG_UNDERSTANDS_CHIP_INFO;

View file

@ -1348,7 +1348,7 @@ static int CmdHF15CSetUID(const char *Cmd) {
data[3][5] = uid[1]; data[3][5] = uid[1];
data[3][6] = uid[0]; data[3][6] = uid[0];
for (int i=0; i<4; i++) { for (int i = 0; i < 4; i++) {
AddCrc15(data[i], 7); AddCrc15(data[i], 7);
clearCommandBuffer(); clearCommandBuffer();

View file

@ -957,7 +957,7 @@ static bool CheckChipType(bool getDeviceData) {
retval = true; retval = true;
goto out; goto out;
} }
//check for t55xx chip... //check for t55xx chip...
if (tryDetectP1(true)) { if (tryDetectP1(true)) {
PrintAndLogEx(SUCCESS, "\nChipset detection : " _GREEN_("T55xx") "found"); PrintAndLogEx(SUCCESS, "\nChipset detection : " _GREEN_("T55xx") "found");
@ -1084,8 +1084,8 @@ int CmdLFfind(const char *Cmd) {
} }
out: out:
// identify chipset // identify chipset
if ( CheckChipType(isOnline) == false ) { if (CheckChipType(isOnline) == false) {
PrintAndLogEx(DEBUG, "Automatic chip type detection " _RED_("failed") ); PrintAndLogEx(DEBUG, "Automatic chip type detection " _RED_("failed"));
} }
return PM3_SUCCESS; return PM3_SUCCESS;
} }

View file

@ -1373,10 +1373,10 @@ static void printEM4x05config(uint32_t wordData) {
PrintAndLogEx(NORMAL, " PSK CF: %u | %s", PSKcf, cf); PrintAndLogEx(NORMAL, " PSK CF: %u | %s", PSKcf, cf);
PrintAndLogEx(NORMAL, " Delay: %u | %s", delay, cdelay); 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, " 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, " 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, " 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, "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, " 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, " 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, " 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"); 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"); snprintf(ctstr + strlen(ctstr), sizeof(ctstr) - strlen(ctstr), _YELLOW_("%s"), "EM4305");
break; break;
case 8: 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; break;
case 4: case 4:
snprintf(ctstr + strlen(ctstr), sizeof(ctstr) - strlen(ctstr), _YELLOW_("%s"), "Unknown"); snprintf(ctstr + strlen(ctstr), sizeof(ctstr) - strlen(ctstr), _YELLOW_("%s"), "Unknown");

View file

@ -2153,7 +2153,7 @@ bool tryDetectP1(bool getData) {
} }
return false; return false;
} }
// try ask clock detect. it could be another type even if successful. // try ask clock detect. it could be another type even if successful.
clk = GetAskClock("", false); clk = GetAskClock("", false);
if (clk > 0) { if (clk > 0) {
@ -2162,14 +2162,14 @@ bool tryDetectP1(bool getData) {
(DemodBufferLen == 32 || DemodBufferLen == 64)) { (DemodBufferLen == 32 || DemodBufferLen == 64)) {
return true; return true;
} }
st = true; st = true;
if ((ASKDemod_ext("0 1 1", false, false, 1, &st) == PM3_SUCCESS) && if ((ASKDemod_ext("0 1 1", false, false, 1, &st) == PM3_SUCCESS) &&
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
(DemodBufferLen == 32 || DemodBufferLen == 64)) { (DemodBufferLen == 32 || DemodBufferLen == 64)) {
return true; return true;
} }
if ((ASKbiphaseDemod("0 0 0 2", false) == PM3_SUCCESS) && if ((ASKbiphaseDemod("0 0 0 2", false) == PM3_SUCCESS) &&
preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) && preambleSearchEx(DemodBuffer, preamble, sizeof(preamble), &DemodBufferLen, &startIdx, false) &&
(DemodBufferLen == 32 || DemodBufferLen == 64)) { (DemodBufferLen == 32 || DemodBufferLen == 64)) {
@ -2182,7 +2182,7 @@ bool tryDetectP1(bool getData) {
return true; return true;
} }
} }
// try NRZ clock detect. it could be another type even if successful. // try NRZ clock detect. it could be another type even if successful.
clk = GetNrzClock("", false); //has the most false positives :( clk = GetNrzClock("", false); //has the most false positives :(
if (clk > 0) { if (clk > 0) {

View file

@ -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]"); PrintAndLogEx(WARNING, "Is the add-on blue light blinking? (Say 'n' if you want to abort) [y/n]");
char input[3]; 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(NORMAL, "");
PrintAndLogEx(FAILED, "Aborting."); PrintAndLogEx(FAILED, "Aborting.");
return PM3_EOPABORTED; return PM3_EOPABORTED;

View file

@ -136,7 +136,7 @@ static void SendCommandNG_internal(uint16_t cmd, uint8_t *data, size_t len, bool
txBufferNG.pre.ng = ng; txBufferNG.pre.ng = ng;
txBufferNG.pre.length = len; txBufferNG.pre.length = len;
txBufferNG.pre.cmd = cmd; txBufferNG.pre.cmd = cmd;
if ( len > 0 && data ) if (len > 0 && data)
memcpy(&txBufferNG.data, data, len); 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)) { if ((conn.send_via_fpc_usart && conn.send_with_crc_on_fpc) || ((!conn.send_via_fpc_usart) && conn.send_with_crc_on_usb)) {

View file

@ -6,18 +6,18 @@
#define SLEEP_H__ #define SLEEP_H__
#ifdef _WIN32 #ifdef _WIN32
#include <windows.h> #include <windows.h>
#define msleep(n) Sleep(n) #define msleep(n) Sleep(n)
#else #else
#include <time.h> #include <time.h>
#include <errno.h> #include <errno.h>
static void nsleep(uint64_t n) { static void nsleep(uint64_t n) {
struct timespec timeout; struct timespec timeout;
timeout.tv_sec = n / 1000000000; timeout.tv_sec = n / 1000000000;
timeout.tv_nsec = n % 1000000000; timeout.tv_nsec = n % 1000000000;
while (nanosleep(&timeout, &timeout) && errno == EINTR); while (nanosleep(&timeout, &timeout) && errno == EINTR);
} }
#define msleep(n) nsleep(1000000 * (uint64_t)n) #define msleep(n) nsleep(1000000 * (uint64_t)n)
#endif #endif
#endif #endif

View file

@ -347,7 +347,7 @@ static int wait_for_ack(PacketResponseNG *ack) {
} }
// Go into flashing mode // 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; uint32_t state;
if (enter_bootloader(serial_port_name) < 0) if (enter_bootloader(serial_port_name) < 0)

View file

@ -61,8 +61,7 @@ int kbd_enter_pressed(void) {
#include <conio.h> #include <conio.h>
int kbd_enter_pressed(void) { int kbd_enter_pressed(void) {
int ret = 0; int ret = 0;
while(kbhit()) while (kbhit()) {
{
ret |= getch() == '\r'; ret |= getch() == '\r';
} }
return ret; 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, 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) { 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; char *tmp = (char *)buf;
size_t i; size_t i;
memset(tmp, 0x00, hex_max_len); 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 // printing and converting functions
void print_hex(const uint8_t *data, const size_t len) { 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++) for (size_t i = 0; i < len; i++)
printf("%02x ", data[i]); printf("%02x ", data[i]);
printf("\n"); printf("\n");
} }
void print_hex_break(const uint8_t *data, const size_t len, uint8_t breaks) { 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; int rownum = 0;
printf("[%02d] | ", rownum); printf("[%02d] | ", rownum);
for (size_t i = 0; i < len; ++i) { for (size_t i = 0; i < len; ++i) {

View file

@ -103,7 +103,7 @@ void computeSignalProperties(uint8_t *samples, uint32_t size) {
// we can detect noise // we can detect noise
signalprop.isnoise = signalprop.amplitude < NOISE_AMPLITUDE_THRESHOLD; signalprop.isnoise = signalprop.amplitude < NOISE_AMPLITUDE_THRESHOLD;
if (g_debugMode) if (g_debugMode)
printSignal(); 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) { int BiphaseRawDecode(uint8_t *bits, size_t *size, int *offset, int invert) {
//sanity check //sanity check
if (*size < 51) return -1; if (*size < 51) return -1;
if ( *offset < 0 ) *offset = 0; if (*offset < 0) *offset = 0;
uint16_t bitnum = 0; uint16_t bitnum = 0;
uint16_t errCnt = 0; uint16_t errCnt = 0;