Change in osmo-ccid-firmware[master]: add the talloc ctx to struct ccid_instance

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

Hoernchen gerrit-no-reply at lists.osmocom.org
Thu Nov 28 16:32:05 UTC 2019


Hoernchen has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16318 )


Change subject: add the talloc ctx to struct ccid_instance
......................................................................

add the talloc ctx to struct ccid_instance

We need it anyway, and relying on global vars is ugly. I'd still like to
keep them for debug purposes tho.

Change-Id: I3b73e68d0347d74f68018614613fcc802f3fdfe7
---
M ccid_common/ccid_device.h
M ccid_common/ccid_slot_fsm.c
M ccid_host/ccid_main_functionfs.c
M sysmoOCTSIM/libosmo_emb.c
M sysmoOCTSIM/main.c
5 files changed, 9 insertions(+), 7 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-ccid-firmware refs/changes/18/16318/1

diff --git a/ccid_common/ccid_device.h b/ccid_common/ccid_device.h
index f364f72..d00bc54 100644
--- a/ccid_common/ccid_device.h
+++ b/ccid_common/ccid_device.h
@@ -105,6 +105,7 @@
 	/* array of permitted clock frequencies; length: bNumClockSupported */
 	const uint32_t *clock_freqs;
 	const char *name;
+	void *talloc_ctx;
 	/* user-supplied opaque data */
 	void *priv;
 };
diff --git a/ccid_common/ccid_slot_fsm.c b/ccid_common/ccid_slot_fsm.c
index 3a591d7..29bffa0 100644
--- a/ccid_common/ccid_slot_fsm.c
+++ b/ccid_common/ccid_slot_fsm.c
@@ -323,10 +323,9 @@
 	return 0;
 }
 
-extern void *g_tall_ctx;
 static int iso_fsm_slot_init(struct ccid_slot *cs)
 {
-	void *ctx = g_tall_ctx; /* FIXME */
+	void *ctx = cs->ci->talloc_ctx;
 	struct iso_fsm_slot *ss = ccid_slot2iso_fsm_slot(cs);
 	struct card_uart *cuart = talloc_zero(ctx, struct card_uart);
 	char id_buf[16] = "SIM0";
diff --git a/ccid_host/ccid_main_functionfs.c b/ccid_host/ccid_main_functionfs.c
index 8e95c73..cd53a09 100644
--- a/ccid_host/ccid_main_functionfs.c
+++ b/ccid_host/ccid_main_functionfs.c
@@ -526,6 +526,7 @@
 	tall_main_ctx = talloc_named_const(NULL, 0, "ccid_main_functionfs");
 	msgb_talloc_ctx_init(tall_main_ctx, 0);
 	osmo_init_logging2(tall_main_ctx, &log_info);
+	g_ci.talloc_ctx = tall_main_ctx;
 
 	signal(SIGUSR1, &signal_handler);
 
diff --git a/sysmoOCTSIM/libosmo_emb.c b/sysmoOCTSIM/libosmo_emb.c
index 81b29e3..40b7f5f 100644
--- a/sysmoOCTSIM/libosmo_emb.c
+++ b/sysmoOCTSIM/libosmo_emb.c
@@ -145,7 +145,7 @@
 	return target;
 }
 
-void libosmo_emb_init(void)
+void libosmo_emb_init(void* talloc_ctx)
 {
 	struct log_target *stderr_target;
 
@@ -156,7 +156,7 @@
 	msgb_talloc_ctx_init(g_msgb_ctx, 0);
 #endif
 	/* logging */
-	log_init(&log_info, g_tall_ctx);
+	log_init(&log_info, talloc_ctx);
 #ifdef ENABLE_DBG_UART7
 	stderr_target = log_target_create_stderr_raw();
 	log_add_target(stderr_target);
diff --git a/sysmoOCTSIM/main.c b/sysmoOCTSIM/main.c
index 07c5af8..4770868 100644
--- a/sysmoOCTSIM/main.c
+++ b/sysmoOCTSIM/main.c
@@ -325,13 +325,13 @@
 
 
 extern void testmode_init(void);
-extern void libosmo_emb_init(void);
+extern void libosmo_emb_init(void* talloc_ctx);
 extern void libosmo_emb_mainloop(void);
 
 #include "talloc.h"
 #include "logging.h"
 
-void *g_tall_ctx;
+static void *g_tall_ctx;
 
 
 /* Section 9.6 of SAMD5x/E5x Family Data Sheet */
@@ -491,11 +491,12 @@
 	talloc_enable_null_tracking();
 	g_tall_ctx = talloc_named_const(NULL, 0, "global");
 	printf("g_tall_ctx=%p\r\n", g_tall_ctx);
+	g_ci.talloc_ctx = g_tall_ctx;
 
 	//FIXME osmo_emb has a pool?
 	msgb_talloc_ctx_init(g_tall_ctx, 0);
 
-	libosmo_emb_init();
+	libosmo_emb_init(g_tall_ctx);
 
 	LOGP(DUSB, LOGL_ERROR, "foobar usb\n");
 

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ccid-firmware/+/16318
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ccid-firmware
Gerrit-Branch: master
Gerrit-Change-Id: I3b73e68d0347d74f68018614613fcc802f3fdfe7
Gerrit-Change-Number: 16318
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20191128/24a3eb4c/attachment.htm>


More information about the gerrit-log mailing list