core: fix pointer access in msgb_l[1-4] macros
Put the 'm' pointer into braces, so that it's possible to pass an
expression to these macros, e.g. a pointer-to-pointer dereference.
This patch makes the following example compile:
struct msgb **msg = /* ... */;
return msgb_l2(*msg); /* <-- currently this fails */
Currently it fails with the following error:
error: ‘msg’ is a pointer to pointer; did you mean to
dereference it before applying ‘->’ to it?
Change-Id: I2d19ea3c09ff9499314255d408fb71c07148fe25
diff --git a/include/osmocom/core/msgb.h b/include/osmocom/core/msgb.h
index 2529c0e..5c58c84 100644
--- a/include/osmocom/core/msgb.h
+++ b/include/osmocom/core/msgb.h
@@ -127,13 +127,13 @@
#endif
/*! obtain L1 header of msgb */
-#define msgb_l1(m) ((void *)(m->l1h))
+#define msgb_l1(m) ((void *)((m)->l1h))
/*! obtain L2 header of msgb */
-#define msgb_l2(m) ((void *)(m->l2h))
+#define msgb_l2(m) ((void *)((m)->l2h))
/*! obtain L3 header of msgb */
-#define msgb_l3(m) ((void *)(m->l3h))
+#define msgb_l3(m) ((void *)((m)->l3h))
/*! obtain L4 header of msgb */
-#define msgb_l4(m) ((void *)(m->l4h))
+#define msgb_l4(m) ((void *)((m)->l4h))
/*! obtain SMS header of msgb */
#define msgb_sms(m) msgb_l4(m)