From patchwork Wed Sep 21 07:23:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 16698 X-Patchwork-Delegate: sven@narfation.org Return-Path: X-Original-To: patchwork@open-mesh.org Delivered-To: patchwork@open-mesh.org Received: from open-mesh.org (localhost [IPv6:::1]) by open-mesh.org (Postfix) with ESMTP id 2C13A81C50; Wed, 21 Sep 2016 09:23:56 +0200 (CEST) Authentication-Results: open-mesh.org; dmarc=none header.from=narfation.org Authentication-Results: open-mesh.org; dkim=fail reason="verification failed; unprotected key" header.d=narfation.org header.i=@narfation.org header.b=Eb7aD1kE; dkim-adsp=fail (unprotected policy); dkim-atps=neutral Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2001:4d88:2000:7::2; helo=v3-1039.vlinux.de; envelope-from=sven@narfation.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Authentication-Results: open-mesh.org; dmarc=pass header.from=narfation.org Received: from v3-1039.vlinux.de (narfation.org [IPv6:2001:4d88:2000:7::2]) by open-mesh.org (Postfix) with ESMTPS id 95B9281A2F for ; Wed, 21 Sep 2016 09:23:54 +0200 (CEST) Received: from sven-desktop.home.narfation.org (p200300C593C1EFFD4D8048FF3B6092CB.dip0.t-ipconnect.de [IPv6:2003:c5:93c1:effd:4d80:48ff:3b60:92cb]) by v3-1039.vlinux.de (Postfix) with ESMTPSA id 115311100CF; Wed, 21 Sep 2016 09:23:54 +0200 (CEST) Authentication-Results: v3-1039.vlinux.de; dmarc=none header.from=narfation.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=narfation.org; s=20121; t=1474442634; bh=1cTrDPIs3leoUtsZL9RUr1OBu6Keo+TuwsI3GESOA+M=; h=From:To:Cc:Subject:Date:From; b=Eb7aD1kEz8KLcJLCiBkspB1WGQf89TNlNEzuJxR1koI/cCppdIp478GZpvaCMmW5t Ju7rSQalmx0aXkUC1o2MnlooDf8Xp8VgpI3huAhecWERtCM1IkKkgMcS8cYqh9ndiL fEofzEPWMJMDEz2AtmpMDIWrMhhbWcQ82Bg10Dzg= From: Sven Eckelmann To: b.a.t.m.a.n@lists.open-mesh.org Date: Wed, 21 Sep 2016 09:23:50 +0200 Message-Id: <20160921072350.13823-1-sven@narfation.org> X-Mailer: git-send-email 2.9.3 Subject: [B.A.T.M.A.N.] [PATCH] batman-adv: Avoid precedence issues in macros X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking Errors-To: b.a.t.m.a.n-bounces@lists.open-mesh.org Sender: "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 --- 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 #include -#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