Change in ...osmo-pcu[master]: osmobts_sock.cpp: pcu_sock_read(): use stack buffer, not heap

laforge gerrit-no-reply at lists.osmocom.org
Mon Aug 26 20:37:18 UTC 2019


laforge has submitted this change and it was merged. ( https://gerrit.osmocom.org/c/osmo-pcu/+/15279 )

Change subject: osmobts_sock.cpp: pcu_sock_read(): use stack buffer, not heap
......................................................................

osmobts_sock.cpp: pcu_sock_read(): use stack buffer, not heap

We don't really need to use the message buffer (on heap), because
it's never getting passed to pcu_rx(). Let's use a buffer on stack.

Change-Id: I4cb8ca80513df7b71e1438da2e82799be6be1fa0
---
M src/osmobts_sock.cpp
1 file changed, 3 insertions(+), 15 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  pespin: Looks good to me, but someone else must approve
  Jenkins Builder: Verified



diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp
index 9fcd99d..a3e9d63 100644
--- a/src/osmobts_sock.cpp
+++ b/src/osmobts_sock.cpp
@@ -139,17 +139,10 @@
 static int pcu_sock_read(struct osmo_fd *bfd)
 {
 	struct pcu_sock_state *state = (struct pcu_sock_state *)bfd->data;
-	struct gsm_pcu_if *pcu_prim;
-	struct msgb *msg;
+	struct gsm_pcu_if pcu_prim;
 	int rc;
 
-	msg = msgb_alloc(sizeof(*pcu_prim), "pcu_sock_rx");
-	if (!msg)
-		return -ENOMEM;
-
-	pcu_prim = (struct gsm_pcu_if *) msg->tail;
-
-	rc = recv(bfd->fd, msg->tail, msgb_tailroom(msg), 0);
+	rc = recv(bfd->fd, &pcu_prim, sizeof(pcu_prim), 0);
 	if (rc == 0)
 		goto close;
 
@@ -159,16 +152,11 @@
 		goto close;
 	}
 
-	rc = pcu_rx(pcu_prim->msg_type, pcu_prim);
-
-	/* as we always synchronously process the message in pcu_rx() and
-	 * its callbacks, we can free the message here. */
-	msgb_free(msg);
+	rc = pcu_rx(pcu_prim.msg_type, &pcu_prim);
 
 	return rc;
 
 close:
-	msgb_free(msg);
 	pcu_sock_close(state, 1);
 	return -1;
 }

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/15279
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I4cb8ca80513df7b71e1438da2e82799be6be1fa0
Gerrit-Change-Number: 15279
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190826/35ccd49f/attachment.html>


More information about the gerrit-log mailing list