From 8a5d60b996f0c653787baa9954a8b3d57f542324 Mon Sep 17 00:00:00 2001 From: Neels Hofmeyr Date: Thu, 9 Mar 2017 23:01:37 +0100 Subject: [PATCH] fix OSMO_VALUE_STRING macro: don't use OSMO_STRINGIFY() To be able to use OSMO_VALUE_STRING() on a #defined constant, don't use OSMO_STRINGIFY(): the second indirection resolves the #define to its value, so for example OSMO_VALUE_STRING(GSM48_PDISC_MM) would resolve to { 0x05, "0x05" } When using '#x' directly, this becomes the desired { 0x05, "GSM48_PDISC_MM" } With enum values as we've used until now, this problem does not appear, because enum values are not resolved by the preprocessor. Keep OSMO_STRINGIFY() because it is used directly in openbsc (composing FSM state names). Change-Id: I91ecfcef61be8cf73d59ea821cc4fd9d2ad5c9c7 --- include/osmocom/core/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h index d9c3097fb..63a73ab4e 100644 --- a/include/osmocom/core/utils.h +++ b/include/osmocom/core/utils.h @@ -18,7 +18,7 @@ /*! \brief Stringify the contents of a macro, e.g. a port number */ #define OSMO_STRINGIFY(x) #x /*! \brief Make a value_string entry from an enum value name */ -#define OSMO_VALUE_STRING(x) { x, OSMO_STRINGIFY(x) } +#define OSMO_VALUE_STRING(x) { x, #x } #include #include