[PATCH] utils: use namespace prefix osmo_*

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/OpenBSC@lists.osmocom.org/.

Pablo Neira Ayuso pablo at gnumonks.org
Sat May 7 10:43:08 UTC 2011


Summary of changes:

s/bcd2char/osmo_bcd2char/g
s/char2bcd/osmo_char2bcd/g
s/hexparse/osmo_hexparse/g
s/hexdump/osmo_hexdump/g
s/hexdump_nospc/osmo_hexdump_nospc/g
s/ubit_dump/osmo_ubit_dump/g
s/static_assert/osmo_static_assert/g
---
 include/osmocom/core/msgb.h  |    2 +-
 include/osmocom/core/utils.h |   14 +++++++-------
 src/gsm/gsm48.c              |   12 ++++++------
 src/utils.c                  |   18 +++++++++---------
 4 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index 57b5d7f..8665c2b 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -181,7 +181,7 @@ static inline void msgb_reserve(struct msgb *msg, int len)
 static inline struct msgb *msgb_alloc_headroom(int size, int headroom,
 						const char *name)
 {
-	static_assert(size > headroom, headroom_bigger);
+	osmo_static_assert(size > headroom, headroom_bigger);
 
 	struct msgb *msg = msgb_alloc(size, name);
 	if (msg)
diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index 252228d..0f1ea3b 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -13,16 +13,16 @@ struct value_string {
 const char *get_value_string(const struct value_string *vs, uint32_t val);
 int get_string_value(const struct value_string *vs, const char *str);
 
-char bcd2char(uint8_t bcd);
+char osmo_bcd2char(uint8_t bcd);
 /* only works for numbers in ascci */
-uint8_t char2bcd(char c);
+uint8_t osmo_char2bcd(char c);
 
-int hexparse(const char *str, uint8_t *b, int max_len);
-char *hexdump(const unsigned char *buf, int len);
-char *hexdump_nospc(const unsigned char *buf, int len);
-char *ubit_dump(const uint8_t *bits, unsigned int len);
+int osmo_hexparse(const char *str, uint8_t *b, int max_len);
+char *osmo_hexdump(const unsigned char *buf, int len);
+char *osmo_osmo_hexdump_nospc(const unsigned char *buf, int len);
+char *osmo_ubit_dump(const uint8_t *bits, unsigned int len);
 
-#define static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1];
+#define osmo_static_assert(exp, name) typedef int dummy##name [(exp) ? 1 : -1];
 
 void osmo_str2lower(char *out, const char *in);
 void osmo_str2upper(char *out, const char *in);
diff --git a/src/gsm/gsm48.c b/src/gsm/gsm48.c
index 436bf14..d034589 100644
--- a/src/gsm/gsm48.c
+++ b/src/gsm/gsm48.c
@@ -301,7 +301,7 @@ int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi)
 	uint8_t odd = (length & 0x1) == 1;
 
 	buf[0] = GSM48_IE_MOBILE_ID;
-	buf[2] = char2bcd(imsi[0]) << 4 | GSM_MI_TYPE_IMSI | (odd << 3);
+	buf[2] = osmo_char2bcd(imsi[0]) << 4 | GSM_MI_TYPE_IMSI | (odd << 3);
 
 	/* if the length is even we will fill half of the last octet */
 	if (odd)
@@ -312,11 +312,11 @@ int gsm48_generate_mid_from_imsi(uint8_t *buf, const char *imsi)
 	for (i = 1; i < buf[1]; ++i) {
 		uint8_t lower, upper;
 
-		lower = char2bcd(imsi[++off]);
+		lower = osmo_char2bcd(imsi[++off]);
 		if (!odd && off + 1 == length)
 			upper = 0x0f;
 		else
-			upper = char2bcd(imsi[++off]) & 0x0f;
+			upper = osmo_char2bcd(imsi[++off]) & 0x0f;
 
 		buf[2 + i] = (upper << 4) | lower;
 	}
@@ -349,15 +349,15 @@ int gsm48_mi_to_string(char *string, const int str_len, const uint8_t *mi,
 	case GSM_MI_TYPE_IMSI:
 	case GSM_MI_TYPE_IMEI:
 	case GSM_MI_TYPE_IMEISV:
-		*str_cur++ = bcd2char(mi[0] >> 4);
+		*str_cur++ = osmo_bcd2char(mi[0] >> 4);
 
                 for (i = 1; i < mi_len; i++) {
 			if (str_cur + 2 >= string + str_len)
 				return str_cur - string;
-			*str_cur++ = bcd2char(mi[i] & 0xf);
+			*str_cur++ = osmo_bcd2char(mi[i] & 0xf);
 			/* skip last nibble in last input byte when GSM_EVEN */
 			if( (i != mi_len-1) || (mi[0] & GSM_MI_ODD))
-				*str_cur++ = bcd2char(mi[i] >> 4);
+				*str_cur++ = osmo_bcd2char(mi[i] >> 4);
 		}
 		break;
 	default:
diff --git a/src/utils.c b/src/utils.c
index af1829c..3ee14ab 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -35,7 +35,7 @@ int get_string_value(const struct value_string *vs, const char *str)
 	return -EINVAL;
 }
 
-char bcd2char(uint8_t bcd)
+char osmo_bcd2char(uint8_t bcd)
 {
 	if (bcd < 0xa)
 		return '0' + bcd;
@@ -44,12 +44,12 @@ char bcd2char(uint8_t bcd)
 }
 
 /* only works for numbers in ascii */
-uint8_t char2bcd(char c)
+uint8_t osmo_char2bcd(char c)
 {
 	return c - 0x30;
 }
 
-int hexparse(const char *str, uint8_t *b, int max_len)
+int osmo_hexparse(const char *str, uint8_t *b, int max_len)
 
 {
 	int i, l, v;
@@ -78,7 +78,7 @@ int hexparse(const char *str, uint8_t *b, int max_len)
 
 static char hexd_buff[4096];
 
-static char *_hexdump(const unsigned char *buf, int len, char *delim)
+static char *_osmo_hexdump(const unsigned char *buf, int len, char *delim)
 {
 	int i;
 	char *cur = hexd_buff;
@@ -95,7 +95,7 @@ static char *_hexdump(const unsigned char *buf, int len, char *delim)
 	return hexd_buff;
 }
 
-char *ubit_dump(const uint8_t *bits, unsigned int len)
+char *osmo_ubit_dump(const uint8_t *bits, unsigned int len)
 {
 	int i;
 
@@ -125,14 +125,14 @@ char *ubit_dump(const uint8_t *bits, unsigned int len)
 	return hexd_buff;
 }
 
-char *hexdump(const unsigned char *buf, int len)
+char *osmo_hexdump(const unsigned char *buf, int len)
 {
-	return _hexdump(buf, len, " ");
+	return _osmo_hexdump(buf, len, " ");
 }
 
-char *hexdump_nospc(const unsigned char *buf, int len)
+char *osmo_osmo_hexdump_nospc(const unsigned char *buf, int len)
 {
-	return _hexdump(buf, len, "");
+	return _osmo_hexdump(buf, len, "");
 }
 
 #include "../config.h"
-- 
1.7.2.3


--------------080409000203030603090707--




More information about the OpenBSC mailing list