[PATCH 1/2] alfred: don't treat empty datagrams as a socket read error

Sven Eckelmann <[email protected]> Wed, 29 Jul 2026 09:23:27 +0200
Newsgroups org.open-mesh.lists.batman
Message-ID <[email protected]>
recvfrom() on the UDP netsock returns 0 for a validly received zero-length
datagram, which is not an error condition. In this case, it is not
necessary to print "read from network socket failed". zero-length packets
will be handled later when checking for the minimal size of a packet.

Fixes: 23359bbf72aa ("alfred: initial commit")
Signed-off-by: Sven Eckelmann <[email protected]>
---
 recv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/recv.c b/recv.c
index 76bfb30..7d4e147 100644
--- a/recv.c
+++ b/recv.c
@@ -403,7 +403,7 @@ int recv_alfred_packet(struct globals *globals, struct interface *interface,
 
 	length = recvfrom(recv_sock, buf, sizeof(buf), 0,
 			  (struct sockaddr *)source, &sourcelen);
-	if (length <= 0) {
+	if (length < 0) {
 		perror("read from network socket failed");
 		return -1;
 	}

-- 
2.47.3