[PATCH] libosmocore[master]: Catch repeated calls to osmo_init_logging()

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

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Oct 29 09:39:27 UTC 2017


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

Catch repeated calls to osmo_init_logging()

If an application calls osmo_init_logging() multiple times, let's
bail out in a safe way without corrupting the state + returning an
error.

Change-Id: Icf337a430fb367bbca48a1b02822a2cb3b644e5f
---
M src/application.c
1 file changed, 6 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/62/4562/1

diff --git a/src/application.c b/src/application.c
index ee22639..538ac45 100644
--- a/src/application.c
+++ b/src/application.c
@@ -112,6 +112,12 @@
  */
 int osmo_init_logging(const struct log_info *log_info)
 {
+	static int logging_initialized = 0;
+
+	if (logging_initialized)
+		return -EEXIST;
+
+	logging_initialized = 1;
 	log_init(log_info, NULL);
 	osmo_stderr_target = log_target_create_stderr();
 	if (!osmo_stderr_target)

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Icf337a430fb367bbca48a1b02822a2cb3b644e5f
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>



More information about the gerrit-log mailing list