[MERGED] openbsc[master]: Cosmetic fixes around SI generation

Max gerrit-no-reply at lists.osmocom.org
Fri Jan 6 11:37:52 UTC 2017


Max has submitted this change and it was merged.

Change subject: Cosmetic fixes around SI generation
......................................................................


Cosmetic fixes around SI generation

* add missing spaces after comma and minus
* prevent useless recursion calls
* mark static functions as such
* name and explicitly use enum for ARFCN range

Change-Id: If5b717445c8b24668bad0e78fd5bb51f66c4d18e
---
M openbsc/include/openbsc/arfcn_range_encode.h
M openbsc/include/openbsc/system_information.h
M openbsc/src/libbsc/arfcn_range_encode.c
M openbsc/src/libbsc/bsc_init.c
M openbsc/src/libbsc/system_information.c
5 files changed, 12 insertions(+), 11 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/openbsc/include/openbsc/arfcn_range_encode.h b/openbsc/include/openbsc/arfcn_range_encode.h
index bd85d6a..7ec710c 100644
--- a/openbsc/include/openbsc/arfcn_range_encode.h
+++ b/openbsc/include/openbsc/arfcn_range_encode.h
@@ -3,7 +3,7 @@
 
 #include <stdint.h>
 
-enum {
+enum gsm48_range {
 	ARFCN_RANGE_INVALID	= -1,
 	ARFCN_RANGE_128		= 127,
 	ARFCN_RANGE_256		= 255,
@@ -14,8 +14,8 @@
 #define RANGE_ENC_MAX_ARFCNS	29
 
 int range_enc_determine_range(const int *arfcns, int size, int *f0_out);
-int range_enc_arfcns(const int rng, const int *arfcns, int sze, int *out, int idx);
-int range_enc_find_index(const int rng, const int *arfcns, int size);
+int range_enc_arfcns(enum gsm48_range rng, const int *arfcns, int sze, int *out, int idx);
+int range_enc_find_index(enum gsm48_range rng, const int *arfcns, int size);
 int range_enc_filter_arfcns(int *arfcns, const int sze, const int f0, int *f0_included);
 
 int range_enc_range128(uint8_t *chan_list, int f0, int *w);
diff --git a/openbsc/include/openbsc/system_information.h b/openbsc/include/openbsc/system_information.h
index 7e3ceaa..ebc3afd 100644
--- a/openbsc/include/openbsc/system_information.h
+++ b/openbsc/include/openbsc/system_information.h
@@ -6,7 +6,6 @@
 struct gsm_bts;
 
 int gsm_generate_si(struct gsm_bts *bts, enum osmo_sysinfo_type type);
-uint16_t encode_fdd(uint16_t scramble, bool diversity);
 unsigned uarfcn_size(const uint16_t *u, const uint16_t *sc, size_t u_len);
 unsigned earfcn_size(const struct osmo_earfcn_si2q *e);
 unsigned range1024_p(unsigned n);
diff --git a/openbsc/src/libbsc/arfcn_range_encode.c b/openbsc/src/libbsc/arfcn_range_encode.c
index e67bf0a..9918838 100644
--- a/openbsc/src/libbsc/arfcn_range_encode.c
+++ b/openbsc/src/libbsc/arfcn_range_encode.c
@@ -27,7 +27,7 @@
 
 #include <osmocom/core/utils.h>
 
-int greatest_power_of_2_lesser_or_equal_to(int index)
+static inline int greatest_power_of_2_lesser_or_equal_to(int index)
 {
 	int power_of_2 = 1;
 
@@ -52,7 +52,7 @@
  * equally size partition for the given range. Return -1 if
  * no such partition exists.
  */
-int range_enc_find_index(const int range, const int *freqs, const int size)
+int range_enc_find_index(enum gsm48_range range, const int *freqs, const int size)
 {
 	int i, j, n;
 
@@ -79,7 +79,7 @@
  * \param size The size of the list of ARFCNs
  * \param out Place to store the W(i) output.
  */
-int range_enc_arfcns(const int range,
+int range_enc_arfcns(enum gsm48_range range,
 		const int *arfcns, int size, int *out,
 		const int index)
 {
@@ -127,9 +127,11 @@
 	 * Now recurse and we need to make this iterative... but as the
 	 * tree is balanced the stack will not be too deep.
 	 */
-	range_enc_arfcns(range / 2, arfcns_left, l_size,
+	if (l_size)
+		range_enc_arfcns(range / 2, arfcns_left, l_size,
 			out, index + greatest_power_of_2_lesser_or_equal_to(index + 1));
-	range_enc_arfcns((range -1 ) / 2, arfcns_right, r_size,
+	if (r_size)
+		range_enc_arfcns((range - 1) / 2, arfcns_right, r_size,
 			 out, index + (2 * greatest_power_of_2_lesser_or_equal_to(index + 1)));
 	return 0;
 }
diff --git a/openbsc/src/libbsc/bsc_init.c b/openbsc/src/libbsc/bsc_init.c
index 9e913d6..b17ff79 100644
--- a/openbsc/src/libbsc/bsc_init.c
+++ b/openbsc/src/libbsc/bsc_init.c
@@ -193,7 +193,7 @@
 
 	return 0;
 err_out:
-	LOGP(DRR, LOGL_ERROR, "Cannot generate SI%s for BTS %u: error <%s>,"
+	LOGP(DRR, LOGL_ERROR, "Cannot generate SI%s for BTS %u: error <%s>, "
 	     "most likely a problem with neighbor cell list generation\n",
 	     get_value_string(osmo_sitype_strs, i), bts->nr, strerror(-rc));
 	return rc;
diff --git a/openbsc/src/libbsc/system_information.c b/openbsc/src/libbsc/system_information.c
index 6c601e4..3d55d1a 100644
--- a/openbsc/src/libbsc/system_information.c
+++ b/openbsc/src/libbsc/system_information.c
@@ -149,7 +149,7 @@
 }
 
 /* 3GPP TS 44.018, Table 9.1.54.1 - prepend diversity bit to scrambling code */
-uint16_t encode_fdd(uint16_t scramble, bool diversity)
+static inline uint16_t encode_fdd(uint16_t scramble, bool diversity)
 {
 	if (diversity)
 		return scramble | (1 << 9);

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If5b717445c8b24668bad0e78fd5bb51f66c4d18e
Gerrit-PatchSet: 6
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>


More information about the gerrit-log mailing list