Change in libosmocore[master]: use __FILE__, not __BASE_FILE__

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/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Aug 20 20:23:19 UTC 2018


Harald Welte has submitted this change and it was merged. ( https://gerrit.osmocom.org/10537 )

Change subject: use __FILE__, not __BASE_FILE__
......................................................................

use __FILE__, not __BASE_FILE__

The intention was to use the file's basename, but __BASE_FILE__ means "the root
file that is being parsed and contains #include statements".

If we had a function using __BASE_FILE__ and that was defined in an #included
file, __BASE_FILE__ would indicate the first file where the #include is, and
not the file where the function is defined. __BASE_FILE__ works for us because
we don't ever include function definitions that log something, so __BASE_FILE__
always coincides with __FILE__ for our logging; but still __BASE_FILE__ is
semantically the wrong constant.

Related: OS#2740
Change-Id: Ibc1d3746f1876ac42d6b1faf0e5f83bd2283cdcc
---
M include/osmocom/core/fsm.h
M include/osmocom/core/logging.h
M include/osmocom/core/utils.h
M include/osmocom/gsm/mncc.h
M src/gb/gprs_ns.c
5 files changed, 15 insertions(+), 15 deletions(-)

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



diff --git a/include/osmocom/core/fsm.h b/include/osmocom/core/fsm.h
index 9e1062f..54bbad5 100644
--- a/include/osmocom/core/fsm.h
+++ b/include/osmocom/core/fsm.h
@@ -178,7 +178,7 @@
  */
 #define osmo_fsm_inst_state_chg(fi, new_state, timeout_secs, T) \
 	_osmo_fsm_inst_state_chg(fi, new_state, timeout_secs, T, \
-				 __BASE_FILE__, __LINE__)
+				 __FILE__, __LINE__)
 int _osmo_fsm_inst_state_chg(struct osmo_fsm_inst *fi, uint32_t new_state,
 			     unsigned long timeout_secs, int T,
 			     const char *file, int line);
@@ -194,7 +194,7 @@
  */
 #define osmo_fsm_inst_state_chg_keep_timer(fi, new_state) \
 	_osmo_fsm_inst_state_chg_keep_timer(fi, new_state, \
-				 __BASE_FILE__, __LINE__)
+				 __FILE__, __LINE__)
 int _osmo_fsm_inst_state_chg_keep_timer(struct osmo_fsm_inst *fi, uint32_t new_state,
 					const char *file, int line);
 
@@ -205,7 +205,7 @@
  *  purposes. See there for documentation.
  */
 #define osmo_fsm_inst_dispatch(fi, event, data) \
-	_osmo_fsm_inst_dispatch(fi, event, data, __BASE_FILE__, __LINE__)
+	_osmo_fsm_inst_dispatch(fi, event, data, __FILE__, __LINE__)
 int _osmo_fsm_inst_dispatch(struct osmo_fsm_inst *fi, uint32_t event, void *data,
 			    const char *file, int line);
 
@@ -216,7 +216,7 @@
  *  See there for documentation.
  */
 #define osmo_fsm_inst_term(fi, cause, data) \
-	_osmo_fsm_inst_term(fi, cause, data, __BASE_FILE__, __LINE__)
+	_osmo_fsm_inst_term(fi, cause, data, __FILE__, __LINE__)
 void _osmo_fsm_inst_term(struct osmo_fsm_inst *fi,
 			 enum osmo_fsm_term_cause cause, void *data,
 			 const char *file, int line);
@@ -228,7 +228,7 @@
  *  purposes. See there for documentation.
  */
 #define osmo_fsm_inst_term_children(fi, cause, data) \
