Fix warnings

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2026-05-13 15:56:40 +02:00
parent 4507bb68a6
commit 141d62da01
4 changed files with 20 additions and 10 deletions

View File

@@ -30,7 +30,8 @@ extern int gettimeofday(struct timeval *tp, struct timezone *tzp);
static inline uint32_t board_millis(void) {
struct timeval start;
gettimeofday(&start, NULL);
return start.tv_sec * 1000 + start.tv_usec / 1000;
uint64_t ms = (uint64_t)start.tv_sec * 1000ULL + (uint64_t)start.tv_usec / 1000ULL;
return (uint32_t)ms;
}
#endif // _BOARD_H_

View File

@@ -216,7 +216,11 @@ uint16_t driver_write_emul(uint8_t itf, const uint8_t *buffer, uint16_t buffer_s
uint16_t size = htons(buffer_size);
socket_t sock = get_sock_itf(itf);
// DEBUG_PAYLOAD(buffer,buffer_size);
#ifdef _WIN32
int ret = 0;
#else
ssize_t ret = 0;
#endif
do {
ret = send(sock, (const char *)&size, sizeof(size), 0);
if (ret == SOCKET_ERROR) {
@@ -295,7 +299,11 @@ uint16_t emul_read(uint8_t itf) {
__pragma(warning(pop))
#endif
struct timeval timeout;
#ifdef _WIN32
int valread = 0;
#else
ssize_t valread = 0;
#endif
timeout.tv_sec = 0;
timeout.tv_usec = 0 * 1000;
int n = select((int)(sock + 1), &input, NULL, NULL, &timeout);

View File

@@ -306,10 +306,11 @@ void rest_close_conn(rest_conn_t *conn) {
mbedtls_ssl_free(&conn->ssl);
}
if (conn->sock >= 0) {
socket_t fd = (socket_t)conn->sock;
#ifdef _MSC_VER
shutdown((SOCKET)conn->sock, 1);
shutdown((SOCKET)fd, 1);
#endif
(void)close(conn->sock);
(void)close(fd);
}
clear_conn(conn);
#else
@@ -445,7 +446,7 @@ static void send_response(rest_conn_t *conn, int status_code, const char *status
}
#ifdef ENABLE_EMULATION
while (sent_total < (size_t)header_len) {
int n = send((socket_t)conn->sock, headers_buf + sent_total, (int)((size_t)header_len - sent_total), 0);
ssize_t n = send((socket_t)conn->sock, headers_buf + sent_total, (int)((size_t)header_len - sent_total), 0);
if (n <= 0) {
rest_close_conn(conn);
return;
@@ -454,7 +455,7 @@ static void send_response(rest_conn_t *conn, int status_code, const char *status
}
sent_total = 0;
while (sent_total < body_len) {
int n = send((socket_t)conn->sock, body + sent_total, (int)(body_len - sent_total), 0);
ssize_t n = send((socket_t)conn->sock, body + sent_total, (int)(body_len - sent_total), 0);
if (n <= 0) {
rest_close_conn(conn);
return;
@@ -1285,7 +1286,7 @@ static void *rest_emulation_thread(void *arg) {
}
}
else {
int n = recv((socket_t)conn->sock, conn->request + conn->request_len, (int)(REST_MAX_REQUEST_SIZE - conn->request_len), 0);
ssize_t n = recv((socket_t)conn->sock, conn->request + conn->request_len, (int)(REST_MAX_REQUEST_SIZE - conn->request_len), 0);
if (n <= 0) {
rest_close_conn(conn);
break;

View File

@@ -190,9 +190,9 @@ int emulation_rest_tls_port(void) {
int tls_send_cb(void *ctx, const unsigned char *buf, size_t len) {
const socket_t fd = (socket_t)(*(const intptr_t *)ctx);
int r = send(fd, (const char *)buf, (int)len, 0);
ssize_t r = send(fd, (const char *)buf, (int)len, 0);
if (r >= 0) {
return r;
return (int)r;
}
#ifdef _MSC_VER
{
@@ -211,9 +211,9 @@ int tls_send_cb(void *ctx, const unsigned char *buf, size_t len) {
int tls_recv_cb(void *ctx, unsigned char *buf, size_t len) {
const socket_t fd = (socket_t)(*(const intptr_t *)ctx);
int r = recv(fd, (char *)buf, (int)len, 0);
ssize_t r = recv(fd, (char *)buf, (int)len, 0);
if (r > 0) {
return r;
return (int)r;
}
if (r == 0) {
return MBEDTLS_ERR_SSL_CONN_EOF;