Change in osmo-remsim[master]: share debug.[ch] across all executables

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
Thu Mar 7 20:37:46 UTC 2019


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/13176 )

Change subject: share debug.[ch] across all executables
......................................................................

share debug.[ch] across all executables

This avoids us having to re-define log_info/log_info_cat for each
program.

Change-Id: I22f4f8a51b91ee09c5be26b1ed1bfca41730c577
---
M src/Makefile.am
M src/bankd_main.c
A src/debug.c
M src/debug.h
M src/remsim_client.c
M src/simtrace2-remsim_client.c
6 files changed, 24 insertions(+), 42 deletions(-)

Approvals:
  Jenkins Builder: Verified
  Harald Welte: Looks good to me, approved



diff --git a/src/Makefile.am b/src/Makefile.am
index ca799ce..5f0d846 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -25,15 +25,15 @@
 pcsc_test_LDADD = $(OSMOCORE_LIBS) \
 		  $(PCSC_LIBS) libosmo-rspro.la
 
-remsim_bankd_SOURCES = bankd_slotmap.c bankd_main.c bankd_pcsc.c
+remsim_bankd_SOURCES = bankd_slotmap.c bankd_main.c bankd_pcsc.c debug.c
 remsim_bankd_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) \
 		     $(PCSC_LIBS) libosmo-rspro.la -lcsv
 
-remsim_client_SOURCES = remsim_client.c remsim_client_fsm.c
+remsim_client_SOURCES = remsim_client.c remsim_client_fsm.c debug.c
 remsim_client_LDADD = $(OSMOCORE_LIBS) $(OSMOGSM_LIBS) $(OSMOABIS_LIBS) \
 		     libosmo-rspro.la
 
-simtrace2_remsim_client_SOURCES = simtrace2-remsim_client.c remsim_client_fsm.c \
+simtrace2_remsim_client_SOURCES = simtrace2-remsim_client.c remsim_client_fsm.c debug.c \
 				  simtrace2/apdu_dispatch.c \
 				  simtrace2/simtrace2-discovery.c \
 				  simtrace2/libusb_util.c
diff --git a/src/bankd_main.c b/src/bankd_main.c
index 5e94afb..fde03cd 100644
--- a/src/bankd_main.c
+++ b/src/bankd_main.c
@@ -26,6 +26,7 @@
 #include <osmocom/rspro/RsproPDU.h>
 
 #include "bankd.h"
+#include "debug.h"
 #include "rspro_util.h"
 
 __thread void *talloc_asn1_ctx;
@@ -36,19 +37,6 @@
 * bankd core / main thread
 ***********************************************************************/
 
-static const struct log_info_cat default_categories[] = {
-	[DMAIN] = {
-		.name = "DMAIN",
-		.loglevel = LOGL_DEBUG,
-		.enabled = 1,
-	},
-};
-
-static const struct log_info log_info = {
-	.cat = default_categories,
-	.num_cat = ARRAY_SIZE(default_categories),
-};
-
 int asn_debug;
 
 static void bankd_init(struct bankd *bankd)
diff --git a/src/debug.c b/src/debug.c
new file mode 100644
index 0000000..046dc8c
--- /dev/null
+++ b/src/debug.c
@@ -0,0 +1,16 @@
+#include <osmocom/core/logging.h>
+#include <osmocom/core/utils.h>
+#include "debug.h"
+
+static const struct log_info_cat default_categories[] = {
+	[DMAIN] = {
+		.name = "DMAIN",
+		.loglevel = LOGL_DEBUG,
+		.enabled = 1,
+	},
+};
+
+const struct log_info log_info = {
+	.cat = default_categories,
+	.num_cat = ARRAY_SIZE(default_categories),
+};
diff --git a/src/debug.h b/src/debug.h
index 187d895..02551eb 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -3,3 +3,5 @@
 enum {
 	DMAIN,
 };
+
+extern const struct log_info log_info;
diff --git a/src/remsim_client.c b/src/remsim_client.c
index 2f740d4..0c2dcbe 100644
--- a/src/remsim_client.c
+++ b/src/remsim_client.c
@@ -15,6 +15,7 @@
 
 #include "rspro_util.h"
 #include "client.h"
+#include "debug.h"
 
 static int bankd_handle_msg(struct bankd_client *bc, struct msgb *msg)
 {
@@ -68,19 +69,6 @@
 	return -1;
 }
 
-static const struct log_info_cat default_categories[] = {
-	[DMAIN] = {
-		.name = "DMAIN",
-		.loglevel = LOGL_DEBUG,
-		.enabled = 1,
-	},
-};
-
-static const struct log_info log_info = {
-	.cat = default_categories,
-	.num_cat = ARRAY_SIZE(default_categories),
-};
-
 static struct bankd_client *g_client;
 static void *g_tall_ctx;
 void __thread *talloc_asn1_ctx;
diff --git a/src/simtrace2-remsim_client.c b/src/simtrace2-remsim_client.c
index 79da419..0832300 100644
--- a/src/simtrace2-remsim_client.c
+++ b/src/simtrace2-remsim_client.c
@@ -15,6 +15,7 @@
 
 #include "rspro_util.h"
 #include "client.h"
+#include "debug.h"
 
 #include <unistd.h>
 #include <stdio.h>
@@ -619,19 +620,6 @@
 }
 
 
-static const struct log_info_cat default_categories[] = {
-	[DMAIN] = {
-		.name = "DMAIN",
-		.loglevel = LOGL_DEBUG,
-		.enabled = 1,
-	},
-};
-
-static const struct log_info log_info = {
-	.cat = default_categories,
-	.num_cat = ARRAY_SIZE(default_categories),
-};
-
 static void print_welcome(void)
 {
 	printf("simtrace2-remsim-client - Remote SIM card client for SIMtrace\n"

-- 
To view, visit https://gerrit.osmocom.org/13176
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I22f4f8a51b91ee09c5be26b1ed1bfca41730c577
Gerrit-Change-Number: 13176
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190307/69599793/attachment.htm>


More information about the gerrit-log mailing list