[PATCH] libosmocore[master]: fix OSMO_VALUE_STRING macro: don't use OSMO_STRINGIFY()

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
Thu Mar 9 22:39:08 UTC 2017


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

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
---
M include/osmocom/core/utils.h
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/25/2025/1

diff --git a/include/osmocom/core/utils.h b/include/osmocom/core/utils.h
index d9c3097..63a73ab 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 <stdint.h>
 #include <stdio.h>

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I91ecfcef61be8cf73d59ea821cc4fd9d2ad5c9c7
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