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/.
neels gerrit-no-reply at lists.osmocom.orgneels has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/24298 ) Change subject: log: show src file,line of lchan_set_last_error ...................................................................... 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 --- M include/osmocom/bsc/lchan_fsm.h M src/osmo-bsc/lchan_fsm.c M src/osmo-bsc/lchan_rtp_fsm.c 3 files changed, 12 insertions(+), 24 deletions(-) Approvals: Jenkins Builder: Verified fixeria: Looks good to me, approved diff --git a/include/osmocom/bsc/lchan_fsm.h b/include/osmocom/bsc/lchan_fsm.h index ded7f54..2d5307a 100644 --- a/include/osmocom/bsc/lchan_fsm.h +++ b/include/osmocom/bsc/lchan_fsm.h @@ -12,6 +12,13 @@ LOGP(DRSL, level, "%s (not initialized) " fmt, gsm_lchan_name(lchan), ## args); \ } while(0) +#define LCHAN_SET_LAST_ERROR(LCHAN, fmt, args...) do { \ + if ((LCHAN)->last_error) \ + talloc_free((LCHAN)->last_error); \ + (LCHAN)->last_error = talloc_asprintf((LCHAN)->ts->trx, fmt, ##args); \ + LOG_LCHAN(LCHAN, LOGL_ERROR, "%s\n", (LCHAN)->last_error); \ + } while(0) + enum lchan_fsm_state { LCHAN_ST_UNUSED, LCHAN_ST_CBCH, /*< Blocked by CBCH channel combination, not usable as SDCCH. */ @@ -74,6 +81,4 @@ void lchan_forget_conn(struct gsm_lchan *lchan); -void lchan_set_last_error(struct gsm_lchan *lchan, const char *fmt, ...); - void lchan_fsm_skip_error(struct gsm_lchan *lchan); diff --git a/src/osmo-bsc/lchan_fsm.c b/src/osmo-bsc/lchan_fsm.c index 4eb95ff..94f7821 100644 --- a/src/osmo-bsc/lchan_fsm.c +++ b/src/osmo-bsc/lchan_fsm.c @@ -66,25 +66,6 @@ } } -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 @@ 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 @@ 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 cd195d0..8991acc 100644 --- a/src/osmo-bsc/lchan_rtp_fsm.c +++ b/src/osmo-bsc/lchan_rtp_fsm.c @@ -63,7 +63,7 @@ #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) -- To view, visit https://gerrit.osmocom.org/c/osmo-bsc/+/24298 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmo-bsc Gerrit-Branch: master Gerrit-Change-Id: I571fdf2d418c52d120215cf19e57a3c96d67af07 Gerrit-Change-Number: 24298 Gerrit-PatchSet: 2 Gerrit-Owner: neels <nhofmeyr at sysmocom.de> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria <vyanitskiy at sysmocom.de> Gerrit-Reviewer: neels <nhofmeyr at sysmocom.de> Gerrit-CC: pespin <pespin at sysmocom.de> Gerrit-MessageType: merged -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210521/a9fa2337/attachment.htm>