All of lore.kernel.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH] batman-adv: Avoid precedence issues in macros
@ 2016-09-21  7:23 Sven Eckelmann
  2016-10-18 12:48 ` [B.A.T.M.A.N.] " Sven Eckelmann
  0 siblings, 1 reply; 2+ messages in thread
From: Sven Eckelmann @ 2016-09-21  7:23 UTC (permalink / raw)
  To: b.a.t.m.a.n

It must be avoided that arguments to a macro are evaluated ungrouped (which
enforces normal operator precendence). Otherwise the result of the macro
is not well defined.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 net/batman-adv/log.h    | 12 ++++++------
 net/batman-adv/main.h   |  4 ++--
 net/batman-adv/packet.h |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/net/batman-adv/log.h b/net/batman-adv/log.h
index e0e1a88..ab47acf 100644
--- a/net/batman-adv/log.h
+++ b/net/batman-adv/log.h
@@ -71,12 +71,12 @@ int batadv_debug_log(struct batadv_priv *bat_priv, const char *fmt, ...)
 __printf(2, 3);
 
 /* possibly ratelimited debug output */
-#define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...)	\
-	do {							\
-		if (atomic_read(&bat_priv->log_level) & type && \
-		    (!ratelimited || net_ratelimit()))		\
-			batadv_debug_log(bat_priv, fmt, ## arg);\
-	}							\
+#define _batadv_dbg(type, bat_priv, ratelimited, fmt, arg...)		\
+	do {								\
+		if (atomic_read(&(bat_priv)->log_level) & (type) &&	\
+		    (!(ratelimited) || net_ratelimit()))		\
+			batadv_debug_log(bat_priv, fmt, ## arg);	\
+	}								\
 	while (0)
 #else /* !CONFIG_BATMAN_ADV_DEBUG */
 __printf(4, 5)
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h
index 09af21e..07a6e19 100644
--- a/net/batman-adv/main.h
+++ b/net/batman-adv/main.h
@@ -200,8 +200,8 @@ struct packet_type;
 struct seq_file;
 struct sk_buff;
 
-#define BATADV_PRINT_VID(vid) ((vid & BATADV_VLAN_HAS_TAG) ? \
-			       (int)(vid & VLAN_VID_MASK) : -1)
+#define BATADV_PRINT_VID(vid) (((vid) & BATADV_VLAN_HAS_TAG) ? \
+			       (int)((vid) & VLAN_VID_MASK) : -1)
 
 extern struct list_head batadv_hardif_list;
 
diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h
index 6afc0b8..4265eba 100644
--- a/net/batman-adv/packet.h
+++ b/net/batman-adv/packet.h
@@ -21,7 +21,7 @@
 #include <asm/byteorder.h>
 #include <linux/types.h>
 
-#define batadv_tp_is_error(n) ((u8)n > 127 ? 1 : 0)
+#define batadv_tp_is_error(n) ((u8)(n) > 127 ? 1 : 0)
 
 /**
  * enum batadv_packettype - types for batman-adv encapsulated packets
-- 
2.9.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [B.A.T.M.A.N.] batman-adv: Avoid precedence issues in macros
  2016-09-21  7:23 [B.A.T.M.A.N.] [PATCH] batman-adv: Avoid precedence issues in macros Sven Eckelmann
@ 2016-10-18 12:48 ` Sven Eckelmann
  0 siblings, 0 replies; 2+ messages in thread
From: Sven Eckelmann @ 2016-10-18 12:48 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: text/plain, Size: 647 bytes --]

On Mittwoch, 21. September 2016 09:23:50 CEST Sven Eckelmann wrote:
> It must be avoided that arguments to a macro are evaluated ungrouped (which
> enforces normal operator precendence). Otherwise the result of the macro
> is not well defined.
> 
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
>  net/batman-adv/log.h    | 12 ++++++------
>  net/batman-adv/main.h   |  4 ++--
>  net/batman-adv/packet.h |  2 +-
>  3 files changed, 9 insertions(+), 9 deletions(-)

Applied in aaf289c83d63bfa43665bd76cd0b96658d2746b2 [1].

Kind regards,
	Sven

[1] https://git.open-mesh.org/batman-adv.git/commit/aaf289c83d63bfa43665bd76cd0b96658d2746b2

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 801 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-10-18 12:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-21  7:23 [B.A.T.M.A.N.] [PATCH] batman-adv: Avoid precedence issues in macros Sven Eckelmann
2016-10-18 12:48 ` [B.A.T.M.A.N.] " Sven Eckelmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.