summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2019-12-01 13:15:52 +0100
committerHarald Welte <laforge@osmocom.org>2019-12-01 17:36:50 +0100
commita4555c34304aee9b825be3879c54cedcb5a7dbae (patch)
treebc4df8fe9781cb03630f3148f7e25bc8d70e7bfe
parent362141cc58ac4e480c09598b0ec65a28ad0b1f06 (diff)
check for osmo_fsm_register() failures and propagate error
-rw-r--r--examples/sccp_demo_user.c2
-rw-r--r--src/osmo_ss7.c23
-rw-r--r--stp/stp_main.c2
-rw-r--r--tests/ss7/ss7_test.c2
-rw-r--r--tests/vty/ss7_asp_vty_test.c2
5 files changed, 22 insertions, 9 deletions
diff --git a/examples/sccp_demo_user.c b/examples/sccp_demo_user.c
index 28dd166..b55b50c 100644
--- a/examples/sccp_demo_user.c
+++ b/examples/sccp_demo_user.c
@@ -230,7 +230,7 @@ int main(int argc, char **argv)
signal(SIGUSR2, &signal_handler);
init_logging();
- osmo_ss7_init();
+ OSMO_ASSERT(osmo_ss7_init() == 0);
osmo_fsm_log_addr(false);
vty_init(&vty_info);
osmo_ss7_vty_init_asp(NULL);
diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c
index a07fbed..1ca8b5e 100644
--- a/src/osmo_ss7.c
+++ b/src/osmo_ss7.c
@@ -2061,13 +2061,26 @@ bool osmo_ss7_pc_is_local(struct osmo_ss7_instance *inst, uint32_t pc)
int osmo_ss7_init(void)
{
+ int rc;
+
if (ss7_initialized)
return 1;
- osmo_fsm_register(&sccp_scoc_fsm);
- osmo_fsm_register(&xua_as_fsm);
- osmo_fsm_register(&xua_asp_fsm);
- osmo_fsm_register(&ipa_asp_fsm);
- osmo_fsm_register(&xua_default_lm_fsm);
+ rc = osmo_fsm_register(&sccp_scoc_fsm);
+ if (rc < 0)
+ return rc;
+ rc = osmo_fsm_register(&xua_as_fsm);
+ if (rc < 0)
+ return rc;
+ rc = osmo_fsm_register(&xua_asp_fsm);
+ if (rc < 0)
+ return rc;
+ rc = osmo_fsm_register(&ipa_asp_fsm);
+ if (rc < 0)
+ return rc;
+ rc = osmo_fsm_register(&xua_default_lm_fsm);
+ if (rc < 0)
+ return rc;
+
ss7_initialized = true;
return 0;
}
diff --git a/stp/stp_main.c b/stp/stp_main.c
index 4cc2586..3923ed2 100644
--- a/stp/stp_main.c
+++ b/stp/stp_main.c
@@ -175,7 +175,7 @@ int main(int argc, char **argv)
fputs(stp_copyright, stdout);
fputs("\n", stdout);
- osmo_ss7_init();
+ OSMO_ASSERT(osmo_ss7_init() == 0);
osmo_fsm_log_addr(false);
logging_vty_add_cmds();
osmo_stats_vty_add_cmds();
diff --git a/tests/ss7/ss7_test.c b/tests/ss7/ss7_test.c
index a3f47b6..ae96a4b 100644
--- a/tests/ss7/ss7_test.c
+++ b/tests/ss7/ss7_test.c
@@ -302,7 +302,7 @@ int main(int argc, char **argv)
osmo_fsm_log_addr(false);
/* init */
- osmo_ss7_init();
+ OSMO_ASSERT(osmo_ss7_init() == 0);
s7i = osmo_ss7_instance_find_or_create(NULL, 0);
OSMO_ASSERT(osmo_ss7_instance_find(0) == s7i);
OSMO_ASSERT(osmo_ss7_instance_find(23) == NULL);
diff --git a/tests/vty/ss7_asp_vty_test.c b/tests/vty/ss7_asp_vty_test.c
index 76ffcf2..eb575bc 100644
--- a/tests/vty/ss7_asp_vty_test.c
+++ b/tests/vty/ss7_asp_vty_test.c
@@ -164,7 +164,7 @@ int main(int argc, char **argv)
osmo_init_logging2(root_ctx, &log_info);
logging_vty_add_cmds();
- osmo_ss7_init();
+ OSMO_ASSERT(osmo_ss7_init() == 0);
osmo_ss7_vty_init_asp(root_ctx);
osmo_sccp_vty_init();