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

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

Max gerrit-no-reply at lists.osmocom.org
Wed Dec 14 14:18:18 UTC 2016


Hello Harald Welte, Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/1372

to look at the new patch set (#2).

Cosmetic fixes around SI generation

* add missing spaces after comma and minus
* make range_enc_arfcns() return void instead of always returning 0
* prevent useless recursion calls
* mark static function as such

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


  git pull ssh://gerrit.osmocom.org:29418/openbsc refs/changes/72/1372/2

diff --git a/openbsc/include/openbsc/arfcn_range_encode.h b/openbsc/include/openbsc/arfcn_range_encode.h
index bd85d6a..11192d1 100644
--- a/openbsc/include/openbsc/arfcn_range_encode.h
+++ b/openbsc/include/openbsc/arfcn_range_encode.h
@@ -14,7 +14,7 @@
 #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);
+void 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_filter_arfcns(int *arfcns, const int sze, const int f0, int *f0_included);
 
diff --git a/openbsc/src/libbsc/arfcn_range_encode.c b/openbsc/src/libbsc/arfcn_range_encode.c
index e67bf0a..7f90ce1 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;
 
@@ -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,
+void range_enc_arfcns(const int range,
 		const int *arfcns, int size, int *out,
 		const int index)
 {
@@ -100,11 +100,11 @@
 
 	/* Test the two recursion anchors and stop processing */
 	if (size == 0)
-		return 0;
+		return;
 
 	if (size == 1) {
 		out[index] = 1 + arfcns[0];
-		return 0;
+		return;
 	}
 
 	/* Now do the processing */
@@ -127,11 +127,12 @@
 	 * 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 3f6d6b9..1b4145c 100644
--- a/openbsc/src/libbsc/system_information.c
+++ b/openbsc/src/libbsc/system_information.c
@@ -325,7 +325,7 @@
 	int w[RANGE_ENC_MAX_ARFCNS];
 	int f0_included = 0;
 	int arfcns_used = 0;
-	int i, rc, range, f0;
+	int i, range, f0;
 
 	/*
 	 * Select ARFCNs according to the rules in bitvec2freq_list
@@ -354,9 +354,7 @@
 				f0, &f0_included);
 
 	memset(w, 0, sizeof(w));
-	rc = range_enc_arfcns(range, arfcns, arfcns_used, w, 0);
-	if (rc != 0)
-		return -3;
+	range_enc_arfcns(range, arfcns, arfcns_used, w, 0);
 
 	/* Select the range and the amount of bits needed */
 	switch (range) {

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: If5b717445c8b24668bad0e78fd5bb51f66c4d18e
Gerrit-PatchSet: 2
Gerrit-Project: openbsc
Gerrit-Branch: master
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list