-	_osmo_fsm_inst_term_children(fi, cause, data, __BASE_FILE__, __LINE__)
+	_osmo_fsm_inst_term_children(fi, cause, data, __FILE__, __LINE__)
 void _osmo_fsm_inst_term_children(struct osmo_fsm_inst *fi,
 				  enum osmo_fsm_term_cause cause,
 				  void *data,
diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h
index e68f618..3cae63d 100644
--- a/include/osmocom/core/logging.h
+++ b/include/osmocom/core/logging.h
@@ -55,17 +55,17 @@
 #define LOGPC(ss, level, fmt, args...) \
 	do { \
 		if (log_check_level(ss, level)) \
-			logp2(ss, level, __BASE_FILE__, __LINE__, 1, fmt, ##args); \
+			logp2(ss, level, __FILE__, __LINE__, 1, fmt, ##args); \
 	} while(0)
 
 /*! Log through the Osmocom logging framework with explicit source.
- *  If caller_file is passed as NULL, __BASE_FILE__ and __LINE__ are used
+ *  If caller_file is passed as NULL, __FILE__ and __LINE__ are used
  *  instead of caller_file and caller_line (so that this macro here defines
  *  both cases in the same place, and to catch cases where callers fail to pass
  *  a non-null filename string).
  *  \param[in] ss logging subsystem (e.g. \ref DLGLOBAL)
  *  \param[in] level logging level (e.g. \ref LOGL_NOTICE)
- *  \param[in] caller_file caller's source file string (e.g. __BASE_FILE__)
+ *  \param[in] caller_file caller's source file string (e.g. __FILE__)
  *  \param[in] caller_line caller's source line nr (e.g. __LINE__)
  *  \param[in] fmt format string
  *  \param[in] args variable argument list
@@ -74,13 +74,13 @@
 	LOGPSRCC(ss, level, caller_file, caller_line, 0, fmt, ##args)
 
 /*! Log through the Osmocom logging framework with explicit source.
- *  If caller_file is passed as NULL, __BASE_FILE__ and __LINE__ are used
+ *  If caller_file is passed as NULL, __FILE__ and __LINE__ are used
  *  instead of caller_file and caller_line (so that this macro here defines
  *  both cases in the same place, and to catch cases where callers fail to pass
  *  a non-null filename string).
  *  \param[in] ss logging subsystem (e.g. \ref DLGLOBAL)
  *  \param[in] level logging level (e.g. \ref LOGL_NOTICE)
- *  \param[in] caller_file caller's source file string (e.g. __BASE_FILE__)
+ *  \param[in] caller_file caller's source file string (e.g. __FILE__)
  *  \param[in] caller_line caller's source line nr (e.g. __LINE__)
  *  \param[in] cont continuation (1) or new line (0)
  *  \param[in] fmt format string
@@ -92,7 +92,7 @@
 			if (caller_file) \
 				logp2(ss, level, caller_file, caller_line, cont, fmt, ##args); \
 			else \
-				logp2(ss, level, __BASE_FILE__, __LINE__, cont, fmt, ##args); \
+				logp2(ss, level, __FILE__, __LINE__, cont, fmt, ##args); \
 		}\
 	} while(0)
 
diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index dd4461c..e2d5134 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -78,7 +78,7 @@
  */
 #define OSMO_ASSERT(exp)    \
 	if (!(exp)) { \
-		osmo_panic("Assert failed %s %s:%d\n", #exp, __BASE_FILE__, __LINE__); \
+		osmo_panic("Assert failed %s %s:%d\n", #exp, __FILE__, __LINE__); \
 	}
 
 /*! duplicate a string using talloc and release its prior content (if any)
diff --git a/include/osmocom/gsm/mncc.h b/include/osmocom/gsm/mncc.h
index 6b94d46..7e7d12c 100644
--- a/include/osmocom/gsm/mncc.h
+++ b/include/osmocom/gsm/mncc.h
@@ -90,7 +90,7 @@
 		    const uint8_t *msg, unsigned int len);
 
 #define osmo_mncc_log(ss, level, prefix, msg, len)	\
-	_osmo_mncc_log(ss, level, __BASE_FILE__, __LINE__, prefix, msg, len);
+	_osmo_mncc_log(ss, level, __FILE__, __LINE__, prefix, msg, len);
 
 extern const struct value_string osmo_mncc_names[];
 static inline const char *osmo_mncc_name(uint32_t msg_type) {
diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 75c3141..9b7cc05 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -87,8 +87,8 @@
 
 #include "common_vty.h"
 
-#define ns_set_state(ns_, st_) ns_set_state_with_log(ns_, st_, false, __BASE_FILE__, __LINE__)
-#define ns_set_remote_state(ns_, st_) ns_set_state_with_log(ns_, st_, true, __BASE_FILE__, __LINE__)
+#define ns_set_state(ns_, st_) ns_set_state_with_log(ns_, st_, false, __FILE__, __LINE__)
+#define ns_set_remote_state(ns_, st_) ns_set_state_with_log(ns_, st_, true, __FILE__, __LINE__)
 #define ns_mark_blocked(ns_) ns_set_state(ns_, (ns_)->state | NSE_S_BLOCKED)
 #define ns_mark_unblocked(ns_) ns_set_state(ns_, (ns_)->state & (~NSE_S_BLOCKED));
 

-- 
To view, visit https://gerrit.osmocom.org/10537
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: Ibc1d3746f1876ac42d6b1faf0e5f83bd2283cdcc
Gerrit-Change-Number: 10537
Gerrit-PatchSet: 2
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180820/3d504660/attachment.htm>


More information about the gerrit-log mailing list