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
Wed Dec 19 23:23:15 UTC 2018


Neels Hofmeyr has uploaded this change for review. ( 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(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/85/12385/1

diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h
index 0b02e9a..5b43e56 100644
--- a/include/osmocom/core/fsm.h
+++ b/include/osmocom/core/fsm.h
@@ -138,11 +138,11 @@
  * \param args  String format 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  String format 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  String format 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: newchange
Gerrit-Change-Id: I9eaf8b7e2cf1e450ae626cb2fc928862008f6233
Gerrit-Change-Number: 12385
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181219/396ccc4b/attachment.htm>


More information about the gerrit-log mailing list