Change in osmo-bsc[master]: Meas Tools: Avoid OSMO_ASSERT due to uninitialised 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/.

laforge gerrit-no-reply at lists.osmocom.org
Sun Mar 29 14:23:22 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/17647 )

Change subject: Meas Tools: Avoid OSMO_ASSERT due to uninitialised logging.
......................................................................

Meas Tools: Avoid OSMO_ASSERT due to uninitialised logging.

The measurement tools use libosmocore socket functions that will
use logging if the socket cannot be opened, but the tools did
not initialise logging, resulting in

 Assert failed osmo_log_info logging.c:235
 backtrace() returned 9 addresses
 [.....]

Initialise logging so that we get a nicer and more informative
message, such as:

 unable to bind socket:(null):8888: Address already in use
 no suitable addr found for: (null):8888

Change-Id: Ib3b3558723682defcee22e7ea2d8bf5c2cff1278
---
M src/utils/meas_json.c
M src/utils/meas_vis.c
2 files changed, 29 insertions(+), 0 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/utils/meas_json.c b/src/utils/meas_json.c
index a3526de..6aa531a 100644
--- a/src/utils/meas_json.c
+++ b/src/utils/meas_json.c
@@ -34,6 +34,7 @@
 #include <osmocom/core/socket.h>
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/select.h>
+#include <osmocom/core/application.h>
 
 #include <osmocom/gsm/gsm_utils.h>
 
@@ -171,8 +172,21 @@
 	return 0;
 }
 
+/* default categories */
+static struct log_info_cat default_categories[] = {
+};
+
+static const struct log_info meas_json_log_info = {
+	.cat = default_categories,
+	.num_cat = ARRAY_SIZE(default_categories),
+};
+
 int main(int argc, char **argv)
 {
+
+	void *tall_ctx = talloc_named_const(NULL, 0, "meas_json");
+	osmo_init_logging2(tall_ctx, &meas_json_log_info);
+
 	int rc;
 	struct osmo_fd udp_ofd;
 
diff --git a/src/utils/meas_vis.c b/src/utils/meas_vis.c
index cba08f5..aea12bf 100644
--- a/src/utils/meas_vis.c
+++ b/src/utils/meas_vis.c
@@ -13,6 +13,8 @@
 #include <osmocom/core/msgb.h>
 #include <osmocom/core/select.h>
 #include <osmocom/core/talloc.h>
+#include <osmocom/core/logging.h>
+#include <osmocom/core/application.h>
 
 #include <osmocom/gsm/gsm_utils.h>
 
@@ -258,11 +260,24 @@
 	{ 0, NULL }
 };
 
+/* default categories */
+static struct log_info_cat default_categories[] = {
+};
+
+static const struct log_info meas_vis_log_info = {
+	.cat = default_categories,
+	.num_cat = ARRAY_SIZE(default_categories),
+};
+
 int main(int argc, char **argv)
 {
 	int rc;
 	char *header[1];
 	char *title[1];
+	struct log_target *stderr_target;
+
+	void *tall_ctx = talloc_named_const(NULL, 0, "meas_vis");
+	osmo_init_logging2(tall_ctx, &meas_vis_log_info);
 
 	msgb_talloc_ctx_init(NULL, 0);
 

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ib3b3558723682defcee22e7ea2d8bf5c2cff1278
Gerrit-Change-Number: 17647
Gerrit-PatchSet: 5
Gerrit-Owner: keith <keith at rhizomatica.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: keith <keith at rhizomatica.org>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200329/6ac87d04/attachment.htm>


More information about the gerrit-log mailing list