From 41ad752a95926477127add328150f5657d95307b Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Fri, 3 Jul 2026 11:33:35 +0200 Subject: [PATCH] fix coverity #290250 --- client/deps/mqtt/posix_sockets.h | 5 ++++- client/src/uart/uart_posix.c | 3 +-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/client/deps/mqtt/posix_sockets.h b/client/deps/mqtt/posix_sockets.h index 42954f640..a3a53d1b6 100644 --- a/client/deps/mqtt/posix_sockets.h +++ b/client/deps/mqtt/posix_sockets.h @@ -58,7 +58,10 @@ int open_nb_socket(const char *addr, const char *port) { // make non-blocking if (sockfd != -1) { - fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL) | O_NONBLOCK); + if(fcntl(sockfd, F_SETFL, fcntl(sockfd, F_GETFL) | O_NONBLOCK) < 0) { + PrintAndLogEx(ERR, "fcntl failed in open_nb_socket"); + return -1; + } } return sockfd; diff --git a/client/src/uart/uart_posix.c b/client/src/uart/uart_posix.c index 7e569a97a..05c0952b5 100644 --- a/client/src/uart/uart_posix.c +++ b/client/src/uart/uart_posix.c @@ -462,8 +462,7 @@ void uart_close(const serial_port sp) { fl.l_pid = getpid(); // Does the system allows us to place a lock on this file descriptor - int err = fcntl(spu->fd, F_SETLK, &fl); - if (err == -1) { + if (fcntl(spu->fd, F_SETLK, &fl) < 0) { //silent error message as it can be called from uart_open failing modes, e.g. when waiting for port to appear //PrintAndLogEx(ERR, "UART error while closing port"); }