[PATCH] libosmocore[master]: fsm: Update the name as well if the id is updated and accept...

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/.

daniel gerrit-no-reply at lists.osmocom.org
Wed Mar 14 17:36:47 UTC 2018


Review at  https://gerrit.osmocom.org/7286

fsm: Update the name as well if the id is updated and accept NULL

If the name stays the same the log messages will still log with the old
id. Since we can now change the id we need to update the name as well.

NULL as id was allowed before so we should allow that as well.

Change-Id: I6b01eb10b8a05fee3e4a5cdefdcf3ce9f79545b4
---
M src/fsm.c
1 file changed, 22 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/86/7286/1

diff --git a/src/fsm.c b/src/fsm.c
index 342542f..5dc7bf4 100644
--- a/src/fsm.c
+++ b/src/fsm.c
@@ -214,9 +214,30 @@
 		}
 		osmo_talloc_replace_string(fi, (char **)&fi->id, id);
 
+		if (fi->name)
+			talloc_free(fi->name);
+
+		if (!fsm_log_addr) {
+			fi->name = talloc_asprintf(fi, "%s(%s)", fi->fsm->name, id);
+		} else {
+			fi->name = talloc_asprintf(fi, "%s(%s)[%p]", fi->fsm->name, fi);
+		}
+
 		return 0;
 	}
-	return -EINVAL;
+
+	if (fi->id)
+		talloc_free(fi->id);
+	fi->id = NULL;
+	if (fi->name)
+		talloc_free(fi->name);
+
+	if (!fsm_log_addr) {
+		fi->name = talloc_asprintf(fi, "%s", fi->fsm->name);
+	} else {
+		fi->name = talloc_asprintf(fi, "%s[%p]", fi->fsm->name, fi);
+	}
+	return 0;
 }
 
 /*! allocate a new instance of a specified FSM
@@ -242,19 +263,6 @@
 				talloc_free(fi);
 				return NULL;
 		}
-	}
-
-	if (!fsm_log_addr) {
-		if (id)
-			fi->name = talloc_asprintf(fi, "%s(%s)", fsm->name, id);
-		else
-			fi->name = talloc_asprintf(fi, "%s", fsm->name);
-	} else {
-		if (id)
-			fi->name = talloc_asprintf(fi, "%s(%s)[%p]", fsm->name,
-						   id, fi);
-		else
-			fi->name = talloc_asprintf(fi, "%s[%p]", fsm->name, fi);
 	}
 
 	INIT_LLIST_HEAD(&fi->proc.children);

-- 
To view, visit https://gerrit.osmocom.org/7286
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6b01eb10b8a05fee3e4a5cdefdcf3ce9f79545b4
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: daniel <dwillmann at sysmocom.de>



More information about the gerrit-log mailing list