[MERGED] 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
Wed Mar 15 13:54:26 UTC 2017


Neels Hofmeyr has submitted this change and it was merged.

Change subject: fix OSMO_VALUE_STRING macro: don't use OSMO_STRINGIFY()
......................................................................


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(-)

Approvals:
  Max: Looks good to me, but someone else must approve
  Neels Hofmeyr: Looks good to me, approved
  Jenkins Builder: Verified
  Holger Freyther: Looks good to me, but someone else must approve



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: merged
Gerrit-Change-Id: I91ecfcef61be8cf73d59ea821cc4fd9d2ad5c9c7
Gerrit-PatchSet: 2
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Holger Freyther <holger at freyther.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list