SI2quater: fix EARFCN inclusion check

Previously only the existance of bts->si_common.si2quater_neigh_list was
checked but not the actual number of EARFCNs in it. Fix it by using
si2q_earfcn_count() and adjust tests accordingly. While at it - reformat
tests to include extra information.

The correctness was checked manually by inspecting GSMTAP output.

Change-Id: Ic4fb2a9e870db66cac58b1e8d113587b30d64ce2
Related: RT#8792
diff --git a/openbsc/src/libbsc/rest_octets.c b/openbsc/src/libbsc/rest_octets.c
index 950e570..a6fdf46 100644
--- a/openbsc/src/libbsc/rest_octets.c
+++ b/openbsc/src/libbsc/rest_octets.c
@@ -379,14 +379,13 @@
 	/* No GPRS_3G_MEASUREMENT Parameters Descr. */
 	bitvec_set_bit(&bv, 0);
 
-	if (&bts->si_common.si2quater_neigh_list) { /* FIXME: use si2q_earfcn_count() in if */
+	if (si2q_earfcn_count(&bts->si_common.si2quater_neigh_list)) {
 		append_earfcn(&bv, bts, SI2Q_MAX_LEN - bv.cur_bit);
 
 		/* FIXME: remove following check once multiple SI2q are properly supported */
 		if ((bts->e_offset != si2q_earfcn_count(&bts->si_common.si2quater_neigh_list)) ||
 		    si2q_earfcn_count(&bts->si_common.si2quater_neigh_list) > 5)
 			return -ENOMEM;
-
 	} else {
 		/* No Additions in Rel-5: */
 		bitvec_set_bit(&bv, L);
diff --git a/openbsc/src/libbsc/system_information.c b/openbsc/src/libbsc/system_information.c
index 0496506..644bebd 100644
--- a/openbsc/src/libbsc/system_information.c
+++ b/openbsc/src/libbsc/system_information.c
@@ -692,6 +692,10 @@
 size_t si2q_earfcn_count(const struct osmo_earfcn_si2q *e)
 {
 	unsigned i, ret = 0;
+
+	if (!e)
+		return 0;
+
 	for (i = 0; i < e->length; i++)
 		if (e->arfcn[i] != OSMO_EARFCN_INVALID)
 			ret++;
@@ -777,7 +781,8 @@
 		si_info.si2ter_indicator = 0;
 	}
 	if ((bts->si_valid & (1 << SYSINFO_TYPE_2quater))) {
-		LOGP(DRR, LOGL_INFO, "SI 2quater is included.\n");
+		LOGP(DRR, LOGL_INFO, "SI 2quater is included, based on %zu EARFCNs and %zu UARFCNs.\n",
+		     si2q_earfcn_count(&bts->si_common.si2quater_neigh_list), bts->si_common.uarfcn_length);
 		si_info.si2quater_indicator = 1;
 	} else {
 		si_info.si2quater_indicator = 0;