[PATCH] libosmocore[master]: gsm0480.c: code dup: have common msgb alloc functions

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Mon Nov 28 13:39:36 UTC 2016


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

gsm0480.c: code dup: have common msgb alloc functions

One with an explicit msgb name, another with fixed name.

Change-Id: I029551dd74410ad6f326ce52eb7a75d912d3b875
---
M src/gsm/gsm0480.c
1 file changed, 14 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/41/1341/1

diff --git a/src/gsm/gsm0480.c b/src/gsm/gsm0480.c
index 3c23f6f..bbf6e3f 100644
--- a/src/gsm/gsm0480.c
+++ b/src/gsm/gsm0480.c
@@ -32,6 +32,16 @@
 
 #include <string.h>
 
+static inline struct msgb *gsm0480_msgb_alloc_name(const char *name)
+{
+	return msgb_alloc_headroom(1024, 128, name);
+}
+
+static inline struct msgb *gsm0480_msgb_alloc(void)
+{
+	return gsm0480_msgb_alloc_name("GSM 04.80");
+}
+
 static inline unsigned char *msgb_wrap_with_TL(struct msgb *msgb, uint8_t tag)
 {
 	uint8_t *data = msgb_push(msgb, 2);
@@ -87,7 +97,7 @@
 	uint8_t *seq_len_ptr, *ussd_len_ptr, *data;
 	int len;
 
-	msg = msgb_alloc_headroom(1024, 128, "GSM 04.80");
+	msg = gsm0480_msgb_alloc();
 	if (!msg)
 		return NULL;
 
@@ -133,7 +143,7 @@
 	if (len < 1 || len > 160)
 		return NULL;
 
-	msg = msgb_alloc_headroom(1024, 128, "GSM 04.80");
+	msg = gsm0480_msgb_alloc();
 	if (!msg)
 		return NULL;
 
@@ -489,7 +499,7 @@
 	uint8_t *ptr8;
 	int response_len;
 
-	msg = msgb_alloc_headroom(1024, 128, "GSM 04.80");
+	msg = gsm0480_msgb_alloc();
 	if (!msg)
 		return NULL;
 
@@ -560,7 +570,7 @@
 {
 	struct msgb *msg;
 
-	msg = msgb_alloc_headroom(1024, 128, "GSM 04.80 USSD REL COMPL");
+	msg = gsm0480_msgb_alloc_name("GSM 04.80 USSD REL COMPL");
 	if (!msg)
 		return NULL;
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I029551dd74410ad6f326ce52eb7a75d912d3b875
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list