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 Hofmeyr gerrit-no-reply at lists.osmocom.orgHello Harald Welte, Jenkins Builder,
I'd like you to reexamine a change. Please visit
https://gerrit.osmocom.org/7627
to look at the new patch set (#2).
fsm: id: properly set name in case of NULL id
Since alloc relies on osmo_fsm_inst_update_id() to set the name, never skip
that.
In osmo_fsm_inst_alloc(), we allow passing a NULL id, and in
osmo_fsm_inst_update_id(), we set the name without id if id is NULL.
Change-Id: I6d6b09a811b82770818f19b189a57d9fc4a8133b
---
M src/fsm.c
M tests/fsm/fsm_test.c
M tests/fsm/fsm_test.err
3 files changed, 4 insertions(+), 19 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/27/7627/2
diff --git a/src/fsm.c b/src/fsm.c
index 88de011..9bbf870 100644
--- a/src/fsm.c
+++ b/src/fsm.c
@@ -263,11 +263,9 @@
fi->log_level = log_level;
osmo_timer_setup(&fi->timer, fsm_tmr_cb, fi);
- if (id) {
- if (osmo_fsm_inst_update_id(fi, id) < 0) {
- talloc_free(fi);
- return NULL;
- }
+ if (osmo_fsm_inst_update_id(fi, id) < 0) {
+ talloc_free(fi);
+ return NULL;
}
INIT_LLIST_HEAD(&fi->proc.children);
diff --git a/tests/fsm/fsm_test.c b/tests/fsm/fsm_test.c
index 0f29a2e..859b78d 100644
--- a/tests/fsm/fsm_test.c
+++ b/tests/fsm/fsm_test.c
@@ -221,20 +221,7 @@
/* allocate FSM instance without id, there should be a name without id */
fi = osmo_fsm_inst_alloc(&fsm, g_ctx, NULL, LOGL_DEBUG, NULL);
OSMO_ASSERT(fi);
- /* CURRENT BUG: here I want to just do
assert_name("Test_FSM");
- * but when allocated with a NULL id, the fsm's name remains unset. Hence: */
- {
- const char *expected_name = "Test_FSM";
- const char *name = osmo_fsm_inst_name(fi);
- fprintf(stderr, " osmo_fsm_inst_name() == %s\n", osmo_quote_str(name, -1));
- if (safe_strcmp(name, expected_name)) {
- fprintf(stderr, " ERROR: expected %s\n", osmo_quote_str(expected_name, -1));
- OSMO_ASSERT(false);
- }
- OSMO_ASSERT(osmo_fsm_inst_find_by_name(&fsm, "Test_FSM") == NULL); /* <- ERROR */
- fprintf(stderr, " osmo_fsm_inst_find_by_name(%s) == NULL\n", osmo_quote_str(expected_name, -1));
- }
change_id("my_id");
change_id("another_id");
diff --git a/tests/fsm/fsm_test.err b/tests/fsm/fsm_test.err
index bc159bd..c4ee46f 100644
--- a/tests/fsm/fsm_test.err
+++ b/tests/fsm/fsm_test.err
@@ -13,7 +13,7 @@
--- test_id_api()
Test_FSM{NULL}: Allocated
[0;m osmo_fsm_inst_name() == "Test_FSM"
- osmo_fsm_inst_find_by_name("Test_FSM") == NULL
+ osmo_fsm_inst_find_by_name("Test_FSM") == fi
osmo_fsm_inst_update_id("my_id")
rc == 0, ok
osmo_fsm_inst_name() == "Test_FSM(my_id)"
--
To view, visit https://gerrit.osmocom.org/7627
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I6d6b09a811b82770818f19b189a57d9fc4a8133b
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>