fix PrintAndLogEx formats that only break on 32-bit and LLP64 hosts

size_t printed with %lu/%ld/PRIu64 and uint64_t with %lu are correct on
64-bit Linux/macOS only; with the new format attribute they fail -Werror
builds on 32-bit hosts (RPi, 32-bit Windows), and %lu for uint64_t also on
64-bit Windows. unsigned long printed with PRIu64 likewise.
Found by a 32-bit (arm-none-eabi) syntax-only pass over the client.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
iceman1001andClaude Opus 5.5 committed 2026-11-09 18:41:40 +07:00
1 parent cc50ed6b72
commit 3686dffe1c
9 files changed
+16 -16

No files matched your search

+4 -4
View File
@@ -4081,12 +4081,12 @@ static int CmdTestSaveState8(const char *Cmd) {
for (size_t i = 0; i < returnedLength; i++) {
if (srcBuffer[i] != destBuffer[i]) {
PrintAndLogEx(FAILED, "Buffers don't match at index %lu!, Expected %i, got %i", i, srcBuffer[i], destBuffer[i]);
PrintAndLogEx(FAILED, "Buffers don't match at index %zu!, Expected %i, got %i", i, srcBuffer[i], destBuffer[i]);
free(srcBuffer);
free(destBuffer);
return PM3_EFAILED;
}
PrintAndLogEx(DEBUG, "Index %lu matches: %u", i, destBuffer[i]);
PrintAndLogEx(DEBUG, "Index %zu matches: %u", i, destBuffer[i]);
}
PrintAndLogEx(SUCCESS, _GREEN_("Save State (8-bit) test success!") "\n");
@@ -4146,12 +4146,12 @@ static int CmdTestSaveState32(const char *Cmd) {
for (size_t i = 0; i < length; i++) {
if (srcBuffer[i] != destBuffer[i]) {
PrintAndLogEx(FAILED, "Buffers don't match at index %lu!, Expected %i, got %i", i, srcBuffer[i], destBuffer[i]);
PrintAndLogEx(FAILED, "Buffers don't match at index %zu!, Expected %i, got %i", i, srcBuffer[i], destBuffer[i]);
free(srcBuffer);
free(destBuffer);
return PM3_EFAILED;
}
PrintAndLogEx(DEBUG, "Index %lu matches: %i", i, destBuffer[i]);
PrintAndLogEx(DEBUG, "Index %zu matches: %i", i, destBuffer[i]);
}
PrintAndLogEx(SUCCESS, _GREEN_("Save State (32-bit) test success!") "\n");
+1 -1
View File
@@ -253,7 +253,7 @@ static void pm3_print_public_keys(void) {
mbedtls_mpi_write_string(&rsa.E, 16, str_exp, sizeof(str_exp), &exlen);
mbedtls_mpi_write_string(&rsa.N, 16, str_pk, sizeof(str_pk), &pklen);
PrintAndLogEx(INFO, "Len........ %"PRIu64, rsa.len);
PrintAndLogEx(INFO, "Len........ %zu", rsa.len);
PrintAndLogEx(INFO, "Exponent... %s", str_exp);
PrintAndLogEx(INFO, "Public key modulus N");
PrintAndLogEx(INFO, " %.64s", str_pk);
+2 -2
View File
@@ -4425,7 +4425,7 @@ static int CmdHF14AMfSmartBrute(const char *Cmd) {
if (keys_checked) {
PrintAndLogEx(INFO, "Current cracking speed (keys/s): %lu",
PrintAndLogEx(INFO, "Current cracking speed (keys/s): %" PRIu64,
keys_checked / ((msclock() - t1) / 1000)
);
@@ -4452,7 +4452,7 @@ static int CmdHF14AMfSmartBrute(const char *Cmd) {
out:
PrintAndLogEx(INFO, "Time in brute mode: " _YELLOW_("%.1fs") "\n", (float)((msclock() - t0) / 1000.0));
PrintAndLogEx(INFO, "Total keys checked: " _YELLOW_("%lu") "\n", total_keys_checked);
PrintAndLogEx(INFO, "Total keys checked: " _YELLOW_("%" PRIu64) "\n", total_keys_checked);
// check..
uint8_t found_keys = 0;
for (i = 0; i < sectorsCnt; ++i) {
+1 -1
View File
@@ -7146,7 +7146,7 @@ static int CmdHF14ADesMakeMFCLicense(const char *Cmd) {
license_len = 1 + 2 * num_blocks;
}
PrintAndLogEx(loglevel, "Covering %lu sector%s in total", num_sectors, num_sectors != 1 ? "s" : "");
PrintAndLogEx(loglevel, "Covering %zu sector%s in total", num_sectors, num_sectors != 1 ? "s" : "");
if (use_default_keys) {
// by default: all key A FFFFFFFFFFFF, all key B readable
+1 -1
View File
@@ -453,7 +453,7 @@ static void init_bitflip_bitarrays(void) {
exit(5);
}
if (generated_output_size != expected_output_size) {
PrintAndLogEx(ERR, "File read error with %s (3) got %lu instead of %lu bytes. Aborting...\n", state_file_name, generated_output_size, expected_output_size);
PrintAndLogEx(ERR, "File read error with %s (3) got %zu instead of %zu bytes. Aborting...\n", state_file_name, generated_output_size, expected_output_size);
free(uncompressed_data);
exit(5);
}
+2 -2
View File
@@ -491,7 +491,7 @@ static bool piv_tag_dump(const struct tlv *tlv, int level) {
PrintAndLogEx(NORMAL, " '" _YELLOW_("%s")"'", sprint_hex_inrow(tlv->value, tlv->len));
break;
case PIV_TAG_NUMERIC:
PrintAndLogEx(NORMAL, " " _YELLOW_("%" PRIu64), piv_value_numeric(tlv, 0, tlv->len * 2));
PrintAndLogEx(NORMAL, " " _YELLOW_("%lu"), piv_value_numeric(tlv, 0, tlv->len * 2));
break;
case PIV_TAG_YYYYMMDD:
piv_tag_dump_yyyymmdd(tlv, tag, level);
@@ -710,7 +710,7 @@ static int PivAuthenticateSign(Iso7816CommandChannel channel, uint8_t alg_id, ui
const size_t MAX_NONCE_LEN = 0x7a;
if (nonce_len > MAX_NONCE_LEN) {
if (verbose == true) {
PrintAndLogEx(WARNING, "Nonce cannot exceed %" PRIu64 " bytes. Got %" PRIu64 " bytes.", MAX_NONCE_LEN, nonce_len);
PrintAndLogEx(WARNING, "Nonce cannot exceed %zu bytes. Got %zu bytes.", MAX_NONCE_LEN, nonce_len);
}
return PM3_EINVARG;
}
+2 -2
View File
@@ -241,7 +241,7 @@ static uint32_t extractChallenges(uint32_t tracepos, uint32_t traceLen, uint8_t
// sanity check tracking position is less than available trace size
if (tracepos + TRACELOG_HDR_LEN + data_len + TRACELOG_PARITY_LEN(hdr) > traceLen) {
PrintAndLogEx(DEBUG, "trace pos offset %"PRIu64 " larger than reported tracelen %u",
PrintAndLogEx(DEBUG, "trace pos offset %zu larger than reported tracelen %u",
tracepos + TRACELOG_HDR_LEN + data_len + TRACELOG_PARITY_LEN(hdr),
traceLen
);
@@ -665,7 +665,7 @@ static uint32_t printTraceLine(uint32_t tracepos, uint32_t traceLen, uint8_t *tr
uint16_t data_len = hdr->data_len;
if (tracepos + TRACELOG_HDR_LEN + data_len + TRACELOG_PARITY_LEN(hdr) > traceLen) {
PrintAndLogEx(DEBUG, "trace pos offset %"PRIu64 " larger than reported tracelen %u",
PrintAndLogEx(DEBUG, "trace pos offset %zu larger than reported tracelen %u",
tracepos + TRACELOG_HDR_LEN + data_len + TRACELOG_PARITY_LEN(hdr),
traceLen
);
+2 -2
View File
@@ -269,7 +269,7 @@ bool KSX6924ParsePurseInfo(const uint8_t *purseInfo, size_t purseLen, struct ksx
if (purseLen != sizeof(_ksx6924_internal_purse_info_t)) {
// Invalid size!
PrintAndLogEx(FAILED, "Expected %ld bytes, got %ld\n", sizeof(_ksx6924_internal_purse_info_t), purseLen);
PrintAndLogEx(FAILED, "Expected %zu bytes, got %zu\n", sizeof(_ksx6924_internal_purse_info_t), purseLen);
return false;
}
@@ -493,7 +493,7 @@ bool KSX6924ParseInitializeCardResponse(const uint8_t *initCardResponse, size_t
if (resp_len != sizeof(_ksx6924_initialize_card_response_t)) {
// Invalid size!
PrintAndLogEx(FAILED, "Expected %ld bytes, got %ld\n", sizeof(_ksx6924_initialize_card_response_t), resp_len);
PrintAndLogEx(FAILED, "Expected %zu bytes, got %zu\n", sizeof(_ksx6924_initialize_card_response_t), resp_len);
return false;
}
+1 -1
View File
@@ -1612,7 +1612,7 @@ void HIDListFormats(void) {
++i;
}
PrintAndLogEx(INFO, "------------------------------------------------------------");
PrintAndLogEx(INFO, "Available card formats: " _YELLOW_("%" PRIu64), ARRAYLEN(FormatTable) - 1);
PrintAndLogEx(INFO, "Available card formats: " _YELLOW_("%zu"), ARRAYLEN(FormatTable) - 1);
PrintAndLogEx(NORMAL, "");
return;
}