Change in libosmocore[master]: LOGPFSM*: guard against fi == NULL

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
Thu Jan 3 00:31:07 UTC 2019


Neels Hofmeyr has submitted this change and it was merged. ( https://gerrit.osmocom.org/12385 )

Change subject: LOGPFSM*: guard against fi == NULL
......................................................................

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
---
M include/osmocom/core/fsm.h
1 file changed, 4 insertions(+), 4 deletions(-)

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



diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h
index 8db8cce..f1080cd 100644
--- a/include/osmocom/core/fsm.h
+++ b/include/osmocom/core/fsm.h
@@ -138,11 +138,11 @@
  * \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 @@
  * \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 @@
  * \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)
 

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I9eaf8b7e2cf1e450ae626cb2fc928862008f6233
Gerrit-Change-Number: 12385
Gerrit-PatchSet: 3
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-CC: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190103/1c647c27/attachment.htm>


More information about the gerrit-log mailing list