cosmetic: osmo_fsm_inst_update_id(): don't log "allocate"

On erratic id in osmo_fsm_inst_update_id(), don't say "Attempting to allocate
FSM instance".

Escape the invalid id using osmo_quote_str().

Change-Id: I770fc460de21faa42b403f694e853e8da01c4bef
This commit is contained in:
Neels Hofmeyr 2018-04-09 02:28:34 +02:00
parent 71f76a1f42
commit 6e8c088472
2 changed files with 5 additions and 4 deletions

View File

@ -213,8 +213,9 @@ int osmo_fsm_inst_update_id(struct osmo_fsm_inst *fi, const char *id)
{
if (id) {
if (!osmo_identifier_valid(id)) {
LOGP(DLGLOBAL, LOGL_ERROR, "Attempting to allocate FSM instance of type '%s'"
" with illegal identifier '%s'\n", fi->fsm->name, id);
LOGP(DLGLOBAL, LOGL_ERROR,
"Attempting to set illegal id for FSM instance of type '%s': %s\n",
fi->fsm->name, osmo_quote_str(id, -1));
return -EINVAL;
}
osmo_talloc_replace_string(fi, (char **)&fi->id, id);

View File

@ -38,12 +38,12 @@ osmo_fsm_inst_update_id("arbitrary_id")
osmo_fsm_inst_find_by_name("Test_FSM(arbitrary_id)") == fi
osmo_fsm_inst_find_by_id("arbitrary_id") == fi
osmo_fsm_inst_update_id("")
Attempting to allocate FSM instance of type 'Test_FSM' with illegal identifier ''
Attempting to set illegal id for FSM instance of type 'Test_FSM': ""
 rc == -22, ok
osmo_fsm_inst_name() == "Test_FSM(arbitrary_id)"
osmo_fsm_inst_find_by_name("Test_FSM(arbitrary_id)") == fi
osmo_fsm_inst_update_id("invalid.id")
Attempting to allocate FSM instance of type 'Test_FSM' with illegal identifier 'invalid.id'
Attempting to set illegal id for FSM instance of type 'Test_FSM': "invalid.id"
 rc == -22, ok
osmo_fsm_inst_name() == "Test_FSM(arbitrary_id)"
osmo_fsm_inst_find_by_name("Test_FSM(arbitrary_id)") == fi