[PATCH] libosmocore[master]: fix logging: out-of-bounds check should end with user catego...

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
Mon Dec 12 15:36:37 UTC 2016


Hello Jenkins Builder,

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

    https://gerrit.osmocom.org/1419

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

fix logging: out-of-bounds check should end with user categories

To check category bounds, rather use num_cat_user, to redirect all semantically
unknown categories to DLGLOBAL.

Adjust logging_test expectations accordingly: "(d)" is now also shown.

Change-Id: I4a952b759f30d90fbfb81fedcfc56a8092ea18c1
---
M src/logging.c
M tests/logging/logging_test.err
2 files changed, 4 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/19/1419/2

diff --git a/src/logging.c b/src/logging.c
index 2a8bfdc..6e0056b 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -336,6 +336,9 @@
  * which should never happen unless even the DLGLOBAL category is missing. */
 static inline int map_subsys(int subsys)
 {
+	if (subsys >= osmo_log_info->num_cat_user)
+		subsys = DLGLOBAL;
+
 	if (subsys < 0)
 		subsys = subsys_lib2index(subsys);
 
diff --git a/tests/logging/logging_test.err b/tests/logging/logging_test.err
index f4e9c1f..4527d83 100644
--- a/tests/logging/logging_test.err
+++ b/tests/logging/logging_test.err
@@ -4,4 +4,5 @@
 DLGLOBAL You should see this on DLGLOBAL (a)
 DLGLOBAL You should see this on DLGLOBAL (b)
 DLGLOBAL You should see this on DLGLOBAL (c)
+DLGLOBAL You should see this on DLGLOBAL (d)
 DLGLOBAL You should see this on DLGLOBAL (e)

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

Gerrit-MessageType: newpatchset
Gerrit-Change-Id: I4a952b759f30d90fbfb81fedcfc56a8092ea18c1
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list