Skip to contentSkip to conversation

alfred: txrx-warnings: random fixes

PATCH New Sven Eckelmann 1 participant 3 messages Jul 29

lore
Share & tools
lore
#0 lore raw

cover alfred: txrx-warnings: random fixes

Similar to the batctl fixes, I have now compiled a list of potential fixes for alfred. Instead of posting everything at once, I will be posted in smaller chunks. They are just various (mostly minor) problems which should be tackled at some point.

---
Sven Eckelmann (2):
alfred: don't treat empty datagrams as a socket read error
alfred: fix type of sendto() return

 recv.c | 2 +-
 send.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

---
base-commit: 462a0cf40615f62e0912c36d72a75accbb26f5ee
change-id: 20260729-bugfixes-txrx-warn-19b01d48b5e4

Best regards,

Signature · 1 line
Sven Eckelmann <[email protected]>
#1 lore raw

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

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")
---
 recv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
recv.c +1 -1
index 76bfb30..7d4e147 100644
@@ -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;
 	}
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/2 alfred: fix type of sendto() return

In reply to Sven Eckelmann

The function sendto is returning -1 on an error and not an errno code. But since -EPERM is -1, no functional change is expected.

---
 send.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
send.c +1 -1
index 8290c98..bd5b9a3 100644
@@ -189,7 +189,7 @@ ssize_t send_alfred_packet(struct globals *globals, struct interface *interface,
 		return 0;
 
 	ret = sendto(interface->netsock, buf, length, 0, dest_addr, slen);
-	if (ret == -EPERM) {
+	if (ret == -1) {
 		perror("Error during sent");
 		close(interface->netsock);
 		close(interface->netsock_mcast);
Signature · 1 line
2.47.3