Review at https://gerrit.osmocom.org/7628
fsm: collapse an empty id to a NULL id, adjust api doc If the FSM instance id were passed as empty string, we would print "()" in the instance name. Instead, evaluate an empty id just like a NULL id. Describe that properly in the API docs. Change-Id: I9fa6e13ec1c2ab204b6229f4e3fa5f2c0d53a2ba --- M src/fsm.c 1 file changed, 5 insertions(+), 2 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/28/7628/1 diff --git a/src/fsm.c b/src/fsm.c index 0c943d4..56bb3d0 100644 --- a/src/fsm.c +++ b/src/fsm.c @@ -201,11 +201,14 @@ /*! Change id of the FSM instance * \param[in] fi FSM instance - * \param[in] id new ID + * \param[in] id new ID, or NULL/empty to clear the ID. * \returns 0 if the ID was updated, otherwise -EINVAL */ int osmo_fsm_inst_update_id(struct osmo_fsm_inst *fi, const char *id) { + if (id && !*id) + id = NULL; + if (id) { if (!osmo_identifier_valid(id)) { LOGP(DLGLOBAL, LOGL_ERROR, "Attempting to allocate FSM instance of type '%s'" @@ -245,7 +248,7 @@ * \param[in] ctx talloc context from which to allocate memory * \param[in] priv private data reference store in fsm instance * \param[in] log_level The log level for events of this FSM - * \param[in] id The name/ID of the FSM instance + * \param[in] id The name/ID of the FSM instance, or NULL/empty to use no ID. * \returns newly-allocated, initialized and registered FSM instance */ struct osmo_fsm_inst *osmo_fsm_inst_alloc(struct osmo_fsm *fsm, void *ctx, void *priv, -- To view, visit https://gerrit.osmocom.org/7628 To unsubscribe, visit https://gerrit.osmocom.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9fa6e13ec1c2ab204b6229f4e3fa5f2c0d53a2ba Gerrit-PatchSet: 1 Gerrit-Project: libosmocore Gerrit-Branch: master Gerrit-Owner: Neels Hofmeyr <nhofm...@sysmocom.de>