[PATCH] libosmo-netif[master]: cosmetic: relax UDP length check

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Max gerrit-no-reply at lists.osmocom.org
Fri Oct 13 16:25:37 UTC 2017


Review at  https://gerrit.osmocom.org/4258

cosmetic: relax UDP length check

Previously recv() returning 0 for UDP socket was considered as error
although it's legitimate return value for empty UDP packets. Relax the
error check to avoid confusing error messages.

The function behavior is the same:
* msg is not altered while receiving 0-length UDP packet
* return value is 0

The only result of the relaxed error check is the absense of error log
message for 0-length UDP packet.

Change-Id: I32e5fcbf5ed92cc923660ac59e6a37fd3f0703a7
Fixes: OS#2219
---
M src/datagram.c
1 file changed, 2 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/58/4258/1

diff --git a/src/datagram.c b/src/datagram.c
index c2c84e0..10204e2 100644
--- a/src/datagram.c
+++ b/src/datagram.c
@@ -236,14 +236,14 @@
 /*! \brief Receive data via Osmocom datagram receiver
  *  \param[in] conn Datagram Receiver from which to receive
  *  \param msg pre-allocate message buffer to which received data is appended
- *  \returns number of bytes read, negative on error. */
+ *  \returns number of bytes read (might be 0 for empty UDP packet), negative on error. */
 int osmo_dgram_rx_recv(struct osmo_dgram_rx *conn,
 				struct msgb *msg)
 {
 	int ret;
 
 	ret = recv(conn->ofd.fd, msg->data, msg->data_len, 0);
-	if (ret <= 0) {
+	if (ret < 0) {
 		LOGP(DLINP, LOGL_ERROR, "error receiving data from tx\n");
 		return ret;
 	}

-- 
To view, visit https://gerrit.osmocom.org/4258
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I32e5fcbf5ed92cc923660ac59e6a37fd3f0703a7
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>



More information about the gerrit-log mailing list