Harald Welte has submitted this change and it was merged. ( 
https://gerrit.osmocom.org/13346 )

Change subject: amr: use sizeof(struct amr_hdr) when working with amr header 
length
......................................................................

amr: use sizeof(struct amr_hdr) when working with amr header length

The header of an AMR header payload is 2 bytes long. At the moment we
use just a constant of 2 when we refer to the header length, but we have a
struct amr_hdr defined. Lets use sizeof(struct amr_hdr) to make it more
clear that we are refering to the header length.

Change-Id: Ic7ca04b99a97d7d3b91717b0c3e6c55ef3001a3e
---
M src/amr.c
1 file changed, 3 insertions(+), 3 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Pau Espin Pedrol: Looks good to me, but someone else must approve
  Harald Welte: Looks good to me, approved



diff --git a/src/amr.c b/src/amr.c
index 9c63f60..5609c46 100644
--- a/src/amr.c
+++ b/src/amr.c
@@ -82,7 +82,7 @@
        unsigned int frame_len;

        /* Broken payload? */
-       if (!payload || payload_len < 2)
+       if (!payload || payload_len < sizeof(struct amr_hdr))
                return false;

        /* In octet aligned mode, padding bits are specified to be
@@ -106,7 +106,7 @@
        if(!osmo_amr_ft_valid(oa_hdr->ft))
                return false;
        frame_len = osmo_amr_bytes(oa_hdr->ft);
-       if (frame_len != payload_len - 2)
+       if (frame_len != payload_len - sizeof(struct amr_hdr))
                return false;

        return true;
@@ -119,7 +119,7 @@
 int osmo_amr_oa_to_bwe(uint8_t *payload, unsigned int payload_len)
 {
        struct amr_hdr *oa_hdr = (struct amr_hdr *)payload;
-       unsigned int frame_len = payload_len - 2;
+       unsigned int frame_len = payload_len - sizeof(struct amr_hdr);
        unsigned int i;

        /* This implementation is not capable to handle multi-frame

--
To view, visit https://gerrit.osmocom.org/13346
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic7ca04b99a97d7d3b91717b0c3e6c55ef3001a3e
Gerrit-Change-Number: 13346
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <[email protected]>
Gerrit-Reviewer: Harald Welte <[email protected]>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <[email protected]>

Reply via email to