Change in osmo-remsim[master]: slotmap: Log file/line when changing state

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
Thu Mar 7 20:37:04 UTC 2019


Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/13184


Change subject: slotmap: Log file/line when changing state
......................................................................

slotmap: Log file/line when changing state

Change-Id: Idc7b350b464ddc50076f92dae592a0d5ad4d486a
---
M src/debug.h
M src/slotmap.c
M src/slotmap.h
3 files changed, 17 insertions(+), 14 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/84/13184/1

diff --git a/src/debug.h b/src/debug.h
index 02551eb..e3994b4 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -1,4 +1,5 @@
 #pragma once
+#include <osmocom/core/logging.h>
 
 enum {
 	DMAIN,
diff --git a/src/slotmap.c b/src/slotmap.c
index aa03638..f4a22e1 100644
--- a/src/slotmap.c
+++ b/src/slotmap.c
@@ -12,6 +12,7 @@
 #include <osmocom/core/utils.h>
 
 #include "slotmap.h"
+#include "debug.h"
 
 const struct value_string slot_map_state_name[] = {
 	{ SLMAP_S_NEW,			"NEW" },
@@ -148,33 +149,30 @@
 
 #ifdef REMSIM_SERVER
 
-void _slotmap_state_change(struct slot_mapping *map, enum slot_mapping_state new_state,
-			   struct llist_head *new_bank_list)
+void _Slotmap_state_change(struct slot_mapping *map, enum slot_mapping_state new_state,
+			   struct llist_head *new_bank_list, const char *file, int line)
 {
 	char mapname[64];
 
-	printf("Slot Map %s state change: %s -> %s\n", slotmap_name(mapname, sizeof(mapname), map),
+	LOGPSRC(DMAIN, LOGL_INFO, file, line, "Slot Map %s state change: %s -> %s\n",
+		slotmap_name(mapname, sizeof(mapname), map),
 		get_value_string(slot_map_state_name, map->state),
 		get_value_string(slot_map_state_name, new_state));
 
 	map->state = new_state;
-#ifdef REMSIM_SERVER
 	llist_del(&map->bank_list);
-#endif
 	if (new_bank_list)
 		llist_add_tail(&map->bank_list, new_bank_list);
-#ifdef REMSIM_SERVER
 	else
 		INIT_LLIST_HEAD(&map->bank_list);
-#endif
 }
 
 
-void slotmap_state_change(struct slot_mapping *map, enum slot_mapping_state new_state,
-			  struct llist_head *new_bank_list)
+void Slotmap_state_change(struct slot_mapping *map, enum slot_mapping_state new_state,
+			  struct llist_head *new_bank_list, const char *file, int line)
 {
 	pthread_rwlock_wrlock(&map->maps->rwlock);
-	_slotmap_state_change(map, new_state, new_bank_list);
+	_Slotmap_state_change(map, new_state, new_bank_list, file, line);
 	pthread_rwlock_unlock(&map->maps->rwlock);
 }
 
diff --git a/src/slotmap.h b/src/slotmap.h
index 3eb976f..bc55f29 100644
--- a/src/slotmap.h
+++ b/src/slotmap.h
@@ -87,9 +87,13 @@
 struct slotmaps *slotmap_init(void *ctx);
 
 #ifdef REMSIM_SERVER
-void _slotmap_state_change(struct slot_mapping *map, enum slot_mapping_state new_state,
-			   struct llist_head *new_bank_list);
+void _Slotmap_state_change(struct slot_mapping *map, enum slot_mapping_state new_state,
+			   struct llist_head *new_bank_list, const char *file, int line);
 /* thread-safe way to change the state of given slot map */
-void slotmap_state_change(struct slot_mapping *map, enum slot_mapping_state new_state,
-			  struct llist_head *new_bank_list);
+void Slotmap_state_change(struct slot_mapping *map, enum slot_mapping_state new_state,
+			  struct llist_head *new_bank_list, const char *file, int line);
+#define _slotmap_state_change(map, state, list)				\
+	_Slotmap_state_change(map, state, list, __FILE__, __LINE__)
+#define slotmap_state_change(map, state, list)				\
+	Slotmap_state_change(map, state, list, __FILE__, __LINE__)
 #endif

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

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idc7b350b464ddc50076f92dae592a0d5ad4d486a
Gerrit-Change-Number: 13184
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190307/1ab1e631/attachment.htm>


More information about the gerrit-log mailing list