From 5e4fdb23a48fa9990e739d39296289403ce8cbe0 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Sun, 1 Dec 2019 15:43:40 +0100 Subject: Move a_reset_fsm regstration to __attribute__((contructor)) This way we can avoid the runtime overhead of checking whether or not it is initialized over and over again. It also brings this code more in line with other users of osmo_fsm_register(). Change-Id: I3c7220491cf6ffb1361e7259c0344df64a013a0a --- src/osmo-bsc/a_reset.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/osmo-bsc/a_reset.c b/src/osmo-bsc/a_reset.c index bc4191456..3f512781b 100644 --- a/src/osmo-bsc/a_reset.c +++ b/src/osmo-bsc/a_reset.c @@ -149,10 +149,6 @@ void a_reset_alloc(struct bsc_msc_data *msc, const char *name, void *cb) /* There must not be any double allocation! */ OSMO_ASSERT(msc->a.reset_fsm == NULL); - /* Register the fsm description (if not already done) */ - if (osmo_fsm_find_by_name(fsm.name) != &fsm) - OSMO_ASSERT(osmo_fsm_register(&fsm) == 0); - /* Allocate and configure a new fsm instance */ reset_ctx = talloc_zero(msc, struct reset_ctx); OSMO_ASSERT(reset_ctx); @@ -217,3 +213,8 @@ bool a_reset_conn_ready(struct bsc_msc_data *msc) return false; } + +static __attribute__((constructor)) void a_reset_fsm_init() +{ + OSMO_ASSERT(osmo_fsm_register(&fsm) == 0); +} -- cgit v1.2.3