[PATCH] libosmocore[master]: utils.h: add OSMO_ENUM_VAL_TO_VALUE_STRING macro

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
Fri Dec 16 12:45:08 UTC 2016


Review at  https://gerrit.osmocom.org/1440

utils.h: add OSMO_ENUM_VAL_TO_VALUE_STRING macro

Replace a similar macro def in fsm.c

Change-Id: I857af45ae602bb9a647ba26cf8b0d1b23403b54c
---
M include/osmocom/core/utils.h
M src/fsm.c
2 files changed, 7 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/40/1440/1

diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index 3c6fc98..64ba381 100644
--- a/include/osmocom/core/utils.h
+++ b/include/osmocom/core/utils.h
@@ -15,6 +15,8 @@
 #define OSMO_MAX(a, b) ((a) >= (b) ? (a) : (b))
 /*! \brief Return the minimum of two specified values */
 #define OSMO_MIN(a, b) ((a) >= (b) ? (b) : (a))
+/*! \brief Make a value_string entry from an enum value name */
+#define OSMO_ENUM_VAL_TO_VALUE_STRING(x) { x, #x }
 
 #include <stdint.h>
 
diff --git a/src/fsm.c b/src/fsm.c
index d251cfd..ed57fde 100644
--- a/src/fsm.c
+++ b/src/fsm.c
@@ -457,14 +457,12 @@
 					file, line);
 }
 
-#define ENUM_VAL_TO_VALUE_STRING(X) { X, #X }
-
 const struct value_string osmo_fsm_term_cause_names[] = {
-	ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_PARENT),
-	ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_REQUEST),
-	ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_REGULAR),
-	ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_ERROR),
-	ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_TIMEOUT),
+	OSMO_ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_PARENT),
+	OSMO_ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_REQUEST),
+	OSMO_ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_REGULAR),
+	OSMO_ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_ERROR),
+	OSMO_ENUM_VAL_TO_VALUE_STRING(OSMO_FSM_TERM_TIMEOUT),
 	{ 0, NULL }
 };
 

-- 
To view, visit https://gerrit.osmocom.org/1440
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I857af45ae602bb9a647ba26cf8b0d1b23403b54c
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list