diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2019-08-23 17:38:43 +0200 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2019-08-23 18:03:37 +0200 |
commit | c7849c2dfe680d5157e847d3e9f6ebeaf41d50dc (patch) | |
tree | 3cf7f92032fec19160bee23b5f11caf831495c2f | |
parent | aef6bf43e5fc8931a17bd0b17ae184654c37f1fa (diff) |
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
-rw-r--r-- | src/osmobts_sock.cpp | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/src/osmobts_sock.cpp b/src/osmobts_sock.cpp index 9fcd99d3..a3e9d635 100644 --- a/src/osmobts_sock.cpp +++ b/src/osmobts_sock.cpp @@ -139,17 +139,10 @@ for the reset. */ 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 @@ static int pcu_sock_read(struct osmo_fd *bfd) 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; } |