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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu Mar 15 19:00:36 UTC 2018


Hello Jenkins Builder,

I'd like you to reexamine a change.  Please visit

    https://gerrit.osmocom.org/7286

to look at the new patch set (#2).

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

diff --git a/src/fsm.c b/src/fsm.c
index 342542f..c5256da 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((void*)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, id, fi);
+		}
+
 		return 0;
 	}
-	return -EINVAL;
+
+	if (fi->id)
+		talloc_free((void*)fi->id);
+	fi->id = NULL;
+	if (fi->name)
+		talloc_free((void*)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: newpatchset
Gerrit-Change-Id: I6b01eb10b8a05fee3e4a5cdefdcf3ce9f79545b4
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list