From 575ab684fe328e9d3c35fdb89cf221bf521fb93f Mon Sep 17 00:00:00 2001 From: MrKevinWeiss Date: Thu, 21 Mar 2024 10:07:05 +0100 Subject: [PATCH] sys/net/coap: cast in non-config define If we try to set the compile-time config we need to always remember casting, instead, just cast in the places that are not exposed to users --- sys/include/net/coap.h | 2 +- sys/net/application_layer/gcoap/gcoap.c | 2 +- sys/net/application_layer/nanocoap/sock.c | 4 ++-- tests/net/gcoap_fileserver/Makefile | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/include/net/coap.h b/sys/include/net/coap.h index 7e83216e7e..275510463d 100644 --- a/sys/include/net/coap.h +++ b/sys/include/net/coap.h @@ -563,7 +563,7 @@ typedef enum { * (@ref CONFIG_COAP_ACK_TIMEOUT_MS * @ref CONFIG_COAP_RANDOM_FACTOR_1000 / 1000). */ #ifndef CONFIG_COAP_ACK_TIMEOUT_MS -#define CONFIG_COAP_ACK_TIMEOUT_MS (2000UL) +#define CONFIG_COAP_ACK_TIMEOUT_MS (2000) #endif /** diff --git a/sys/net/application_layer/gcoap/gcoap.c b/sys/net/application_layer/gcoap/gcoap.c index dae1a3e7fd..adf8829b23 100644 --- a/sys/net/application_layer/gcoap/gcoap.c +++ b/sys/net/application_layer/gcoap/gcoap.c @@ -50,7 +50,7 @@ #define NO_IMMEDIATE_REPLY (-1) /* End of the range to pick a random timeout */ -#define TIMEOUT_RANGE_END (CONFIG_COAP_ACK_TIMEOUT_MS * CONFIG_COAP_RANDOM_FACTOR_1000 / 1000) +#define TIMEOUT_RANGE_END ((uint32_t)CONFIG_COAP_ACK_TIMEOUT_MS * CONFIG_COAP_RANDOM_FACTOR_1000 / 1000) /* Internal functions */ static void *_event_loop(void *arg); diff --git a/sys/net/application_layer/nanocoap/sock.c b/sys/net/application_layer/nanocoap/sock.c index 01747d3ccf..eb82c7bef1 100644 --- a/sys/net/application_layer/nanocoap/sock.c +++ b/sys/net/application_layer/nanocoap/sock.c @@ -189,8 +189,8 @@ ssize_t nanocoap_sock_request_cb(nanocoap_sock_t *sock, coap_pkt_t *pkt, uint8_t state = STATE_REQUEST_SEND; /* random timeout, deadline for receive retries */ - uint32_t timeout = random_uint32_range(CONFIG_COAP_ACK_TIMEOUT_MS * US_PER_MS, - CONFIG_COAP_ACK_TIMEOUT_MS * CONFIG_COAP_RANDOM_FACTOR_1000); + uint32_t timeout = random_uint32_range((uint32_t)CONFIG_COAP_ACK_TIMEOUT_MS * US_PER_MS, + (uint32_t)CONFIG_COAP_ACK_TIMEOUT_MS * CONFIG_COAP_RANDOM_FACTOR_1000); uint32_t deadline = _deadline_from_interval(timeout); /* check if we expect a reply */ diff --git a/tests/net/gcoap_fileserver/Makefile b/tests/net/gcoap_fileserver/Makefile index ebe7f785c3..d3d8027322 100644 --- a/tests/net/gcoap_fileserver/Makefile +++ b/tests/net/gcoap_fileserver/Makefile @@ -30,7 +30,7 @@ TEST_ON_CI_BLACKLIST += all # use small blocksize for test to increase chance for errors CFLAGS += -DCONFIG_NANOCOAP_BLOCKSIZE_DEFAULT=COAP_BLOCKSIZE_16 -CFLAGS += -DCONFIG_COAP_ACK_TIMEOUT_MS=100UL +CFLAGS += -DCONFIG_COAP_ACK_TIMEOUT_MS=100 CFLAGS += -DCONFIG_COAP_MAX_RETRANSMIT=10 ifneq (,$(filter native native64,$(BOARD)))