diff --git a/examples/dtls-echo/dtls-client.c b/examples/dtls-echo/dtls-client.c index c1563252cb..fd4e4b60ff 100644 --- a/examples/dtls-echo/dtls-client.c +++ b/examples/dtls-echo/dtls-client.c @@ -114,7 +114,7 @@ static int dtls_handle_read(dtls_context_t *ctx) if (res <= 0) { if ((ENABLE_DEBUG) && (res != -EAGAIN) && (res != -ETIMEDOUT)) { - DEBUG("sock_udp_recv unexpected code error: %i\n", (int)res); + DEBUG("sock_udp_recv unexpected code error: %" PRIiSIZE "\n", res); } return 0; } diff --git a/examples/dtls-echo/dtls-server.c b/examples/dtls-echo/dtls-server.c index 4abdf833cf..18f5f206d4 100644 --- a/examples/dtls-echo/dtls-server.c +++ b/examples/dtls-echo/dtls-server.c @@ -106,7 +106,7 @@ static int dtls_handle_read(dtls_context_t *ctx) if (res <= 0) { if ((ENABLE_DEBUG) && (res != -EAGAIN) && (res != -ETIMEDOUT)) { - DEBUG("sock_udp_recv unexpected code error: %i\n", (int)res); + DEBUG("sock_udp_recv unexpected code error: %" PRIiSIZE "\n", res); } return 0; } diff --git a/examples/dtls-sock/dtls-client.c b/examples/dtls-sock/dtls-client.c index 71560c22b4..4a913cee95 100644 --- a/examples/dtls-sock/dtls-client.c +++ b/examples/dtls-sock/dtls-client.c @@ -154,7 +154,7 @@ static int client_send(char *addr_str, char *data, size_t datalen) res = credman_add(&credential0); 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; } @@ -170,13 +170,13 @@ static int client_send(char *addr_str, char *data, size_t datalen) res = credman_add(&credential1); 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; } /* make the new credential available to the sock */ if (sock_dtls_add_credential(&dtls_sock, SOCK_DTLS_CLIENT_TAG_1) < 0) { - printf("Error cannot add credential to the sock: %d\n", (int)res); + printf("Error cannot add credential to the sock: %" PRIdSIZE "\n", res); return -1; } @@ -192,7 +192,7 @@ static int client_send(char *addr_str, char *data, size_t datalen) res = sock_dtls_recv(&dtls_sock, &session, buf, sizeof(buf), SOCK_NO_TIMEOUT); if (res != -SOCK_DTLS_HANDSHAKE) { - printf("Error creating session: %d\n", (int)res); + printf("Error creating session: %" PRIdSIZE "\n", res); sock_dtls_close(&dtls_sock); sock_udp_close(&udp_sock); return -1; @@ -208,7 +208,7 @@ static int client_send(char *addr_str, char *data, size_t datalen) uint8_t rcv[512]; if ((res = sock_dtls_recv(&dtls_sock, &session, rcv, sizeof(rcv), SOCK_NO_TIMEOUT)) >= 0) { - printf("Received %d bytes: \"%.*s\"\n", (int)res, (int)res, + printf("Received %" PRIdSIZE " bytes: \"%.*s\"\n", res, (int)res, (char *)rcv); } } diff --git a/examples/dtls-sock/dtls-server.c b/examples/dtls-sock/dtls-server.c index 5288388147..c31845ceb5 100644 --- a/examples/dtls-sock/dtls-server.c +++ b/examples/dtls-sock/dtls-server.c @@ -139,7 +139,7 @@ void *dtls_server_wrapper(void *arg) res = credman_add(&credential0); 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 NULL; } @@ -163,13 +163,13 @@ void *dtls_server_wrapper(void *arg) res = credman_add(&credential1); 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 NULL; } /* make the new credential available to the sock */ if (sock_dtls_add_credential(&sock, SOCK_DTLS_SERVER_TAG_1) < 0) { - printf("Error cannot add credential to the sock: %d\n", (int)res); + printf("Error cannot add credential to the sock: %" PRIdSIZE "\n", res); return NULL; } @@ -187,10 +187,10 @@ void *dtls_server_wrapper(void *arg) res = sock_dtls_recv(&sock, &session, rcv, sizeof(rcv), 10 * US_PER_SEC); if (res >= 0) { - printf("Received %d bytes -- (echo)\n", (int)res); + printf("Received %" PRIdSIZE " bytes -- (echo)\n", res); res = sock_dtls_send(&sock, &session, rcv, (size_t)res, 0); if (res < 0) { - printf("Error resending DTLS message: %d", (int)res); + printf("Error resending DTLS message: %" PRIdSIZE, res); } sock_dtls_session_destroy(&sock, &session); } diff --git a/examples/emcute_mqttsn/main.c b/examples/emcute_mqttsn/main.c index 34c175498d..0530b88d4e 100644 --- a/examples/emcute_mqttsn/main.c +++ b/examples/emcute_mqttsn/main.c @@ -159,8 +159,8 @@ static int cmd_pub(int argc, char **argv) return 1; } - printf("Published %i bytes to topic '%s [%i]'\n", - (int)strlen(argv[2]), t.name, t.id); + printf("Published %" PRIuSIZE " bytes to topic '%s [%i]'\n", + strlen(argv[2]), t.name, t.id); return 0; } diff --git a/examples/gcoap/client.c b/examples/gcoap/client.c index ee9416bec4..491a905ef8 100644 --- a/examples/gcoap/client.c +++ b/examples/gcoap/client.c @@ -368,8 +368,8 @@ int gcoap_cli_cmd(int argc, char **argv) len = coap_opt_finish(&pdu, COAP_OPT_FINISH_NONE); } - printf("gcoap_cli: sending msg ID %u, %u bytes\n", coap_get_id(&pdu), - (unsigned) len); + printf("gcoap_cli: sending msg ID %u, %" PRIuSIZE " bytes\n", + coap_get_id(&pdu), len); if (!_send(&buf[0], len, argv[apos])) { puts("gcoap_cli: msg send failed"); } diff --git a/examples/gcoap_block_server/gcoap_block.c b/examples/gcoap_block_server/gcoap_block.c index bbad52e3c2..5aece7bde6 100644 --- a/examples/gcoap_block_server/gcoap_block.c +++ b/examples/gcoap_block_server/gcoap_block.c @@ -93,8 +93,8 @@ static ssize_t _sha256_handler(coap_pkt_t* pdu, uint8_t *buf, size_t len, coap_r int blockwise = coap_get_block1(pdu, &block1); - printf("_sha256_handler: received data: offset=%u len=%u blockwise=%i more=%i\n", - (unsigned)block1.offset, pdu->payload_len, blockwise, block1.more); + printf("_sha256_handler: received data: offset=%" PRIuSIZE " len=%u blockwise=%i more=%i\n", + block1.offset, pdu->payload_len, blockwise, block1.more); /* initialize sha256 calculation and add payload bytes */ if (block1.blknum == 0) { diff --git a/examples/lua_REPL/main.c b/examples/lua_REPL/main.c index 1632cf2d99..361d726300 100644 --- a/examples/lua_REPL/main.c +++ b/examples/lua_REPL/main.c @@ -21,6 +21,7 @@ #include #include +#include "architecture.h" #include "lua_run.h" #include "lua_builtin.h" #include "blob/repl.lua.h" @@ -44,7 +45,7 @@ const size_t lua_riot_builtin_lua_table_len = 1; int main(void) { - printf("Using memory range for Lua heap: %p - %p, %zu bytes\n", + printf("Using memory range for Lua heap: %p - %p, %" PRIuSIZE " bytes\n", (void *)lua_memory, (void *)(lua_memory + MAIN_LUA_MEM_SIZE), sizeof(void *)); while (1) { diff --git a/examples/nanocoap_server/coap_handler.c b/examples/nanocoap_server/coap_handler.c index 6bffe8b224..2e00e256c9 100644 --- a/examples/nanocoap_server/coap_handler.c +++ b/examples/nanocoap_server/coap_handler.c @@ -128,8 +128,8 @@ ssize_t _sha256_handler(coap_pkt_t* pkt, uint8_t *buf, size_t len, coap_request_ coap_block1_t block1; int blockwise = coap_get_block1(pkt, &block1); - printf("_sha256_handler(): received data: offset=%u len=%u blockwise=%i more=%i\n", \ - (unsigned)block1.offset, pkt->payload_len, blockwise, block1.more); + printf("_sha256_handler(): received data: offset=%" PRIuSIZE " len=%u blockwise=%i more=%i\n", + block1.offset, pkt->payload_len, blockwise, block1.more); if (block1.offset == 0) { puts("_sha256_handler(): init"); diff --git a/examples/posix_sockets/udp.c b/examples/posix_sockets/udp.c index 72c5dff351..20f7b0d151 100644 --- a/examples/posix_sockets/udp.c +++ b/examples/posix_sockets/udp.c @@ -136,7 +136,7 @@ static int udp_send(char *addr_str, char *port_str, char *data, unsigned int num puts("could not send"); } else { - printf("Success: send %u byte to %s:%u\n", (unsigned)data_len, addr_str, port); + printf("Success: send %" PRIuSIZE " byte to %s:%u\n", data_len, addr_str, port); } usleep(delay); diff --git a/examples/riot_and_cpp/main.cpp b/examples/riot_and_cpp/main.cpp index ed4bb02cee..891ed71c8e 100644 --- a/examples/riot_and_cpp/main.cpp +++ b/examples/riot_and_cpp/main.cpp @@ -21,6 +21,7 @@ * @author DangNhat Pham-Huu <51002279@hcmut.edu.vn> */ +#include "architecture.h" #include "thread.h" #include "c_functions.h" @@ -64,7 +65,7 @@ int main() vInts.push_back(1); vInts.push_back(3); vInts.push_back(2); - printf("The vector vInts has been filled with %d numbers.\n", (int)vInts.size()); + printf("The vector vInts has been filled with %" PRIuSIZE " numbers.\n", vInts.size()); printf("\n-= Test iterator =-\n"); printf("The content of vInts = { ");