Hoernchen has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmocore/+/30609 )
Change subject: logging: do not expose internal data structures
......................................................................
logging: do not expose internal data structures
The header declares a log_initialized(void) but there never was a
defintion (???!!) and instead of using the non existing function the
struct was just exposed and abused (???!?!)....
Change-Id: I2ba3506233ff485f3935b2f46c94d8351b5d283c
---
M include/osmocom/core/logging.h
M src/logging.c
2 files changed, 11 insertions(+), 6 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/09/30609/1
diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h
index 5ae38c7..f4201b1 100644
--- a/include/osmocom/core/logging.h
+++ b/include/osmocom/core/logging.h
@@ -11,8 +11,6 @@
#include <osmocom/core/defs.h>
#include <osmocom/core/linuxlist.h>
-extern struct log_info *osmo_log_info;
-
#ifndef DEBUG
#define DEBUG
#endif
@@ -34,6 +32,7 @@
#define DEBUGPC(ss, fmt, args...)
#endif
+int log_initialized(void);
void osmo_vlogp(int subsys, int level, const char *file, int line,
int cont, const char *format, va_list ap);
@@ -58,7 +57,7 @@
#ifndef LIBOSMOCORE_NO_LOGGING
#define LOGPC(ss, level, fmt, args...) \
do { \
- if (!osmo_log_info) { \
+ if (!log_initialized()) { \
logp_stub(__FILE__, __LINE__, 1, fmt, ##args); \
break; \
} \
@@ -100,7 +99,7 @@
#ifndef LIBOSMOCORE_NO_LOGGING
#define LOGPSRCC(ss, level, caller_file, caller_line, cont, fmt, args...) \
do { \
- if (!osmo_log_info) { \
+ if (!log_initialized()) { \
if (caller_file) \
logp_stub(caller_file, caller_line, cont, fmt, ##args); \
else \
@@ -399,7 +398,6 @@
__attribute__ ((format (printf, 6, 7)));
void logp_stub(const char *file, int line, int cont, const char *format, ...);
int log_init(const struct log_info *inf, void *talloc_ctx);
-int log_initialized(void);
void log_fini(void);
int log_check_level(int subsys, unsigned int level);
diff --git a/src/logging.c b/src/logging.c
index ce42e4c..7e360b7 100644
--- a/src/logging.c
+++ b/src/logging.c
@@ -84,7 +84,7 @@
osmo_static_assert(_LOG_FLT_COUNT <= 8*sizeof(((struct
log_target*)NULL)->filter_map),
enum_logging_filters_fit_in_log_target_filter_map);
-struct log_info *osmo_log_info;
+static struct log_info *osmo_log_info;
static struct log_context log_context;
void *tall_log_ctx = NULL;
@@ -1418,6 +1418,13 @@
return rc;
}
+/*! Check if the the Osmocom logging core is initialized
+ * \returns 1 in case this is true
+ */
+int log_initialized(void) {
+ return tall_log_ctx != NULL;
+}
+
/*! Initialize the Osmocom logging core
* \param[in] inf Information regarding logging categories, could be NULL
* \param[in] ctx talloc context for logging allocations
--
To view, visit
https://gerrit.osmocom.org/c/libosmocore/+/30609
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2ba3506233ff485f3935b2f46c94d8351b5d283c
Gerrit-Change-Number: 30609
Gerrit-PatchSet: 1
Gerrit-Owner: Hoernchen <ewild(a)sysmocom.de>
Gerrit-MessageType: newchange