aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2021-05-05 14:12:16 +0000
committerNeels Hofmeyr <neels@hofmeyr.de>2021-05-21 15:43:30 +0200
commitd60b21cc6b3fd43897e97789423a94095dda0f18 (patch)
tree2c33dfda714edd05b1376e44ec4c57e34f36935f /src
parentf3cce79f146d39840639aa60bddccbc49298c2bc (diff)
log: show src file,line of lchan_set_last_error
Change lchan_set_last_error() to macro so that the error log reflects where the error was encountered. Change-Id: I571fdf2d418c52d120215cf19e57a3c96d67af07
Diffstat (limited to 'src')
-rw-r--r--src/osmo-bsc/lchan_fsm.c25
-rw-r--r--src/osmo-bsc/lchan_rtp_fsm.c2
2 files changed, 5 insertions, 22 deletions
diff --git a/src/osmo-bsc/lchan_fsm.c b/src/osmo-bsc/lchan_fsm.c
index 4eb95ff05..94f7821fd 100644
--- a/src/osmo-bsc/lchan_fsm.c
+++ b/src/osmo-bsc/lchan_fsm.c
@@ -66,25 +66,6 @@ bool lchan_may_receive_data(struct gsm_lchan *lchan)
}
}
-void lchan_set_last_error(struct gsm_lchan *lchan, const char *fmt, ...)
-{
- va_list ap;
- /* This dance allows using an existing error reason in above fmt */
- char *last_error_was = lchan->last_error;
- lchan->last_error = NULL;
-
- if (fmt) {
- va_start(ap, fmt);
- lchan->last_error = talloc_vasprintf(lchan->ts->trx, fmt, ap);
- va_end(ap);
-
- LOG_LCHAN(lchan, LOGL_ERROR, "%s\n", lchan->last_error);
- }
-
- if (last_error_was)
- talloc_free(last_error_was);
-}
-
/* The idea here is that we must not require to change any lchan state in order to deny a request. */
#define lchan_on_activation_failure(lchan, for_conn, activ_for) \
_lchan_on_activation_failure(lchan, for_conn, activ_for, \
@@ -240,7 +221,7 @@ struct osmo_tdef_state_timeout lchan_fsm_timeouts[32] = {
const uint32_t state_chg = STATE_CHG; \
LOG_LCHAN(_lchan, LOGL_DEBUG, "Handling failure, will then transition to state %s\n", \
osmo_fsm_state_name(fsm, state_chg)); \
- lchan_set_last_error(_lchan, "lchan %s in state %s: " fmt, \
+ LCHAN_SET_LAST_ERROR(_lchan, "lchan %s in state %s: " fmt, \
_lchan->activate.concluded ? "failure" : "allocation failed", \
osmo_fsm_state_name(fsm, state_was), ## args); \
lchan_on_activation_failure(_lchan, _lchan->activate.info.activ_for, _lchan->conn); \
@@ -547,7 +528,9 @@ static void lchan_fsm_unused(struct osmo_fsm_inst *fi, uint32_t event, void *dat
OSMO_ASSERT(info);
OSMO_ASSERT(!lchan->conn);
OSMO_ASSERT(!lchan->mgw_endpoint_ci_bts);
- lchan_set_last_error(lchan, NULL);
+ if (lchan->last_error)
+ talloc_free(lchan->last_error);
+ lchan->last_error = NULL;
lchan->release.requested = false;
lchan->activate.info = *info;
diff --git a/src/osmo-bsc/lchan_rtp_fsm.c b/src/osmo-bsc/lchan_rtp_fsm.c
index cd195d021..8991acccd 100644
--- a/src/osmo-bsc/lchan_rtp_fsm.c
+++ b/src/osmo-bsc/lchan_rtp_fsm.c
@@ -63,7 +63,7 @@ struct osmo_tdef_state_timeout lchan_rtp_fsm_timeouts[32] = {
#define lchan_rtp_fail(fmt, args...) do { \
struct gsm_lchan *_lchan = fi->priv; \
uint32_t state_was = fi->state; \
- lchan_set_last_error(_lchan, "lchan-rtp failure in state %s: " fmt, \
+ LCHAN_SET_LAST_ERROR(_lchan, "lchan-rtp failure in state %s: " fmt, \
osmo_fsm_state_name(fi->fsm, state_was), ## args); \
osmo_fsm_inst_dispatch(_lchan->fi, LCHAN_EV_RTP_ERROR, 0); \
} while(0)