mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
examples: Use size_t print format specifier
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@posteo.net>
This commit is contained in:
parent
1182de16fd
commit
314dbf15b9
@ -114,7 +114,7 @@ static int dtls_handle_read(dtls_context_t *ctx)
|
|||||||
|
|
||||||
if (res <= 0) {
|
if (res <= 0) {
|
||||||
if ((ENABLE_DEBUG) && (res != -EAGAIN) && (res != -ETIMEDOUT)) {
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ static int dtls_handle_read(dtls_context_t *ctx)
|
|||||||
|
|
||||||
if (res <= 0) {
|
if (res <= 0) {
|
||||||
if ((ENABLE_DEBUG) && (res != -EAGAIN) && (res != -ETIMEDOUT)) {
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -154,7 +154,7 @@ static int client_send(char *addr_str, char *data, size_t datalen)
|
|||||||
res = credman_add(&credential0);
|
res = credman_add(&credential0);
|
||||||
if (res < 0 && res != CREDMAN_EXIST) {
|
if (res < 0 && res != CREDMAN_EXIST) {
|
||||||
/* ignore duplicate credentials */
|
/* 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,13 +170,13 @@ static int client_send(char *addr_str, char *data, size_t datalen)
|
|||||||
res = credman_add(&credential1);
|
res = credman_add(&credential1);
|
||||||
if (res < 0 && res != CREDMAN_EXIST) {
|
if (res < 0 && res != CREDMAN_EXIST) {
|
||||||
/* ignore duplicate credentials */
|
/* 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;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make the new credential available to the sock */
|
/* make the new credential available to the sock */
|
||||||
if (sock_dtls_add_credential(&dtls_sock, SOCK_DTLS_CLIENT_TAG_1) < 0) {
|
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;
|
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),
|
res = sock_dtls_recv(&dtls_sock, &session, buf, sizeof(buf),
|
||||||
SOCK_NO_TIMEOUT);
|
SOCK_NO_TIMEOUT);
|
||||||
if (res != -SOCK_DTLS_HANDSHAKE) {
|
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_dtls_close(&dtls_sock);
|
||||||
sock_udp_close(&udp_sock);
|
sock_udp_close(&udp_sock);
|
||||||
return -1;
|
return -1;
|
||||||
@ -208,7 +208,7 @@ static int client_send(char *addr_str, char *data, size_t datalen)
|
|||||||
uint8_t rcv[512];
|
uint8_t rcv[512];
|
||||||
if ((res = sock_dtls_recv(&dtls_sock, &session, rcv, sizeof(rcv),
|
if ((res = sock_dtls_recv(&dtls_sock, &session, rcv, sizeof(rcv),
|
||||||
SOCK_NO_TIMEOUT)) >= 0) {
|
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);
|
(char *)rcv);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,7 +139,7 @@ void *dtls_server_wrapper(void *arg)
|
|||||||
res = credman_add(&credential0);
|
res = credman_add(&credential0);
|
||||||
if (res < 0 && res != CREDMAN_EXIST) {
|
if (res < 0 && res != CREDMAN_EXIST) {
|
||||||
/* ignore duplicate credentials */
|
/* 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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,13 +163,13 @@ void *dtls_server_wrapper(void *arg)
|
|||||||
res = credman_add(&credential1);
|
res = credman_add(&credential1);
|
||||||
if (res < 0 && res != CREDMAN_EXIST) {
|
if (res < 0 && res != CREDMAN_EXIST) {
|
||||||
/* ignore duplicate credentials */
|
/* 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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* make the new credential available to the sock */
|
/* make the new credential available to the sock */
|
||||||
if (sock_dtls_add_credential(&sock, SOCK_DTLS_SERVER_TAG_1) < 0) {
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,10 +187,10 @@ void *dtls_server_wrapper(void *arg)
|
|||||||
res = sock_dtls_recv(&sock, &session, rcv, sizeof(rcv),
|
res = sock_dtls_recv(&sock, &session, rcv, sizeof(rcv),
|
||||||
10 * US_PER_SEC);
|
10 * US_PER_SEC);
|
||||||
if (res >= 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, rcv, (size_t)res, 0);
|
res = sock_dtls_send(&sock, &session, rcv, (size_t)res, 0);
|
||||||
if (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);
|
sock_dtls_session_destroy(&sock, &session);
|
||||||
}
|
}
|
||||||
|
@ -159,8 +159,8 @@ static int cmd_pub(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Published %i bytes to topic '%s [%i]'\n",
|
printf("Published %" PRIuSIZE " bytes to topic '%s [%i]'\n",
|
||||||
(int)strlen(argv[2]), t.name, t.id);
|
strlen(argv[2]), t.name, t.id);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -368,8 +368,8 @@ int gcoap_cli_cmd(int argc, char **argv)
|
|||||||
len = coap_opt_finish(&pdu, COAP_OPT_FINISH_NONE);
|
len = coap_opt_finish(&pdu, COAP_OPT_FINISH_NONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("gcoap_cli: sending msg ID %u, %u bytes\n", coap_get_id(&pdu),
|
printf("gcoap_cli: sending msg ID %u, %" PRIuSIZE " bytes\n",
|
||||||
(unsigned) len);
|
coap_get_id(&pdu), len);
|
||||||
if (!_send(&buf[0], len, argv[apos])) {
|
if (!_send(&buf[0], len, argv[apos])) {
|
||||||
puts("gcoap_cli: msg send failed");
|
puts("gcoap_cli: msg send failed");
|
||||||
}
|
}
|
||||||
|
@ -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);
|
int blockwise = coap_get_block1(pdu, &block1);
|
||||||
|
|
||||||
printf("_sha256_handler: received data: offset=%u len=%u blockwise=%i more=%i\n",
|
printf("_sha256_handler: received data: offset=%" PRIuSIZE " len=%u blockwise=%i more=%i\n",
|
||||||
(unsigned)block1.offset, pdu->payload_len, blockwise, block1.more);
|
block1.offset, pdu->payload_len, blockwise, block1.more);
|
||||||
|
|
||||||
/* initialize sha256 calculation and add payload bytes */
|
/* initialize sha256 calculation and add payload bytes */
|
||||||
if (block1.blknum == 0) {
|
if (block1.blknum == 0) {
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "architecture.h"
|
||||||
#include "lua_run.h"
|
#include "lua_run.h"
|
||||||
#include "lua_builtin.h"
|
#include "lua_builtin.h"
|
||||||
#include "blob/repl.lua.h"
|
#include "blob/repl.lua.h"
|
||||||
@ -44,7 +45,7 @@ const size_t lua_riot_builtin_lua_table_len = 1;
|
|||||||
|
|
||||||
int main(void)
|
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 *));
|
(void *)lua_memory, (void *)(lua_memory + MAIN_LUA_MEM_SIZE), sizeof(void *));
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
|
@ -128,8 +128,8 @@ ssize_t _sha256_handler(coap_pkt_t* pkt, uint8_t *buf, size_t len, coap_request_
|
|||||||
coap_block1_t block1;
|
coap_block1_t block1;
|
||||||
int blockwise = coap_get_block1(pkt, &block1);
|
int blockwise = coap_get_block1(pkt, &block1);
|
||||||
|
|
||||||
printf("_sha256_handler(): received data: offset=%u len=%u blockwise=%i more=%i\n", \
|
printf("_sha256_handler(): received data: offset=%" PRIuSIZE " len=%u blockwise=%i more=%i\n",
|
||||||
(unsigned)block1.offset, pkt->payload_len, blockwise, block1.more);
|
block1.offset, pkt->payload_len, blockwise, block1.more);
|
||||||
|
|
||||||
if (block1.offset == 0) {
|
if (block1.offset == 0) {
|
||||||
puts("_sha256_handler(): init");
|
puts("_sha256_handler(): init");
|
||||||
|
@ -136,7 +136,7 @@ static int udp_send(char *addr_str, char *port_str, char *data, unsigned int num
|
|||||||
puts("could not send");
|
puts("could not send");
|
||||||
}
|
}
|
||||||
else {
|
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);
|
usleep(delay);
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
* @author DangNhat Pham-Huu <51002279@hcmut.edu.vn>
|
* @author DangNhat Pham-Huu <51002279@hcmut.edu.vn>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "architecture.h"
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
|
||||||
#include "c_functions.h"
|
#include "c_functions.h"
|
||||||
@ -64,7 +65,7 @@ int main()
|
|||||||
vInts.push_back(1);
|
vInts.push_back(1);
|
||||||
vInts.push_back(3);
|
vInts.push_back(3);
|
||||||
vInts.push_back(2);
|
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("\n-= Test iterator =-\n");
|
||||||
printf("The content of vInts = { ");
|
printf("The content of vInts = { ");
|
||||||
|
Loading…
Reference in New Issue
Block a user