From patchwork Thu Oct 27 19:01:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 687886 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3t4bqN5zdqz9s65 for ; Fri, 28 Oct 2016 06:02:24 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S942689AbcJ0TCS (ORCPT ); Thu, 27 Oct 2016 15:02:18 -0400 Received: from packetmixer.de ([79.140.42.25]:38349 "EHLO mail.mail.packetmixer.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964978AbcJ0TCB (ORCPT ); Thu, 27 Oct 2016 15:02:01 -0400 Received: from kero.packetmixer.de (p4FFE5DCC.dip0.t-ipconnect.de [79.254.93.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mail.packetmixer.de (Postfix) with ESMTPSA id 0E61D1F001E; Thu, 27 Oct 2016 21:02:01 +0200 (CEST) From: Simon Wunderlich To: davem@davemloft.net Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Sven Eckelmann , Simon Wunderlich Subject: [PATCH 17/17] batman-adv: Avoid precedence issues in macros Date: Thu, 27 Oct 2016 21:01:50 +0200 Message-Id: <20161027190150.7880-18-sw@simonwunderlich.de> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161027190150.7880-1-sw@simonwunderlich.de> References: <20161027190150.7880-1-sw@simonwunderlich.de> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Sven Eckelmann 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 Signed-off-by: Simon Wunderlich --- 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 6a2328d..daddca9 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h @@ -199,8 +199,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 d2e9bbd..7a36bcf 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