From 50e07859e8c84fe7d08cd632693c2a4aad19b45a Mon Sep 17 00:00:00 2001 From: Niel Nielsen Date: Sun, 13 Sep 2026 16:25:09 +0200 Subject: [PATCH] Refactor error handling in select function Signed-off-by: Niel Nielsen --- client/src/uart/ble_posix.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/src/uart/ble_posix.c b/client/src/uart/ble_posix.c index 7d94dc86b..e1e38b1f2 100644 --- a/client/src/uart/ble_posix.c +++ b/client/src/uart/ble_posix.c @@ -17,7 +17,6 @@ #include #include -#include // strcasecmp #include #include #include @@ -293,9 +292,11 @@ int ble_resolve_name(const char *name, char *out_mac, size_t out_mac_sz, int tim FD_ZERO(&rs); FD_SET(dd, &rs); int s = select(dd + 1, &rs, NULL, NULL, &tv); - if (s < 0) { if (errno == EINTR) break; break; } // Ctrl-C or error -> give up cleanly - if (s == 0) break; // timeout - + if (s < 0) { + if (errno == EINTR) continue; // Interrupted by signal, try again + break; // Unrecoverable error, break loop + } + if (s == 0) break; // Timeout, handle gracefully int n = read(dd, buf, sizeof(buf)); if (n < (int)(1 + HCI_EVENT_HDR_SIZE + 1)) continue; uint8_t *pkt_end = buf + n;