Change in libosmo-netif[master]: amr: use sizeof(struct amr_hdr) when working with amr header length

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Wed Mar 27 08:01:08 UTC 2019


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 <pmaier at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190327/b429fc47/attachment.htm>


More information about the gerrit-log mailing list