From: Max msuraev@sysmocom.de
Use bool type for boolean values. Move common code out of if.. else. --- src/osmo-bts-litecell15/l1_if.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/osmo-bts-litecell15/l1_if.c b/src/osmo-bts-litecell15/l1_if.c index 6a60b3f..3e60726 100644 --- a/src/osmo-bts-litecell15/l1_if.c +++ b/src/osmo-bts-litecell15/l1_if.c @@ -28,7 +28,7 @@ #include <unistd.h> #include <errno.h> #include <fcntl.h> - +#include <stdbool.h> #include <sys/types.h> #include <sys/stat.h>
@@ -96,7 +96,7 @@ static void l1if_req_timeout(void *data) }
static int _l1if_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, - int is_system_prim, l1if_compl_cb *cb, void *data) + bool is_system_prim, l1if_compl_cb *cb, void *data) { struct wait_l1_conf *wlc; struct osmo_wqueue *wqueue; @@ -108,7 +108,7 @@ static int _l1if_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, wlc->cb_data = data;
/* Make sure we actually have received a REQUEST type primitive */ - if (is_system_prim == 0) { + if (!is_system_prim) { GsmL1_Prim_t *l1p = msgb_l1prim(msg);
LOGP(DL1P, LOGL_INFO, "Tx L1 prim %s\n", @@ -123,7 +123,6 @@ static int _l1if_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, wlc->is_sys_prim = 0; wlc->conf_prim_id = lc15bts_get_l1prim_conf(l1p->id); wqueue = &fl1h->write_q[MQ_L1_WRITE]; - timeout_secs = 30; } else { Litecell15_Prim_t *sysp = msgb_sysprim(msg);
@@ -139,9 +138,10 @@ static int _l1if_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, wlc->is_sys_prim = 1; wlc->conf_prim_id = lc15bts_get_sysprim_conf(sysp->id); wqueue = &fl1h->write_q[MQ_SYS_WRITE]; - timeout_secs = 30; }
+ timeout_secs = 30; + /* enqueue the message in the queue and add wsc to list */ if (osmo_wqueue_enqueue(wqueue, msg) != 0) { /* So we will get a timeout but the log message might help */ @@ -163,13 +163,13 @@ static int _l1if_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, int l1if_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, l1if_compl_cb *cb, void *data) { - return _l1if_req_compl(fl1h, msg, 1, cb, data); + return _l1if_req_compl(fl1h, msg, true, cb, data); }
int l1if_gsm_req_compl(struct lc15l1_hdl *fl1h, struct msgb *msg, l1if_compl_cb *cb, void *data) { - return _l1if_req_compl(fl1h, msg, 0, cb, data); + return _l1if_req_compl(fl1h, msg, false, cb, data); }
/* allocate a msgb containing a GsmL1_Prim_t */
From: Max msuraev@sysmocom.de
Use bool type for boolean values. Move common code out of if.. else. --- src/osmo-bts-sysmo/l1_if.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/src/osmo-bts-sysmo/l1_if.c b/src/osmo-bts-sysmo/l1_if.c index debc80a..e031461 100644 --- a/src/osmo-bts-sysmo/l1_if.c +++ b/src/osmo-bts-sysmo/l1_if.c @@ -24,7 +24,7 @@ #include <unistd.h> #include <errno.h> #include <fcntl.h> - +#include <stdbool.h> #include <sys/types.h> #include <sys/stat.h>
@@ -92,7 +92,7 @@ static void l1if_req_timeout(void *data) }
static int _l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg, - int is_system_prim, l1if_compl_cb *cb, void *data) + bool is_system_prim, l1if_compl_cb *cb, void *data) { struct wait_l1_conf *wlc; struct osmo_wqueue *wqueue; @@ -104,7 +104,7 @@ static int _l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg, wlc->cb_data = data;
/* Make sure we actually have received a REQUEST type primitive */ - if (is_system_prim == 0) { + if (!is_system_prim) { GsmL1_Prim_t *l1p = msgb_l1prim(msg);
LOGP(DL1P, LOGL_INFO, "Tx L1 prim %s\n", @@ -119,7 +119,6 @@ static int _l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg, wlc->is_sys_prim = 0; wlc->conf_prim_id = femtobts_l1prim_req2conf[l1p->id]; wqueue = &fl1h->write_q[MQ_L1_WRITE]; - timeout_secs = 30; } else { SuperFemto_Prim_t *sysp = msgb_sysprim(msg);
@@ -135,9 +134,10 @@ static int _l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg, wlc->is_sys_prim = 1; wlc->conf_prim_id = femtobts_sysprim_req2conf[sysp->id]; wqueue = &fl1h->write_q[MQ_SYS_WRITE]; - timeout_secs = 30; }
+ timeout_secs = 30; + /* enqueue the message in the queue and add wsc to list */ if (osmo_wqueue_enqueue(wqueue, msg) != 0) { /* So we will get a timeout but the log message might help */ @@ -159,13 +159,13 @@ static int _l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg, int l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg, l1if_compl_cb *cb, void *data) { - return _l1if_req_compl(fl1h, msg, 1, cb, data); + return _l1if_req_compl(fl1h, msg, true, cb, data); }
int l1if_gsm_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg, l1if_compl_cb *cb, void *data) { - return _l1if_req_compl(fl1h, msg, 0, cb, data); + return _l1if_req_compl(fl1h, msg, false, cb, data); }
/* allocate a msgb containing a GsmL1_Prim_t */
On 21 Apr 2016, at 18:43, msuraev@sysmocom.de wrote:
From: Max msuraev@sysmocom.de
Hi Max,
Use bool type for boolean values. Move common code out of if.. else.
is this worth our time?
} else { SuperFemto_Prim_t *sysp = msgb_sysprim(msg);timeout_secs = 30;@@ -135,9 +134,10 @@ static int _l1if_req_compl(struct femtol1_hdl *fl1h, struct msgb *msg, wlc->is_sys_prim = 1; wlc->conf_prim_id = femtobts_sysprim_req2conf[sysp->id]; wqueue = &fl1h->write_q[MQ_SYS_WRITE];
}timeout_secs = 30;
- timeout_secs = 30;
then make it const int timeout_secs = 30;
On Fri, Apr 22, 2016 at 03:35:23PM +0200, Holger Freyther wrote:
On 21 Apr 2016, at 18:43, msuraev@sysmocom.de wrote:
From: Max msuraev@sysmocom.de
Hi Max,
Use bool type for boolean values. Move common code out of if.. else.
is this worth our time?
I like API clarifications, IMHO they are "always" worth their time as they extend "infinitely" into the future for every user.
I'd even prefer two separate commits though.
~Neels