diff --git a/client/src/cmdhfmfu.c b/client/src/cmdhfmfu.c index 5620f7a64..93a6c5e10 100644 --- a/client/src/cmdhfmfu.c +++ b/client/src/cmdhfmfu.c @@ -2104,7 +2104,7 @@ void printMFUdumpEx(mfu_dump_t *card, uint16_t pages, uint8_t startpage) { PrintAndLogEx(INFO, "DYNAMIC LOCK: %s", sprint_hex(lockbytes_dyn, 3)); } - for (uint8_t i = 0; i < pages; ++i) { + for (uint16_t i = 0; i < pages; ++i) { if (i < 3) { PrintAndLogEx(INFO, "%3d/0x%02X | %s| | %s", i + startpage, i + startpage, sprint_hex(data + i * 4, 4), sprint_ascii(data + i * 4, 4)); continue; diff --git a/client/src/cmdlf.c b/client/src/cmdlf.c index 9ecd3f6bf..0252c4736 100644 --- a/client/src/cmdlf.c +++ b/client/src/cmdlf.c @@ -174,7 +174,7 @@ static int CmdLFTune(const char *Cmd) { print_progress(0, max, style); // loop forever (till button pressed) if iter = 0 (default) - for (uint8_t i = 0; iter == 0 || i < iter; i++) { + for (uint32_t i = 0; iter == 0 || i < iter; i++) { if (kbd_enter_pressed()) { break; } @@ -840,13 +840,13 @@ int lfsim_upload_gb(void) { //can send only 512 bits at a time (1 byte sent per bit...) PrintAndLogEx(INFO, "." NOLF); - for (uint16_t i = 0; i < g_GraphTraceLen; i += PM3_CMD_DATA_SIZE - 3) { + for (size_t i = 0; i < g_GraphTraceLen; i += PM3_CMD_DATA_SIZE - 3) { size_t len = MIN((g_GraphTraceLen - i), PM3_CMD_DATA_SIZE - 3); clearCommandBuffer(); payload_up.offset = i; - for (uint16_t j = 0; j < len; j++) + for (size_t j = 0; j < len; j++) payload_up.data[j] = g_GraphBuffer[i + j]; SendCommandNG(CMD_LF_UPLOAD_SIM_SAMPLES, (uint8_t *)&payload_up, sizeof(struct pupload)); diff --git a/client/src/cmdlfidteck.c b/client/src/cmdlfidteck.c index b8cc30020..3dae4f0d1 100644 --- a/client/src/cmdlfidteck.c +++ b/client/src/cmdlfidteck.c @@ -201,7 +201,7 @@ static int CmdIdteckSim(const char *Cmd) { memset(bs, 0x00, sizeof(bs)); uint8_t counter = 0; - for (int8_t i = 0; i < raw_len; i++) { + for (int32_t i = 0; i < raw_len; i++) { uint8_t tmp = raw[i]; bs[counter++] = (tmp >> 7) & 1; bs[counter++] = (tmp >> 6) & 1; diff --git a/client/src/cmdlfindala.c b/client/src/cmdlfindala.c index e059c3db3..0a8a9bb16 100644 --- a/client/src/cmdlfindala.c +++ b/client/src/cmdlfindala.c @@ -586,7 +586,7 @@ static int CmdIndalaSim(const char *Cmd) { memset(bs, 0x00, sizeof(bs)); uint8_t counter = 0; - for (int8_t i = 0; i < raw_len; i++) { + for (int32_t i = 0; i < raw_len; i++) { uint8_t tmp = raw[i]; bs[counter++] = (tmp >> 7) & 1; bs[counter++] = (tmp >> 6) & 1; diff --git a/client/src/cmdlfparadox.c b/client/src/cmdlfparadox.c index 986ed64cd..511a8019e 100644 --- a/client/src/cmdlfparadox.c +++ b/client/src/cmdlfparadox.c @@ -102,7 +102,7 @@ int demodParadox(bool verbose) { uint8_t error = 0; // Remove manchester encoding from FSK bits, skip pre - for (uint8_t i = idx + PARADOX_PREAMBLE_LEN; i < (idx + 96); i += 2) { + for (uint32_t i = idx + PARADOX_PREAMBLE_LEN; i < (idx + 96); i += 2) { // not manchester data if (bits[i] == bits[i + 1]) { diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c index 3dd1be167..e06d8a228 100644 --- a/client/src/cmdlft55xx.c +++ b/client/src/cmdlft55xx.c @@ -296,7 +296,7 @@ bool t55xxAcquireAndCompareBlock0(bool usepwd, uint32_t password, uint32_t known continue; } - for (uint16_t i = 0; i < g_DemodBufferLen - 32; i++) { + for (size_t i = 0; i < g_DemodBufferLen - 32; i++) { uint32_t tmp = PackBits(i, 32, g_DemodBuffer); if (tmp == known_block0) { config.offset = i; @@ -4091,7 +4091,7 @@ static int CmdT55xxSniff(const char *Cmd) { // We auto find widths if ((width0 == 0) && (width1 == 0)) { // We ignore bit 0 for the moment as it may be a ref. pulse, so check last - uint8_t ii = 2; + uint32_t ii = 2; minWidth = pulseBuffer[1]; maxWidth = pulseBuffer[1]; bool done = false; diff --git a/client/src/cmdtrace.c b/client/src/cmdtrace.c index acbc5e5ef..1dcf20c1f 100644 --- a/client/src/cmdtrace.c +++ b/client/src/cmdtrace.c @@ -35,7 +35,7 @@ static int CmdHelp(const char *Cmd); // trace pointer static uint8_t *gs_trace; -static long gs_traceLen = 0; +static uint16_t gs_traceLen = 0; static bool is_last_record(uint16_t tracepos, uint16_t traceLen) { return ((tracepos + TRACELOG_HDR_LEN) >= traceLen); diff --git a/client/src/fileutils.c b/client/src/fileutils.c index 2ac29b849..21c052550 100644 --- a/client/src/fileutils.c +++ b/client/src/fileutils.c @@ -1645,7 +1645,7 @@ static int filelist(const char *path, const char *ext, uint8_t last, bool tentat PrintAndLogEx(NORMAL, "%s── "_GREEN_("%s"), last ? "ā””" : "ā”œ", &path[strip]); - for (uint16_t i = 0; i < n; i++) { + for (int i = 0; i < n; i++) { char tmp_fullpath[1024] = {0}; strncat(tmp_fullpath, path, sizeof(tmp_fullpath) - 1); diff --git a/client/src/graph.c b/client/src/graph.c index 9f87271fc..5914c8585 100644 --- a/client/src/graph.c +++ b/client/src/graph.c @@ -33,7 +33,7 @@ TODO, verfy that this doesn't overflow buffer (iceman) */ void AppendGraph(bool redraw, uint16_t clock, int bit) { uint8_t half = clock / 2; - uint8_t i; + uint16_t i; //set first half the clock bit (all 1's or 0's for a 0 or 1 bit) for (i = 0; i < half; ++i) g_GraphBuffer[g_GraphTraceLen++] = bit; diff --git a/client/src/loclass/cipherutils.c b/client/src/loclass/cipherutils.c index eaca50325..eaeee3019 100644 --- a/client/src/loclass/cipherutils.c +++ b/client/src/loclass/cipherutils.c @@ -126,15 +126,13 @@ uint64_t x_bytes_to_num(uint8_t *src, size_t len) { } void reverse_arraybytes(uint8_t *arr, size_t len) { - uint8_t i; - for (i = 0; i < len ; i++) { + for (size_t i = 0; i < len ; i++) { arr[i] = reflect8(arr[i]); } } void reverse_arraycopy(uint8_t *arr, uint8_t *dest, size_t len) { - uint8_t i; - for (i = 0; i < len ; i++) { + for (size_t i = 0; i < len ; i++) { dest[i] = reflect8(arr[i]); } } diff --git a/client/src/loclass/elite_crack.c b/client/src/loclass/elite_crack.c index 4741e52ac..ec13ca76e 100644 --- a/client/src/loclass/elite_crack.c +++ b/client/src/loclass/elite_crack.c @@ -445,7 +445,7 @@ int bruteforceItem(loclass_dumpdata_t item, uint16_t keytable[]) { loclass_thread_arg_t args[loclass_tc]; // init thread arguments - for (int i = 0; i < loclass_tc; i++) { + for (size_t i = 0; i < loclass_tc; i++) { args[i].thread_idx = i; args[i].numbytes_to_recover = numbytes_to_recover; args[i].endmask = 1 << 8 * numbytes_to_recover; @@ -458,7 +458,7 @@ int bruteforceItem(loclass_dumpdata_t item, uint16_t keytable[]) { pthread_t threads[loclass_tc]; // create threads - for (int i = 0; i < loclass_tc; i++) { + for (size_t i = 0; i < loclass_tc; i++) { int res = pthread_create(&threads[i], NULL, bf_thread, (void *)&args[i]); if (res) { PrintAndLogEx(NORMAL, ""); @@ -468,7 +468,7 @@ int bruteforceItem(loclass_dumpdata_t item, uint16_t keytable[]) { } // wait for threads to terminate: void *ptrs[loclass_tc]; - for (int i = 0; i < loclass_tc; i++) + for (size_t i = 0; i < loclass_tc; i++) pthread_join(threads[i], &ptrs[i]); // was it a success? @@ -493,7 +493,7 @@ int bruteforceItem(loclass_dumpdata_t item, uint16_t keytable[]) { keytable[bytes_to_recover[i]] &= 0xFF; keytable[bytes_to_recover[i]] |= LOCLASS_CRACKED; } - for (uint8_t i = 0; i < loclass_tc; i++) { + for (size_t i = 0; i < loclass_tc; i++) { free(ptrs[i]); } } diff --git a/client/src/ui.c b/client/src/ui.c index b5b1fc0f4..74557cd5a 100644 --- a/client/src/ui.c +++ b/client/src/ui.c @@ -426,7 +426,7 @@ void memcpy_filter_rlmarkers(void *dest, const void *src, size_t n) { uint8_t *rdest = (uint8_t *)dest; uint8_t *rsrc = (uint8_t *)src; uint16_t si = 0; - for (uint16_t i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { if ((rsrc[i] == '\001') || (rsrc[i] == '\002')) // skip readline special markers continue; @@ -440,7 +440,7 @@ void memcpy_filter_ansi(void *dest, const void *src, size_t n, bool filter) { uint8_t *rdest = (uint8_t *)dest; uint8_t *rsrc = (uint8_t *)src; uint16_t si = 0; - for (uint16_t i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { if ((i < n - 1) && (rsrc[i] == '\x1b') && (rsrc[i + 1] >= 0x40) @@ -531,7 +531,7 @@ void memcpy_filter_emoji(void *dest, const void *src, size_t n, emojiMode_t mode char *rdest = (char *)dest; char *rsrc = (char *)src; uint16_t si = 0; - for (uint16_t i = 0; i < n; i++) { + for (size_t i = 0; i < n; i++) { current_char = rsrc[i]; if (current_token_length == 0) { diff --git a/client/src/util.c b/client/src/util.c index 103521b42..bb517b5bb 100644 --- a/client/src/util.c +++ b/client/src/util.c @@ -280,8 +280,8 @@ void print_blocks(uint32_t *data, size_t len) { if (!data) { PrintAndLogEx(ERR, "..empty data"); } else { - for (uint8_t i = 0; i < len; i++) - PrintAndLogEx(SUCCESS, " %02d | %08X", i, data[i]); + for (size_t i = 0; i < len; i++) + PrintAndLogEx(SUCCESS, " %02zd | %08X", i, data[i]); } } diff --git a/common/crc.c b/common/crc.c index 876c00951..016d8e5be 100644 --- a/common/crc.c +++ b/common/crc.c @@ -163,7 +163,7 @@ uint32_t CRC8Hitag1Bits(const uint8_t *buff, size_t bitsize) { uint8_t data = 0; uint8_t n = 0; crc_init_ref(&crc, 8, 0x1d, 0xff, 0, false, false); - uint8_t i; + size_t i; for (i = 0; i < bitsize; i++) { data <<= 1; data += (buff[i / 8] >> (7 - (i % 8))) & 1; diff --git a/common/lfdemod.c b/common/lfdemod.c index 6401d522c..bf0bfd4c6 100644 --- a/common/lfdemod.c +++ b/common/lfdemod.c @@ -701,7 +701,7 @@ int DetectASKClock(uint8_t *dest, size_t size, int *clock, int maxErr) { } size_t i = 1; - uint16_t num_clks = 9; + uint8_t num_clks = 9; // first 255 value pos0 is placeholder for user inputed clock. uint16_t clk[] = {255, 8, 16, 32, 40, 50, 64, 100, 128, 255};