summaryrefslogtreecommitdiffstats
path: root/include/osmocom/core
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-12-20 00:03:59 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2019-01-03 00:11:49 +0100
commitb0b39af1bc04b173575b8e2d6b717abc8daad32a (patch)
treef97d5aeb609a6a43b7950800c2591bb681eed4d3 /include/osmocom/core
parentb11ff7c5375f55b23e75129ba123fe7d1d07aa5e (diff)
LOGPFSM*: guard against fi == NULL
The LOGPFSM macros are in such wide use that they should guard against a NULL fi pointer. In case of NULL, default to subsys = DLGLOBAL, loglevel = LOGL_ERROR and state = "fi=NULL". Change-Id: I9eaf8b7e2cf1e450ae626cb2fc928862008f6233
Diffstat (limited to 'include/osmocom/core')
-rw-r--r--include/osmocom/core/fsm.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h
index 8db8cce3..f1080cde 100644
--- a/include/osmocom/core/fsm.h
+++ b/include/osmocom/core/fsm.h
@@ -138,11 +138,11 @@ void osmo_fsm_log_addr(bool log_addr);
* \param args Format string arguments.
*/
#define LOGPFSMLSRC(fi, level, caller_file, caller_line, fmt, args...) \
- LOGPSRC((fi)->fsm->log_subsys, level, \
+ LOGPSRC((fi) ? (fi)->fsm->log_subsys : DLGLOBAL, level, \
caller_file, caller_line, \
"%s{%s}: " fmt, \
osmo_fsm_inst_name(fi), \
- osmo_fsm_state_name((fi)->fsm, (fi)->state), \
+ (fi) ? osmo_fsm_state_name((fi)->fsm, (fi)->state) : "fi=NULL", \
## args)
/*! Log using FSM instance's context.
@@ -153,7 +153,7 @@ void osmo_fsm_log_addr(bool log_addr);
* \param args Format string arguments.
*/
#define LOGPFSM(fi, fmt, args...) \
- LOGPFSML(fi, (fi)->log_level, fmt, ## args)
+ LOGPFSML(fi, (fi) ? (fi)->log_level : LOGL_ERROR, fmt, ## args)
/*! Log using FSM instance's context, with explicit source file and line info.
* The log level to log on is obtained from the FSM instance.
@@ -165,7 +165,7 @@ void osmo_fsm_log_addr(bool log_addr);
* \param args Format string arguments.
*/
#define LOGPFSMSRC(fi, caller_file, caller_line, fmt, args...) \
- LOGPFSMLSRC(fi, (fi)->log_level, \
+ LOGPFSMLSRC(fi, (fi) ? (fi)->log_level : LOGL_ERROR, \
caller_file, caller_line, \
fmt, ## args)