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.org
Review at https://gerrit.osmocom.org/1433
add value strings for enum osmo_fsm_term_cause and use for logging
Change-Id: Iaf63d3cadb0d46bf454e3314ebb439240cafd834
---
M include/osmocom/core/fsm.h
M src/fsm.c
2 files changed, 21 insertions(+), 1 deletion(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/33/1433/1
diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h
index 77072ef..72e6018 100644
--- a/include/osmocom/core/fsm.h
+++ b/include/osmocom/core/fsm.h
@@ -30,6 +30,9 @@
OSMO_FSM_TERM_TIMEOUT,
};
+extern const struct value_string osmo_fsm_term_cause_names[];
+const char *osmo_fsm_term_cause_name(enum osmo_fsm_term_cause cause);
+
/*! \brief description of a rule in the FSM */
struct osmo_fsm_state {
/*! \brief bit-mask of permitted input events for this state */
diff --git a/src/fsm.c b/src/fsm.c
index dc57e5e..034193c 100644
--- a/src/fsm.c
+++ b/src/fsm.c
@@ -431,7 +431,8 @@
struct osmo_fsm_inst *parent = fi->proc.parent;
uint32_t parent_term_event = fi->proc.parent_term_event;
- LOGPFSMSRC(fi, file, line, "Terminating (cause = %u)\n", cause);
+ LOGPFSMSRC(fi, file, line, "Terminating (cause = %s)\n",
+ osmo_fsm_term_cause_name(cause));
/* iterate over all children */
llist_for_each_entry_safe(child, child2, &fi->proc.children, proc.child) {
@@ -456,4 +457,20 @@
file, line);
}
+#define ENUM_VAL_TO_VALUE_STRING(X) { X, #X }
+
+const struct value_string osmo_fsm_term_cause_names[] = {
+ ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_PARENT),
+ ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_REQUEST),
+ ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_REGULAR),
+ ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_ERROR),
+ ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_TIMEOUT),
+ { 0, NULL }
+};
+
+const char *osmo_fsm_term_cause_name(enum osmo_fsm_term_cause cause)
+{
+ return get_value_string(osmo_fsm_term_cause_names, cause);
+}
+
/*! @} */
--
To view, visit https://gerrit.osmocom.org/1433
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf63d3cadb0d46bf454e3314ebb439240cafd834
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>