From fa0cf05d0a945741f93265b9bb90ce155fbf4f4b Mon Sep 17 00:00:00 2001 From: Frederik Haxel Date: Thu, 21 Dec 2023 11:45:56 +0100 Subject: [PATCH] tests: Use size_t print format specifier Co-authored-by: Marian Buschsieweke --- tests/bench/sizeof_coretypes/main.c | 62 +++++++++---------- tests/core/thread_stack_alignment/main.c | 3 +- tests/drivers/at/main.c | 8 +-- tests/drivers/at24cxxx/main.c | 2 +- tests/drivers/ata8520e/main.c | 4 +- tests/drivers/matrix_keypad/main.c | 2 +- tests/drivers/rn2xx3/main.c | 2 +- tests/drivers/sx126x/main.c | 11 ++-- tests/drivers/sx127x/main.c | 10 +-- tests/drivers/sx1280/main.c | 9 +-- tests/net/emcute/main.c | 14 ++--- tests/net/gnrc_ipv6_ext_frag/main.c | 4 +- tests/net/gnrc_ipv6_ext_frag/udp.c | 2 +- tests/net/gnrc_ipv6_fwd_w_sub/main.c | 6 +- tests/net/gnrc_tcp/main.c | 4 +- tests/net/gnrc_tx_sync/main.c | 2 +- tests/net/gnrc_udp/udp.c | 2 +- tests/net/ieee802154_submac/main.c | 2 +- tests/net/nanocoap_cli/nanocli_client.c | 8 +-- tests/periph/eeprom/main.c | 9 +-- tests/periph/flashpage/main.c | 5 +- tests/periph/spi/main.c | 4 +- tests/pkg/edhoc_c/initiator.c | 4 +- tests/pkg/edhoc_c/responder.c | 2 +- tests/pkg/lwip/ip.c | 5 +- tests/pkg/lwip/tcp.c | 2 +- tests/pkg/lwip/udp.c | 4 +- tests/pkg/nanors/main.c | 5 +- tests/pkg/nimble_l2cap/main.c | 2 +- tests/pkg/openwsn/udp.c | 4 +- tests/pkg/tinydtls_sock_async/dtls-server.c | 6 +- tests/pkg/umorse/main.c | 4 +- tests/riotboot_flashwrite/coap_handler.c | 8 ++- tests/sys/bloom_bytes/main.c | 3 +- tests/sys/malloc/main.c | 3 +- tests/sys/memarray/main.c | 37 +++++------ tests/sys/pthread/main.c | 4 +- tests/sys/shell/main.c | 3 +- tests/sys/usbus/main.c | 7 +-- tests/unittests/tests-fib/tests-fib.c | 18 +++--- tests/unittests/tests-fib_sr/tests-fib_sr.c | 2 +- .../tests-uri_parser/tests-uri_parser.c | 5 +- 42 files changed, 156 insertions(+), 147 deletions(-) diff --git a/tests/bench/sizeof_coretypes/main.c b/tests/bench/sizeof_coretypes/main.c index 37221a1185..7eddb53428 100644 --- a/tests/bench/sizeof_coretypes/main.c +++ b/tests/bench/sizeof_coretypes/main.c @@ -38,9 +38,9 @@ #endif #include "thread.h" -#define P(NAME) printf(" tcb->%-11s %3u %3u\n", #NAME, \ - (unsigned)sizeof(((thread_t *) 0)->NAME), \ - (unsigned)offsetof(thread_t, NAME)) +#define P(NAME) printf(" tcb->%-11s %3" PRIuSIZE " %3" PRIuSIZE "\n", #NAME, \ + sizeof(((thread_t *) 0)->NAME), \ + offsetof(thread_t, NAME)) int main(void) { @@ -48,43 +48,43 @@ int main(void) puts(" size"); - printf("sizeof(cib_t): %3u\n", - (unsigned)sizeof(cib_t)); - printf("sizeof(clist_node_t): %3u\n", - (unsigned)sizeof(clist_node_t)); - printf("sizeof(core_panic_t): %3u\n", - (unsigned)sizeof(core_panic_t)); - printf("sizeof(kernel_pid_t): %3u\n", - (unsigned)sizeof(kernel_pid_t)); - printf("sizeof(list_node_t): %3u\n", - (unsigned)sizeof(list_node_t)); - printf("sizeof(mbox_t): %3u\n", - (unsigned)sizeof(mbox_t)); + printf("sizeof(cib_t): %3" PRIuSIZE "\n", + sizeof(cib_t)); + printf("sizeof(clist_node_t): %3" PRIuSIZE "\n", + sizeof(clist_node_t)); + printf("sizeof(core_panic_t): %3" PRIuSIZE "\n", + sizeof(core_panic_t)); + printf("sizeof(kernel_pid_t): %3" PRIuSIZE "\n", + sizeof(kernel_pid_t)); + printf("sizeof(list_node_t): %3" PRIuSIZE "\n", + sizeof(list_node_t)); + printf("sizeof(mbox_t): %3" PRIuSIZE "\n", + sizeof(mbox_t)); #ifdef MODULE_CORE_MSG - printf("sizeof(msg_t): %3u\n", - (unsigned)sizeof(msg_t)); + printf("sizeof(msg_t): %3" PRIuSIZE "\n", + sizeof(msg_t)); #else puts("sizeof(msg_t): 0 (not enabled)"); #endif - printf("sizeof(mutex_t): %3u\n", - (unsigned)sizeof(mutex_t)); - printf("sizeof(priority_queue_node_t): %3u\n", - (unsigned)sizeof(priority_queue_node_t)); - printf("sizeof(priority_queue_t): %3u\n", - (unsigned)sizeof(priority_queue_t)); - printf("sizeof(ringbuffer_t): %3u\n", - (unsigned)sizeof(ringbuffer_t)); - printf("sizeof(rmutex_t): %3u\n", - (unsigned)sizeof(rmutex_t)); + printf("sizeof(mutex_t): %3" PRIuSIZE "\n", + sizeof(mutex_t)); + printf("sizeof(priority_queue_node_t): %3" PRIuSIZE "\n", + sizeof(priority_queue_node_t)); + printf("sizeof(priority_queue_t): %3" PRIuSIZE "\n", + sizeof(priority_queue_t)); + printf("sizeof(ringbuffer_t): %3" PRIuSIZE "\n", + sizeof(ringbuffer_t)); + printf("sizeof(rmutex_t): %3" PRIuSIZE "\n", + sizeof(rmutex_t)); #ifdef MODULE_CORE_THREAD_FLAGS - printf("sizeof(thread_flags_t): %3u\n", - (unsigned)sizeof(thread_flags_t)); + printf("sizeof(thread_flags_t): %3" PRIuSIZE "\n", + sizeof(thread_flags_t)); #else puts("sizeof(thread_flags_t): 0 (not enabled)"); #endif printf("\nTCB (thread_t) details: size offset\n"); - printf("sizeof(thread_t): %3u -\n", - (unsigned)sizeof(thread_t)); + printf("sizeof(thread_t): %3" PRIuSIZE " -\n", + sizeof(thread_t)); P(sp); P(status); P(priority); diff --git a/tests/core/thread_stack_alignment/main.c b/tests/core/thread_stack_alignment/main.c index 818ba696d3..7a89e2a8bc 100644 --- a/tests/core/thread_stack_alignment/main.c +++ b/tests/core/thread_stack_alignment/main.c @@ -27,6 +27,7 @@ * so do not sort this one alphabetically */ #include +#include "architecture.h" #include "irq.h" #include "sched.h" #include "thread.h" @@ -79,7 +80,7 @@ int main(void) (unsigned)STACKSIZE, (unsigned)ALIGNMENT); for (size_t i = 0; i < ALIGNMENT; i++) { atomic_store(&test_failed, false); - printf("Testing for alignment %u: ", (unsigned)i); + printf("Testing for alignment %" PRIuSIZE ": ", i); kernel_pid_t p; p = thread_create(stack + i, STACKSIZE, THREAD_PRIORITY_MAIN - 1, THREAD_CREATE_STACKTEST, diff --git a/tests/drivers/at/main.c b/tests/drivers/at/main.c index e424ac8b78..14e6f4c17a 100644 --- a/tests/drivers/at/main.c +++ b/tests/drivers/at/main.c @@ -80,7 +80,7 @@ static int send(int argc, char **argv) return 1; } - printf("Response (len=%d): %s\n", (int)len, resp); + printf("Response (len=%" PRIdSIZE "): %s\n", len, resp); return 0; } @@ -115,7 +115,7 @@ static int send_lines(int argc, char **argv) return 1; } - printf("Response (len=%d): %s\n", (int)len, resp); + printf("Response (len=%" PRIdSIZE "): %s\n", len, resp); return 0; } @@ -134,7 +134,7 @@ static int send_recv_bytes(int argc, char **argv) ssize_t len = at_recv_bytes(&at_dev, buffer, atoi(argv[2]), 10 * US_PER_SEC); - printf("Response (len=%d): %s\n", (int)len, buffer); + printf("Response (len=%" PRIdSIZE "): %s\n", len, buffer); return 0; } @@ -163,7 +163,7 @@ static int send_recv_bytes_until_string(int argc, char **argv) return 1; } - printf("Response (len=%d): %s\n", (int)len, buffer); + printf("Response (len=%" PRIdSIZE "): %s\n", len, buffer); return 0; } diff --git a/tests/drivers/at24cxxx/main.c b/tests/drivers/at24cxxx/main.c index 4282891982..8f06fc3001 100644 --- a/tests/drivers/at24cxxx/main.c +++ b/tests/drivers/at24cxxx/main.c @@ -113,7 +113,7 @@ int main(void) check = at24cxxx_write(&at24cxxx_dev, WRITE_POSITION, expected_write_data, sizeof(expected_write_data)); if (check != AT24CXXX_OK) { - printf("[FAILURE] at24cxxx_write: %d (size = %zu)\n", check, + printf("[FAILURE] at24cxxx_write: %d (size = %" PRIuSIZE ")\n", check, sizeof(expected_write_data)); return 1; } diff --git a/tests/drivers/ata8520e/main.c b/tests/drivers/ata8520e/main.c index d88b3091eb..624f60e3ce 100644 --- a/tests/drivers/ata8520e/main.c +++ b/tests/drivers/ata8520e/main.c @@ -80,7 +80,7 @@ int ata8520e_sigfox_cmd(int argc, char **argv) else { if (strlen(argv[2]) > SIGFOX_MAX_TX_LENGTH) { printf("Message length cannot exceeds %d characters length, your " - "message length is %u", SIGFOX_MAX_TX_LENGTH, (unsigned)strlen(argv[2])); + "message length is %" PRIuSIZE, SIGFOX_MAX_TX_LENGTH, strlen(argv[2])); return 1; } if (ata8520e_send_frame(&dev, @@ -99,7 +99,7 @@ int ata8520e_sigfox_cmd(int argc, char **argv) } if (strlen(argv[2]) > SIGFOX_MAX_TX_LENGTH) { printf("Message length cannot exceeds %d characters length, your " - "message length is %u", SIGFOX_MAX_TX_LENGTH, (unsigned)strlen(argv[2])); + "message length is %" PRIuSIZE, SIGFOX_MAX_TX_LENGTH, strlen(argv[2])); return 1; } uint8_t rx_buf[SIGFOX_RX_LENGTH]; diff --git a/tests/drivers/matrix_keypad/main.c b/tests/drivers/matrix_keypad/main.c index fe45af0786..bbc6706e6f 100644 --- a/tests/drivers/matrix_keypad/main.c +++ b/tests/drivers/matrix_keypad/main.c @@ -27,7 +27,7 @@ void _callback(void *arg, size_t col, size_t row, bool state) { (void)arg; - printf("Key switch at column %u and row %u is ", (unsigned)col, (unsigned)row); + printf("Key switch at column %" PRIuSIZE " and row %" PRIuSIZE " is ", col, row); if (state) { puts("pressed!"); } diff --git a/tests/drivers/rn2xx3/main.c b/tests/drivers/rn2xx3/main.c index d8107acf16..bda96be1b2 100644 --- a/tests/drivers/rn2xx3/main.c +++ b/tests/drivers/rn2xx3/main.c @@ -214,7 +214,7 @@ int rn2xx3_mac_cmd(int argc, char **argv) { puts("MAC transmission succeeded"); puts("Data received:"); printf(" -port: %d\n", rn2xx3_mac_get_rx_port(&rn2xx3_dev)); - printf(" -payload len: %d\n", (uint8_t)strlen((char *)rn2xx3_dev.rx_buf)); + printf(" -payload len: %" PRIuSIZE "\n", strlen((char *)rn2xx3_dev.rx_buf)); printf(" -payload: '%s'\n", rn2xx3_dev.rx_buf); } break; diff --git a/tests/drivers/sx126x/main.c b/tests/drivers/sx126x/main.c index 038aa86fff..175abd103d 100644 --- a/tests/drivers/sx126x/main.c +++ b/tests/drivers/sx126x/main.c @@ -23,6 +23,7 @@ #include #include +#include "architecture.h" #include "msg.h" #include "thread.h" #include "shell.h" @@ -68,9 +69,9 @@ static void _event_cb(netdev_t *dev, netdev_event_t event) netdev_lora_rx_info_t packet_info; dev->driver->recv(dev, message, len, &packet_info); printf( - "Received: \"%s\" (%d bytes) - [RSSI: %i, SNR: %i, TOA: %" PRIu32 "ms]\n", - message, (int)len, - packet_info.rssi, (int)packet_info.snr, + "Received: \"%s\" (%" PRIuSIZE " bytes) - [RSSI: %i, SNR: %i, TOA: %" PRIu32 "ms]\n", + message, len, + packet_info.rssi, packet_info.snr, sx126x_get_lora_time_on_air_in_ms(&sx126x.pkt_params, &sx126x.mod_params) ); netopt_state_t state = NETOPT_STATE_RX; @@ -273,8 +274,8 @@ static int sx126x_tx_cmd(netdev_t *netdev, int argc, char **argv) return -1; } - printf("sending \"%s\" payload (%u bytes)\n", - argv[2], (unsigned)strlen(argv[2]) + 1); + printf("sending \"%s\" payload (%" PRIuSIZE " bytes)\n", + argv[2], strlen(argv[2]) + 1); iolist_t iolist = { .iol_base = argv[2], .iol_len = (strlen(argv[2]) + 1) diff --git a/tests/drivers/sx127x/main.c b/tests/drivers/sx127x/main.c index 13f3d8a354..216fed80a3 100644 --- a/tests/drivers/sx127x/main.c +++ b/tests/drivers/sx127x/main.c @@ -240,8 +240,8 @@ int send_cmd(int argc, char **argv) return -1; } - printf("sending \"%s\" payload (%u bytes)\n", - argv[1], (unsigned)strlen(argv[1]) + 1); + printf("sending \"%s\" payload (%" PRIuSIZE " bytes)\n", + argv[1], strlen(argv[1]) + 1); iolist_t iolist = { .iol_base = argv[1], @@ -492,9 +492,9 @@ static void _event_cb(netdev_t *dev, netdev_event_t event) len = dev->driver->recv(dev, NULL, 0, 0); dev->driver->recv(dev, message, len, &packet_info); printf( - "{Payload: \"%s\" (%d bytes), RSSI: %i, SNR: %i, TOA: %" PRIu32 "}\n", - message, (int)len, - packet_info.rssi, (int)packet_info.snr, + "{Payload: \"%s\" (%" PRIuSIZE " bytes), RSSI: %i, SNR: %i, TOA: %" PRIu32 "}\n", + message, len, + packet_info.rssi, packet_info.snr, sx127x_get_time_on_air((const sx127x_t *)dev, len)); break; diff --git a/tests/drivers/sx1280/main.c b/tests/drivers/sx1280/main.c index b49f24f858..d90cd3e7d5 100644 --- a/tests/drivers/sx1280/main.c +++ b/tests/drivers/sx1280/main.c @@ -24,6 +24,7 @@ #include #include +#include "architecture.h" #include "msg.h" #include "thread.h" #include "shell.h" @@ -69,8 +70,8 @@ static void _event_cb(netdev_t *dev, netdev_event_t event) netdev_lora_rx_info_t packet_info; dev->driver->recv(dev, message, len, &packet_info); printf( - "Received: \"%s\" (%d bytes) - [RSSI: %i, SNR: %i]\n", - message, (int)len, packet_info.rssi, (int)packet_info.snr); + "Received: \"%s\" (%" PRIuSIZE " bytes) - [RSSI: %i, SNR: %i]\n", + message, len, packet_info.rssi, packet_info.snr); } break; @@ -282,8 +283,8 @@ static int sx1280_tx_cmd(netdev_t *netdev, int argc, char **argv) return -1; } - printf("sending \"%s\" payload (%u bytes)\n", - argv[2], (unsigned)strlen(argv[2]) + 1); + printf("sending \"%s\" payload (%" PRIuSIZE " bytes)\n", + argv[2], strlen(argv[2]) + 1); iolist_t iolist = { .iol_base = argv[2], .iol_len = (strlen(argv[2]) + 1) diff --git a/tests/net/emcute/main.c b/tests/net/emcute/main.c index 9637dc5193..3d63146ef4 100644 --- a/tests/net/emcute/main.c +++ b/tests/net/emcute/main.c @@ -89,8 +89,8 @@ static unsigned _get_qos(const char *str) static void _on_pub(const emcute_topic_t *topic, void *data, size_t len) { (void)data; - printf("### got publication of %u bytes for topic '%s' [%d] ###\n", - (unsigned)len, topic->name, (int)topic->id); + printf("### got publication of %" PRIuSIZE " bytes for topic '%s' [%u] ###\n", + len, topic->name, topic->id); } static int _con(int argc, char **argv) @@ -224,18 +224,18 @@ static int _pub(int argc, char **argv) t = &_topics[idx]; len = atoi(argv[2]); if ((unsigned)len > sizeof(_pub_buf)) { - printf("error: len %d > %lu\n", len, (unsigned long)sizeof(_pub_buf)); + printf("error: len %d > %" PRIuSIZE "\n", len, sizeof(_pub_buf)); return 1; } memset(_pub_buf, 92, len); if (emcute_pub(t, _pub_buf, len, flags) != EMCUTE_OK) { - printf("error: unable to publish data to topic '%s [%d]'\n", - t->name, (int)t->id); + printf("error: unable to publish data to topic '%s [%u]'\n", + t->name, t->id); return 1; } - printf("success: published %d bytes to topic '%s [%d]'\n", - (int)len, t->name, t->id); + printf("success: published %d bytes to topic '%s [%u]'\n", + len, t->name, t->id); return 0; } diff --git a/tests/net/gnrc_ipv6_ext_frag/main.c b/tests/net/gnrc_ipv6_ext_frag/main.c index b6be3cbd08..b92d97f1ff 100644 --- a/tests/net/gnrc_ipv6_ext_frag/main.c +++ b/tests/net/gnrc_ipv6_ext_frag/main.c @@ -604,8 +604,8 @@ static int shell_test_cmd(int argc, char **argv) } test_num = atoi(argv[2]); if ((unsigned)test_num >= ARRAY_SIZE(_shell_tests)) { - printf(" must be between 0 and %u\n", - (unsigned)ARRAY_SIZE(_shell_tests) - 1); + printf(" must be between 0 and %" PRIuSIZE "\n", + ARRAY_SIZE(_shell_tests) - 1); return 1; } printf("Running test %d\n", test_num); diff --git a/tests/net/gnrc_ipv6_ext_frag/udp.c b/tests/net/gnrc_ipv6_ext_frag/udp.c index 442cfefd89..cfaf083d00 100644 --- a/tests/net/gnrc_ipv6_ext_frag/udp.c +++ b/tests/net/gnrc_ipv6_ext_frag/udp.c @@ -106,7 +106,7 @@ static void send(char *addr_str, char *port_str, char *data_len_str, unsigned in } /* access to `payload` was implicitly given up with the send operation above * => use original variable for output */ - printf("Success: send %u byte to [%s]:%u\n", (unsigned)data_len, addr_str, + printf("Success: send %" PRIuSIZE " byte to [%s]:%u\n", data_len, addr_str, port); xtimer_usleep(delay); } diff --git a/tests/net/gnrc_ipv6_fwd_w_sub/main.c b/tests/net/gnrc_ipv6_fwd_w_sub/main.c index 7cb2bf147d..70ff3904ef 100644 --- a/tests/net/gnrc_ipv6_fwd_w_sub/main.c +++ b/tests/net/gnrc_ipv6_fwd_w_sub/main.c @@ -110,9 +110,9 @@ static int _dump_etherframe(netdev_t *dev, const iolist_t *iolist) (void)dev; while (iolist) { if ((outbuf_len + iolist->iol_len) > sizeof(outbuf)) { - printf("Ignoring packet: %u > %u\n", - (unsigned)(outbuf_len + iolist->iol_len), - (unsigned)sizeof(outbuf)); + printf("Ignoring packet: %" PRIuSIZE " > %" PRIuSIZE "\n", + (outbuf_len + iolist->iol_len), + sizeof(outbuf)); /* ignore larger packets */ return outbuf_len; } diff --git a/tests/net/gnrc_tcp/main.c b/tests/net/gnrc_tcp/main.c index 98b88ffe3e..193485bdf2 100644 --- a/tests/net/gnrc_tcp/main.c +++ b/tests/net/gnrc_tcp/main.c @@ -278,7 +278,7 @@ int gnrc_tcp_send_cmd(int argc, char **argv) sent += ret; } while (sent < to_send); - printf("%s: sent %u\n", argv[0], (unsigned)sent); + printf("%s: sent %" PRIuSIZE "\n", argv[0], sent); return sent; } @@ -321,7 +321,7 @@ int gnrc_tcp_recv_cmd(int argc, char **argv) rcvd += ret; } while (rcvd < to_receive); - printf("%s: received %u\n", argv[0], (unsigned)rcvd); + printf("%s: received %" PRIuSIZE "\n", argv[0], rcvd); return 0; } diff --git a/tests/net/gnrc_tx_sync/main.c b/tests/net/gnrc_tx_sync/main.c index a0898c3242..a3e33b31ea 100644 --- a/tests/net/gnrc_tx_sync/main.c +++ b/tests/net/gnrc_tx_sync/main.c @@ -230,7 +230,7 @@ int main(void) int sends_expected = (IS_USED(MODULE_NETDEV_IEEE802154)) ? 2 : 1; printf("transmissions expected = %d, transmissions completed = %d\n", sends_expected, sends); - printf("sent %u out of %u bytes\n", pld_pos, (unsigned)sizeof(test_msg)); + printf("sent %u out of %" PRIuSIZE " bytes\n", pld_pos, sizeof(test_msg)); expect(sends == sends_expected); expect(pld_pos == sizeof(test_msg)); diff --git a/tests/net/gnrc_udp/udp.c b/tests/net/gnrc_udp/udp.c index 6da8c1e8ad..32eced16ea 100644 --- a/tests/net/gnrc_udp/udp.c +++ b/tests/net/gnrc_udp/udp.c @@ -158,7 +158,7 @@ static void send(char *addr_str, char *port_str, char *data_len_str, unsigned in } /* access to `payload` was implicitly given up with the send operation above * => use original variable for output */ - printf("Success: send %u byte to [%s]:%u\n", (unsigned)data_len, addr_str, + printf("Success: send %" PRIuSIZE " byte to [%s]:%u\n", data_len, addr_str, port); xtimer_usleep(delay); } diff --git a/tests/net/ieee802154_submac/main.c b/tests/net/ieee802154_submac/main.c index 212e387168..d1c707e995 100644 --- a/tests/net/ieee802154_submac/main.c +++ b/tests/net/ieee802154_submac/main.c @@ -344,7 +344,7 @@ static void submac_rx_done(ieee802154_submac_t *submac) printf("%u, ", (unsigned)((buffer[1] & IEEE802154_FCF_VERS_MASK) >> 4)); printf("Seq.: %u\n", (unsigned)ieee802154_get_seq(buffer)); od_hex_dump(buffer + mhr_len, data_len - mhr_len, 0); - printf("txt (%u chars): ", data_len - mhr_len); + printf("txt (%" PRIuSIZE " chars): ", data_len - mhr_len); for (int i = mhr_len; i < data_len; i++) { if ((buffer[i] > 0x1F) && (buffer[i] < 0x80)) { putchar((char)buffer[i]); diff --git a/tests/net/nanocoap_cli/nanocli_client.c b/tests/net/nanocoap_cli/nanocli_client.c index b8c8d45e23..d6349ca254 100644 --- a/tests/net/nanocoap_cli/nanocli_client.c +++ b/tests/net/nanocoap_cli/nanocli_client.c @@ -126,12 +126,12 @@ int nanotest_client_cmd(int argc, char **argv) len = coap_opt_finish(&pkt, COAP_OPT_FINISH_NONE); } - printf("nanocli: sending msg ID %u, %u bytes\n", coap_get_id(&pkt), - (unsigned) len); + printf("nanocli: sending msg ID %u, %" PRIuSIZE " bytes\n", coap_get_id(&pkt), + len); ssize_t res = _send(&pkt, buflen, argv[2], argv[3]); if (res < 0) { - printf("nanocli: msg send failed: %d\n", (int)res); + printf("nanocli: msg send failed: %" PRIdSIZE "\n", res); } else { char *class_str = (coap_get_code_class(&pkt) == COAP_CLASS_SUCCESS) @@ -171,7 +171,7 @@ static int _blockwise_cb(void *arg, size_t offset, uint8_t *buf, size_t len, int (void)arg; (void)more; - printf("offset %03u: ", (unsigned)offset); + printf("offset %03" PRIuSIZE ": ", offset); for (unsigned i = 0; i < len; ++i) { putchar(buf[i]); } diff --git a/tests/periph/eeprom/main.c b/tests/periph/eeprom/main.c index e6d10009e6..0127afd859 100644 --- a/tests/periph/eeprom/main.c +++ b/tests/periph/eeprom/main.c @@ -22,6 +22,7 @@ #include #include +#include "architecture.h" #include "shell.h" #include "test_utils/expect.h" @@ -74,7 +75,7 @@ static int cmd_read(int argc, char **argv) size_t ret = eeprom_read(pos, (uint8_t *)buffer, count); buffer[count] = '\0'; - printf("Data read from EEPROM (%d bytes): %s\n", (int)ret, buffer); + printf("Data read from EEPROM (%" PRIuSIZE " bytes): %s\n", ret, buffer); return 0; } @@ -114,7 +115,7 @@ static int cmd_write(int argc, char **argv) } size_t ret = eeprom_write(pos, (uint8_t *)argv[2], strlen(argv[2])); - printf("%d bytes written to EEPROM\n", (int)ret); + printf("%" PRIuSIZE " bytes written to EEPROM\n", ret); return 0; } @@ -162,7 +163,7 @@ static int cmd_set(int argc, char **argv) } size_t ret = eeprom_set(pos, c, count); - printf("%d bytes set to %c in EEPROM\n", (int)ret, c); + printf("%" PRIuSIZE " bytes set to %c in EEPROM\n", ret, c); return 0; } @@ -183,7 +184,7 @@ static int cmd_clear(int argc, char **argv) } size_t ret = eeprom_clear(pos, count); - printf("%d bytes cleared in EEPROM\n", (int)ret); + printf("%" PRIuSIZE " bytes cleared in EEPROM\n", ret); return 0; } diff --git a/tests/periph/flashpage/main.c b/tests/periph/flashpage/main.c index d152b305a4..3bdc087fdd 100644 --- a/tests/periph/flashpage/main.c +++ b/tests/periph/flashpage/main.c @@ -24,6 +24,7 @@ #include #include +#include "architecture.h" #include "od.h" #include "shell.h" #include "periph/flashpage.h" @@ -233,10 +234,10 @@ static int cmd_write_raw(int argc, char **argv) flashpage_write((void*)addr, raw_buf, strlen(raw_buf)); #if (__SIZEOF_POINTER__ == 2) - printf("wrote local data to flash address %#" PRIx16 " of len %u\n", + printf("wrote local data to flash address %#" PRIx16 " of len %" PRIuSIZE "\n", addr, strlen(raw_buf)); #else - printf("wrote local data to flash address %#" PRIx32 " of len %u\n", + printf("wrote local data to flash address %#" PRIx32 " of len %" PRIuSIZE "\n", addr, strlen(raw_buf)); #endif return 0; diff --git a/tests/periph/spi/main.c b/tests/periph/spi/main.c index cbd12cdb98..557ab0f0f9 100644 --- a/tests/periph/spi/main.c +++ b/tests/periph/spi/main.c @@ -112,11 +112,11 @@ static void print_bytes(const char *title, const uint8_t *data, size_t len) { printf("%4s\n", title); for (size_t i = 0; i < len; i++) { - printf(" %2i ", (int)i); + printf(" %2" PRIuSIZE " ", i); } printf("\n "); for (size_t i = 0; i < len; i++) { - printf(" 0x%02x", (int)data[i]); + printf(" 0x%02x", data[i]); } printf("\n "); for (size_t i = 0; i < len; i++) { diff --git a/tests/pkg/edhoc_c/initiator.c b/tests/pkg/edhoc_c/initiator.c index 81a0c64399..c0597ef375 100644 --- a/tests/pkg/edhoc_c/initiator.c +++ b/tests/pkg/edhoc_c/initiator.c @@ -162,7 +162,7 @@ int _handshake_cmd(int argc, char **argv) _ctx.state = EDHOC_WAITING; if ((msg_len = edhoc_create_msg1(&_ctx, corr, _method, _suite, msg, sizeof(msg))) > 0) { - printf("[initiator]: sending msg1 (%d bytes):\n", (int)msg_len); + printf("[initiator]: sending msg1 (%" PRIdSIZE " bytes):\n", msg_len); print_bstr(msg, msg_len); _build_coap_pkt(&pkt, buf, sizeof(buf), msg, msg_len); len = _send(&pkt, COAP_BUF_SIZE, &addr, netif, port); @@ -180,7 +180,7 @@ int _handshake_cmd(int argc, char **argv) print_bstr(pkt.payload, pkt.payload_len); if ((msg_len = edhoc_create_msg3(&_ctx, pkt.payload, pkt.payload_len, msg, sizeof(msg))) > 0) { - printf("[initiator]: sending msg3 (%d bytes):\n", (int)msg_len); + printf("[initiator]: sending msg3 (%" PRIdSIZE " bytes):\n", msg_len); print_bstr(msg, msg_len); _build_coap_pkt(&pkt, buf, sizeof(buf), msg, msg_len); len = _send(&pkt, COAP_BUF_SIZE, &addr, netif, port); diff --git a/tests/pkg/edhoc_c/responder.c b/tests/pkg/edhoc_c/responder.c index f920beacf5..11a59ebea0 100644 --- a/tests/pkg/edhoc_c/responder.c +++ b/tests/pkg/edhoc_c/responder.c @@ -74,7 +74,7 @@ ssize_t _edhoc_handler(coap_pkt_t *pkt, uint8_t *buf, size_t len, coap_request_c uint8_t msg[COAP_BUF_SIZE]; if ((msg_len = edhoc_create_msg2(&_ctx, pkt->payload, pkt->payload_len, msg, sizeof(msg))) >= 0) { - printf("[responder]: sending msg2 (%d bytes):\n", (int) msg_len); + printf("[responder]: sending msg2 (%" PRIdSIZE " bytes):\n", msg_len); print_bstr(msg, msg_len); msg_len = coap_reply_simple(pkt, COAP_CODE_204, buf, len, COAP_FORMAT_OCTET, msg, msg_len); diff --git a/tests/pkg/lwip/ip.c b/tests/pkg/lwip/ip.c index f740840271..750b174d1b 100644 --- a/tests/pkg/lwip/ip.c +++ b/tests/pkg/lwip/ip.c @@ -155,9 +155,8 @@ static int ip_send(char *addr_str, char *port_str, char *data, unsigned int num, puts("could not send"); } else { - printf("Success: send %u byte over %s to %s (next header: %u)\n", - (unsigned)data_len, - (dst.family == AF_INET6) ? "IPv6" : "IPv4", + printf("Success: send %" PRIuSIZE " byte over %s to %s (next header: %u)\n", + data_len, (dst.family == AF_INET6) ? "IPv6" : "IPv4", addr_str, protocol); } ztimer_sleep(ZTIMER_USEC, delay); diff --git a/tests/pkg/lwip/tcp.c b/tests/pkg/lwip/tcp.c index 37b91b591c..c14843c59a 100644 --- a/tests/pkg/lwip/tcp.c +++ b/tests/pkg/lwip/tcp.c @@ -172,7 +172,7 @@ static int tcp_send(char *data, unsigned int num, unsigned int delay) puts("could not send"); } else { - printf("Success: send %u byte over TCP to server\n", (unsigned)data_len); + printf("Success: send %" PRIuSIZE " byte over TCP to server\n", data_len); } ztimer_sleep(ZTIMER_USEC, delay); } diff --git a/tests/pkg/lwip/udp.c b/tests/pkg/lwip/udp.c index 424d2a8512..74feb17f5d 100644 --- a/tests/pkg/lwip/udp.c +++ b/tests/pkg/lwip/udp.c @@ -118,8 +118,8 @@ static int udp_send(char *addr_str, char *data, unsigned int num, puts("could not send"); } else { - printf("Success: send %u byte over UDP to %s\n", - (unsigned)data_len, addr_str); + printf("Success: send %" PRIuSIZE " byte over UDP to %s\n", + data_len, addr_str); } ztimer_sleep(ZTIMER_USEC, delay); } diff --git a/tests/pkg/nanors/main.c b/tests/pkg/nanors/main.c index 343579d53c..e81360e685 100644 --- a/tests/pkg/nanors/main.c +++ b/tests/pkg/nanors/main.c @@ -20,6 +20,7 @@ #include #include +#include "architecture.h" #include "kernel_defines.h" #include "random.h" #include "rs.h" @@ -61,8 +62,8 @@ int main(void) return -1; } - printf("total: %u shards (%u bytes)\n", - (unsigned)ARRAY_SIZE(marks), (unsigned)sizeof(data)); + printf("total: %" PRIuSIZE " shards (%" PRIuSIZE " bytes)\n", + ARRAY_SIZE(marks), sizeof(data)); /* generate parity shards */ reed_solomon_encode(rs, shards, ARRAY_SIZE(shards), SHARD_SIZE); diff --git a/tests/pkg/nimble_l2cap/main.c b/tests/pkg/nimble_l2cap/main.c index 5a03a503c0..c83f4a3b5b 100644 --- a/tests/pkg/nimble_l2cap/main.c +++ b/tests/pkg/nimble_l2cap/main.c @@ -186,7 +186,7 @@ static void _send(uint32_t type, uint32_t seq, size_t len) expect(_coc); expect(len >= 8); expect(len <= APP_MTU); - printf("# Sending: size %5u seq %5u\n", (unsigned)len, (unsigned)seq); + printf("# Sending: size %5" PRIuSIZE " seq %5" PRIu32 "\n", len, seq); _txbuf[POS_TYPE] = type; _txbuf[POS_SEQ] = seq; diff --git a/tests/pkg/openwsn/udp.c b/tests/pkg/openwsn/udp.c index 9325b297df..f6e07349bd 100644 --- a/tests/pkg/openwsn/udp.c +++ b/tests/pkg/openwsn/udp.c @@ -102,8 +102,8 @@ static int udp_send(char *addr_str, char *port_str, char *data, for (unsigned int i = 0; i < num; i++) { - printf("Send %u byte over UDP to [%s]:%s\n", - (unsigned)data_len, addr_str, port_str); + printf("Send %" PRIuSIZE " byte over UDP to [%s]:%s\n", + data_len, addr_str, port_str); /* don't run if not in synch */ if (ieee154e_isSynch() == FALSE) { diff --git a/tests/pkg/tinydtls_sock_async/dtls-server.c b/tests/pkg/tinydtls_sock_async/dtls-server.c index 4ea6703695..0796e95a12 100644 --- a/tests/pkg/tinydtls_sock_async/dtls-server.c +++ b/tests/pkg/tinydtls_sock_async/dtls-server.c @@ -156,10 +156,10 @@ static void _dtls_handler(sock_dtls_t *sock, sock_async_flags_t type, void *arg) res = sock_dtls_recv(sock, &session, _recv_buf, sizeof(_recv_buf), 0); if (res >= 0) { - printf("Received %d bytes -- (echo)\n", (int)res); + printf("Received %" PRIdSIZE " bytes -- (echo)\n", res); res = sock_dtls_send(sock, &session, _recv_buf, (size_t)res, 0); if (res < 0) { - printf("Error resending DTLS message: %d\n", (int)res); + printf("Error resending DTLS message: %" PRIdSIZE "\n", res); } } } @@ -183,7 +183,7 @@ static int start_server(void) res = credman_add(&credential); if (res < 0 && res != CREDMAN_EXIST) { /* ignore duplicate credentials */ - printf("Error cannot add credential to system: %d\n", (int)res); + printf("Error cannot add credential to system: %" PRIdSIZE "\n", res); return 1; } res = sock_dtls_create(&_dtls_sock, &_udp_sock, SOCK_DTLS_SERVER_TAG, diff --git a/tests/pkg/umorse/main.c b/tests/pkg/umorse/main.c index 7f7e997eef..29b6e12101 100644 --- a/tests/pkg/umorse/main.c +++ b/tests/pkg/umorse/main.c @@ -78,8 +78,8 @@ int test_umorse_out(void) { uint8_t code[CODE_LEN]; - printf("> Translate text of length %u into Morse code:\n\"%s\"\n", - (unsigned)strlen(text), text); + printf("> Translate text of length %" PRIuSIZE " into Morse code:\n\"%s\"\n", + strlen(text), text); memset(code, 0, CODE_LEN); printf("> using aligned encoding:\n"); diff --git a/tests/riotboot_flashwrite/coap_handler.c b/tests/riotboot_flashwrite/coap_handler.c index 50fd24c275..4a892e10c7 100644 --- a/tests/riotboot_flashwrite/coap_handler.c +++ b/tests/riotboot_flashwrite/coap_handler.c @@ -24,8 +24,9 @@ ssize_t _flashwrite_handler(coap_pkt_t* pkt, uint8_t *buf, size_t len, coap_requ coap_block1_t block1; int blockwise = coap_get_block1(pkt, &block1); - printf("_flashwrite_handler(): received data: offset=%u len=%u blockwise=%i more=%i\n", \ - (unsigned)block1.offset, pkt->payload_len, blockwise, block1.more); + printf("_flashwrite_handler(): received data: offset=%" PRIuSIZE + " len=%u blockwise=%i more=%i\n", + block1.offset, pkt->payload_len, blockwise, block1.more); uint8_t *payload_start = pkt->payload; size_t payload_len = pkt->payload_len; @@ -53,7 +54,8 @@ ssize_t _flashwrite_handler(coap_pkt_t* pkt, uint8_t *buf, size_t len, coap_requ riotboot_flashwrite_putbytes(writer, payload_start, payload_len, block1.more); } else { - printf("_flashwrite_handler(): skipping invalid offset (data=%u, writer=%u)\n", (unsigned)offset, (unsigned)writer->offset); + printf("_flashwrite_handler(): skipping invalid offset (data=%" PRIuSIZE + ", writer=%" PRIuSIZE ")\n", offset, writer->offset); } if (block1.more == 1) { diff --git a/tests/sys/bloom_bytes/main.c b/tests/sys/bloom_bytes/main.c index e476047344..cffc6c8850 100644 --- a/tests/sys/bloom_bytes/main.c +++ b/tests/sys/bloom_bytes/main.c @@ -62,8 +62,7 @@ int main(void) bloom_init(&bloom, BLOOM_BITS, bf, hashes, BLOOM_HASHF); printf("Testing Bloom filter.\n\n"); - printf("m: %" PRIu32 " k: %" PRIu32 "\n\n", (uint32_t) bloom.m, - (uint32_t) bloom.k); + printf("m: %" PRIuSIZE " k: %" PRIuSIZE "\n\n", bloom.m, bloom.k); random_init(myseed); diff --git a/tests/sys/malloc/main.c b/tests/sys/malloc/main.c index 0195efbb57..c2dcee6143 100644 --- a/tests/sys/malloc/main.c +++ b/tests/sys/malloc/main.c @@ -24,6 +24,7 @@ #include #include +#include "architecture.h" #include "test_utils/expect.h" #ifndef CHUNK_SIZE @@ -128,7 +129,7 @@ static void check_calloc_returns_null_on_overflow(void) * allocation succeeded. It then optimized out the test `NULL == p` and * assumes it to always be false. We just print the address to prevent * that from happening */ - printf("calloc(%zu, %zu) = %p\n", nmemb, size, p); + printf("calloc(%" PRIuSIZE ", %" PRIuSIZE ") = %p\n", nmemb, size, p); expect(NULL == p); #pragma GCC diagnostic pop } diff --git a/tests/sys/memarray/main.c b/tests/sys/memarray/main.c index 7d5762ecd7..4bc1b39287 100644 --- a/tests/sys/memarray/main.c +++ b/tests/sys/memarray/main.c @@ -23,6 +23,7 @@ #include #include +#include "architecture.h" #include "memarray.h" #include "ps.h" @@ -67,8 +68,8 @@ void fill_memory(struct block_t *head) head->message[MESSAGE_SIZE - 1] = 0; head->number = aux; - printf("\t(%i, %s) Allocated %u Bytes at %p, total %d\n", - head->number, head->message, (unsigned)sizeof(struct block_t), + printf("\t(%i, %s) Allocated %" PRIuSIZE " Bytes at %p, total %d\n", + head->number, head->message, sizeof(struct block_t), (void *)head, total); /* NOTE: If there is not space, memarray_alloc returns zero */ @@ -86,8 +87,8 @@ void free_memory(struct block_t *head) while (head) { total -= sizeof(struct block_t); - printf("\tFree (%i) %u Bytes at %p, total %d\n", \ - head->number, (unsigned)sizeof(struct block_t), + printf("\tFree (%i) %" PRIuSIZE " Bytes at %p, total %d\n", \ + head->number, sizeof(struct block_t), (void *)head, total); if (head->next) { @@ -142,45 +143,45 @@ int main(void) puts("Extend and reduce tests"); - printf("Memarray available: %u\n", - (unsigned)memarray_available(&block_storage)); + printf("Memarray available: %" PRIuSIZE "\n", + memarray_available(&block_storage)); /* Extend with second block */ memarray_extend(&block_storage, block_storage_data_extend, MAX_NUMBER_BLOCKS); - printf("Memarray available: %u\n", - (unsigned)memarray_available(&block_storage)); + printf("Memarray available: %" PRIuSIZE "\n", + memarray_available(&block_storage)); /* remove the original block */ int res = memarray_reduce(&block_storage, block_storage_data, MAX_NUMBER_BLOCKS); - printf("Memarray reduction: %d available: %u\n", - res, (unsigned)memarray_available(&block_storage)); + printf("Memarray reduction: %d available: %" PRIuSIZE "\n", + res, memarray_available(&block_storage)); /* try to remove original block a second time */ res = memarray_reduce(&block_storage, block_storage_data, MAX_NUMBER_BLOCKS); - printf("Memarray reduction: %d available: %u\n", - res, (unsigned)memarray_available(&block_storage)); + printf("Memarray reduction: %d available: %" PRIuSIZE "\n", + res, memarray_available(&block_storage)); /* remove the extension block */ res = memarray_reduce(&block_storage, block_storage_data_extend, MAX_NUMBER_BLOCKS); - printf("Memarray reduction: %d available: %u\n", - res, (unsigned)memarray_available(&block_storage)); + printf("Memarray reduction: %d available: %" PRIuSIZE "\n", + res, memarray_available(&block_storage)); /* extend again with the original block */ memarray_extend(&block_storage, block_storage_data, MAX_NUMBER_BLOCKS); /* remove one element */ memarray_alloc(&block_storage); - printf("Memarray available: %u\n", - (unsigned)memarray_available(&block_storage)); + printf("Memarray available: %" PRIuSIZE "\n", + memarray_available(&block_storage)); /* try to reduce with a missing element */ res = memarray_reduce(&block_storage, block_storage_data, MAX_NUMBER_BLOCKS); - printf("Memarray reduction: %d available: %u\n", - res, (unsigned)memarray_available(&block_storage)); + printf("Memarray reduction: %d available: %" PRIuSIZE "\n", + res, memarray_available(&block_storage)); printf("Finishing\n"); ps(); diff --git a/tests/sys/pthread/main.c b/tests/sys/pthread/main.c index e4170f55f5..3487e1ab55 100644 --- a/tests/sys/pthread/main.c +++ b/tests/sys/pthread/main.c @@ -30,7 +30,7 @@ void *run(void *parameter) { size_t n = (size_t) parameter; size_t factorial = 1; - printf("pthread: parameter = %u\n", (unsigned int) n); + printf("pthread: parameter = %" PRIuSIZE "\n", n); if (n > 0) { for (size_t i = 1; i <= n; i++) { @@ -38,7 +38,7 @@ void *run(void *parameter) { } } - printf("pthread: factorial = %u\n", (unsigned int) factorial); + printf("pthread: factorial = %" PRIuSIZE "\n",factorial); pthread_exit((void *)factorial); return NULL; diff --git a/tests/sys/shell/main.c b/tests/sys/shell/main.c index f39189a71a..bb665b0625 100644 --- a/tests/sys/shell/main.c +++ b/tests/sys/shell/main.c @@ -21,6 +21,7 @@ #include #include +#include "architecture.h" #include "shell.h" #if MODULE_STDIO_RTT @@ -87,7 +88,7 @@ static int print_shell_bufsize(int argc, char **argv) { (void)argc; (void)argv; - printf("%d\n", sizeof(line_buf)); + printf("%" PRIuSIZE "\n", sizeof(line_buf)); return 0; } diff --git a/tests/sys/usbus/main.c b/tests/sys/usbus/main.c index 3ca6bf32dc..9bbacd482c 100644 --- a/tests/sys/usbus/main.c +++ b/tests/sys/usbus/main.c @@ -255,7 +255,7 @@ static void _handle_data(usbdev_mock_t *dev, usbdev_mock_ep_t *ep, size_t len) { if (ep->ep.dir == USB_EP_DIR_IN) { /* Zero length IN packet is not valid here */ - DEBUG("[data]: Handling IN data from stack: %u\n", (unsigned)len); + DEBUG("[data]: Handling IN data from stack: %" PRIuSIZE "\n", len); TEST_ASSERT(len != 0); dev->usbdev.epcb(&dev->in[0].ep, USBDEV_EVENT_ESR); if (ep->available == dev->req_len) { @@ -263,9 +263,8 @@ static void _handle_data(usbdev_mock_t *dev, usbdev_mock_ep_t *ep, size_t len) req_phase = TEST_REQ_PHASE_OUTACK; } else { - DEBUG("[data]: Expecting more data from stack: %u/%u\n", - (unsigned)ep->available, - (unsigned)dev->req_len); + DEBUG("[data]: Expecting more data from stack: %" PRIuSIZE "/%" PRIuSIZE "\n", + ep->available, dev->req_len); } } } diff --git a/tests/unittests/tests-fib/tests-fib.c b/tests/unittests/tests-fib/tests-fib.c index 5a3bfde902..113da1e8c7 100644 --- a/tests/unittests/tests-fib/tests-fib.c +++ b/tests/unittests/tests-fib/tests-fib.c @@ -40,8 +40,8 @@ static void _fill_FIB_unique(size_t entries) for (size_t i = 0; i < entries; ++i) { /* construct "addresses" for the FIB */ - snprintf(addr_dst, add_buf_size, "Test address %02d", (int)i); - snprintf(addr_nxt, add_buf_size, "Test address %02d", (int)(entries + i)); + snprintf(addr_dst, add_buf_size, "Test address %02" PRIuSIZE, i); + snprintf(addr_nxt, add_buf_size, "Test address %02" PRIuSIZE, entries + i); /* the terminating \0 is unnecessary here */ fib_add_entry(&test_fib_table, 42, (uint8_t *)addr_dst, add_buf_size - 1, addr_dst_flags, @@ -64,8 +64,8 @@ static void _fill_FIB_multiple(size_t entries, size_t modulus) for (size_t i = 0; i < entries; ++i) { /* construct "addresses" for the FIB */ - snprintf(addr_dst, add_buf_size, "Test address %02d", (int)i); - snprintf(addr_nxt, add_buf_size, "Test address %02d", (int)(i % modulus)); + snprintf(addr_dst, add_buf_size, "Test address %02" PRIuSIZE, i); + snprintf(addr_nxt, add_buf_size, "Test address %02" PRIuSIZE, i % modulus); fib_add_entry(&test_fib_table, 42, (uint8_t *)addr_dst, add_buf_size - 1, addr_dst_flags, (uint8_t *)addr_nxt, add_buf_size - 1, addr_nxt_flags, @@ -151,7 +151,7 @@ static void test_fib_03_removing_all_entries(void) for (size_t i = 0; i < entries; ++i) { /* construct "addresses" to remove */ - snprintf(addr_dst, add_buf_size, "Test address %02d", (int)i); + snprintf(addr_dst, add_buf_size, "Test address %02" PRIuSIZE, i); fib_remove_entry(&test_fib_table, (uint8_t *)addr_dst, add_buf_size - 1); } @@ -185,7 +185,7 @@ static void test_fib_04_remove_lower_half(void) for (size_t i = 0; i < entries / 2; ++i) { /* construct "addresses" to remove */ - snprintf(addr_dst, add_buf_size, "Test address %02d", (int)i); + snprintf(addr_dst, add_buf_size, "Test address %02" PRIuSIZE, i); fib_remove_entry(&test_fib_table, (uint8_t *)addr_dst, add_buf_size - 1); } @@ -217,7 +217,7 @@ static void test_fib_05_remove_upper_half(void) for (size_t i = 0; i < entries / 2; ++i) { /* construct "addresses" to remove */ - snprintf(addr_dst, add_buf_size, "Test address %02d", (int)((entries / 2) + i)); + snprintf(addr_dst, add_buf_size, "Test address %02" PRIuSIZE, (entries / 2) + i); fib_remove_entry(&test_fib_table, (uint8_t *)addr_dst, add_buf_size - 1); } @@ -715,8 +715,8 @@ static void test_fib_17_get_entry_set(void) /* fill 20 addresses */ for (size_t i = 0; i < 20; ++i) { /* construct "addresses" for the FIB */ - snprintf(addr_dst, addr_buf_size, "Test address %02d", (int)i); - snprintf(addr_nxt, addr_buf_size, "Test address %02d", (int)(i % 11)); + snprintf(addr_dst, addr_buf_size, "Test address %02" PRIuSIZE, i); + snprintf(addr_nxt, addr_buf_size, "Test address %02" PRIuSIZE, i % 11); fib_add_entry(&test_fib_table, 42, (uint8_t *)addr_dst, addr_buf_size - 1, 0x0, (uint8_t *)addr_nxt, addr_buf_size - 1, 0x0, 100000); diff --git a/tests/unittests/tests-fib_sr/tests-fib_sr.c b/tests/unittests/tests-fib_sr/tests-fib_sr.c index 3aa31849c5..2af5243175 100644 --- a/tests/unittests/tests-fib_sr/tests-fib_sr.c +++ b/tests/unittests/tests-fib_sr/tests-fib_sr.c @@ -67,7 +67,7 @@ static int _create_sr(const char *pre, size_t from, size_t to, fib_sr_t *sr, siz for (size_t i = from; i < to; ++i) { int res; - snprintf(&(addr_nxt[strlen(pre)]), buf_size, "%d", (int)i); + snprintf(&(addr_nxt[strlen(pre)]), buf_size, "%" PRIuSIZE, i); /* append a hop */ res = fib_sr_entry_append(&test_fib_sr_table, sr, (uint8_t *)&addr_nxt, buf_size); if (res != 0) { diff --git a/tests/unittests/tests-uri_parser/tests-uri_parser.c b/tests/unittests/tests-uri_parser/tests-uri_parser.c index f863b985d2..5614dc44cb 100644 --- a/tests/unittests/tests-uri_parser/tests-uri_parser.c +++ b/tests/unittests/tests-uri_parser/tests-uri_parser.c @@ -14,6 +14,7 @@ #include #include +#include "architecture.h" #include "container.h" #include "embUnit.h" @@ -57,7 +58,7 @@ static int _compare_string_buffer(const char *name, const char *input_uri, const return 0; } printf( - "\nWith given input uri '%s', expected %s '%s' with length '%d' but got '%.*s' with length '%d'\n", + "\nWith given input uri '%s', expected %s '%s' with length '%" PRIuSIZE "' but got '%.*s' with length '%d'\n", input_uri, name, expected_str, strlen(expected_str), actual_len, actual_str, actual_len); return -1; } @@ -317,7 +318,7 @@ static void _result_component_scheme_matches_input_scheme(void) * but the uri_parser provides the length separately*/ if (uri_res.scheme_len != strlen(test_vec[i]->scheme)) { printf( - "With given input uri '%s', expected a scheme with the length '%d' but got '%d'\n", + "With given input uri '%s', expected a scheme with the length '%" PRIuSIZE "' but got '%d'\n", test_vec[i]->input_uri, strlen(test_vec[i]->scheme), uri_res.scheme_len); TEST_FAIL(failure_msg); }