From patchwork Fri Mar 31 14:33:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 96452 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp757668qgd; Fri, 31 Mar 2017 07:35:03 -0700 (PDT) X-Received: by 10.55.151.3 with SMTP id z3mr2973886qkd.79.1490970903845; Fri, 31 Mar 2017 07:35:03 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n185si4794482qkf.137.2017.03.31.07.35.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 31 Mar 2017 07:35:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:41367 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctxdn-0005oD-3Q for patch@linaro.org; Fri, 31 Mar 2017 10:35:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ctxcA-0004vz-9C for qemu-devel@nongnu.org; Fri, 31 Mar 2017 10:33:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ctxc7-00031R-Ll for qemu-devel@nongnu.org; Fri, 31 Mar 2017 10:33:22 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:34356) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ctxc7-00030Z-Dq; Fri, 31 Mar 2017 10:33:19 -0400 Received: by mail-pg0-x244.google.com with SMTP id o123so17835859pga.1; Fri, 31 Mar 2017 07:33:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=nwFc9PwYmTbK49hGmVJT1SmibLDC/S0fXcaybeo4PFo=; b=OKGk/TTrtyQlAWq+Jk7Beb4z5rEqUo0ZAiot14+lhbmt3OwSM5LLo1UrQ45q7L62xN XlSYNZ3VXWMWSG0NcZUoAycGbk7uI7jlsZ1+dXIs7+0spqum1kLCzTsCxo6gdbjjPiX9 /No1bbKLQ3YeqQG2AgH7wFzHRQ8DH8JVkw4A7wjd16Hn0D6M65hHBpiwxZcsEPfWe2+6 Y0Nxvdxrh9gXsPa7cKmSuvGrDKIknK4D1pxwBxkqOBfV65b6VrCUN09lcTn+HSwLvvbI ruAd/tb/vGqW0dgt1f52Pru1F2sHSSGFZfxwsmuhmcr0klsdPN3Da13m7Lu9CFQvZU9/ vcJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=nwFc9PwYmTbK49hGmVJT1SmibLDC/S0fXcaybeo4PFo=; b=klNZAH7g8MvOgFIzxFDkLE9oqBk+Ylrlh6/XaYSvgeNlpQLPtcklGAwcuku2HwAYh8 DitfwvFZVvIBTy4nVzgqh4SHSzulJFfmjgmE7ruc+8ywrrUJwPu89f7q80CDvb155DVN gins7cvrAtjVMdhtcxbCT9qFIjMPj83SJxMkX0BdGOE6oed2ndVIvOeGnj9HC9sWEn8Z wsJ+elymn75gHOmds7+oYPk4uvqrLd2LRqdh6bUpMJn4Hfc6uJxfI4CyWbRPRNQ5zFGZ F+gIOmVO9x70p6gwVJ2CxuvetRamm0ioxHcr445aqlrDEy8KhSkvA8pF4mGxzDQDoxay 7YhQ== X-Gm-Message-State: AFeK/H3dr6+GgcorWIn1SzErIRat8Q+QBMHt8D3Ht1Fps9b/w+Q91XBsjiD2ZdxAE67x5Q== X-Received: by 10.98.196.12 with SMTP id y12mr3192762pff.49.1490970798299; Fri, 31 Mar 2017 07:33:18 -0700 (PDT) Received: from serve.minyard.net ([47.184.141.54]) by smtp.gmail.com with ESMTPSA id a21sm11090684pfc.36.2017.03.31.07.33.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2017 07:33:17 -0700 (PDT) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 9C408399; Fri, 31 Mar 2017 09:33:15 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 9703830006A; Fri, 31 Mar 2017 09:33:14 -0500 (CDT) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Fri, 31 Mar 2017 09:33:03 -0500 Message-Id: <1490970783-29231-1-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::244 Subject: [Qemu-devel] [PATCH v4] ipmi: Fix macro issues X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, Ed Maste , Corey Minyard Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard Macro parameters should almost always have () around them when used. llvm reported an error on this. Remove redundant parenthesis and put parenthesis around the entire macros with assignments in case they are used in an expression. The macros were doing ((v) & 1) for a binary input, but that only works if v == 0 or if v & 1. Changed to !!(v) so they work for all values. Remove some unused macros. Reported in https://bugs.launchpad.net/bugs/1651167 Signed-off-by: Corey Minyard --- Changes since the last revision: * Added the !!(v) change hw/ipmi/isa_ipmi_bt.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) -- 2.7.4 Reviewed-by: Eric Blake Reviewed-by: Ed Maste diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c index 1c69cb3..13a8c09 100644 --- a/hw/ipmi/isa_ipmi_bt.c +++ b/hw/ipmi/isa_ipmi_bt.c @@ -37,40 +37,30 @@ #define IPMI_BT_HBUSY_BIT 6 #define IPMI_BT_BBUSY_BIT 7 -#define IPMI_BT_CLR_WR_MASK (1 << IPMI_BT_CLR_WR_BIT) #define IPMI_BT_GET_CLR_WR(d) (((d) >> IPMI_BT_CLR_WR_BIT) & 0x1) -#define IPMI_BT_SET_CLR_WR(d, v) (d) = (((d) & ~IPMI_BT_CLR_WR_MASK) | \ - (((v & 1) << IPMI_BT_CLR_WR_BIT))) -#define IPMI_BT_CLR_RD_MASK (1 << IPMI_BT_CLR_RD_BIT) #define IPMI_BT_GET_CLR_RD(d) (((d) >> IPMI_BT_CLR_RD_BIT) & 0x1) -#define IPMI_BT_SET_CLR_RD(d, v) (d) = (((d) & ~IPMI_BT_CLR_RD_MASK) | \ - (((v & 1) << IPMI_BT_CLR_RD_BIT))) -#define IPMI_BT_H2B_ATN_MASK (1 << IPMI_BT_H2B_ATN_BIT) #define IPMI_BT_GET_H2B_ATN(d) (((d) >> IPMI_BT_H2B_ATN_BIT) & 0x1) -#define IPMI_BT_SET_H2B_ATN(d, v) (d) = (((d) & ~IPMI_BT_H2B_ATN_MASK) | \ - (((v & 1) << IPMI_BT_H2B_ATN_BIT))) #define IPMI_BT_B2H_ATN_MASK (1 << IPMI_BT_B2H_ATN_BIT) #define IPMI_BT_GET_B2H_ATN(d) (((d) >> IPMI_BT_B2H_ATN_BIT) & 0x1) -#define IPMI_BT_SET_B2H_ATN(d, v) (d) = (((d) & ~IPMI_BT_B2H_ATN_MASK) | \ - (((v & 1) << IPMI_BT_B2H_ATN_BIT))) +#define IPMI_BT_SET_B2H_ATN(d, v) ((d) = (((d) & ~IPMI_BT_B2H_ATN_MASK) | \ + (!!(v) << IPMI_BT_B2H_ATN_BIT))) #define IPMI_BT_SMS_ATN_MASK (1 << IPMI_BT_SMS_ATN_BIT) #define IPMI_BT_GET_SMS_ATN(d) (((d) >> IPMI_BT_SMS_ATN_BIT) & 0x1) -#define IPMI_BT_SET_SMS_ATN(d, v) (d) = (((d) & ~IPMI_BT_SMS_ATN_MASK) | \ - (((v & 1) << IPMI_BT_SMS_ATN_BIT))) +#define IPMI_BT_SET_SMS_ATN(d, v) ((d) = (((d) & ~IPMI_BT_SMS_ATN_MASK) | \ + (!!(v) << IPMI_BT_SMS_ATN_BIT))) #define IPMI_BT_HBUSY_MASK (1 << IPMI_BT_HBUSY_BIT) #define IPMI_BT_GET_HBUSY(d) (((d) >> IPMI_BT_HBUSY_BIT) & 0x1) -#define IPMI_BT_SET_HBUSY(d, v) (d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \ - (((v & 1) << IPMI_BT_HBUSY_BIT))) +#define IPMI_BT_SET_HBUSY(d, v) ((d) = (((d) & ~IPMI_BT_HBUSY_MASK) | \ + (!!(v) << IPMI_BT_HBUSY_BIT))) #define IPMI_BT_BBUSY_MASK (1 << IPMI_BT_BBUSY_BIT) -#define IPMI_BT_GET_BBUSY(d) (((d) >> IPMI_BT_BBUSY_BIT) & 0x1) -#define IPMI_BT_SET_BBUSY(d, v) (d) = (((d) & ~IPMI_BT_BBUSY_MASK) | \ - (((v & 1) << IPMI_BT_BBUSY_BIT))) +#define IPMI_BT_SET_BBUSY(d, v) ((d) = (((d) & ~IPMI_BT_BBUSY_MASK) | \ + (!!(v) << IPMI_BT_BBUSY_BIT))) /* Mask register */ @@ -79,13 +69,13 @@ #define IPMI_BT_B2H_IRQ_EN_MASK (1 << IPMI_BT_B2H_IRQ_EN_BIT) #define IPMI_BT_GET_B2H_IRQ_EN(d) (((d) >> IPMI_BT_B2H_IRQ_EN_BIT) & 0x1) -#define IPMI_BT_SET_B2H_IRQ_EN(d, v) (d) = (((d) & ~IPMI_BT_B2H_IRQ_EN_MASK) | \ - (((v & 1) << IPMI_BT_B2H_IRQ_EN_BIT))) +#define IPMI_BT_SET_B2H_IRQ_EN(d, v) ((d) = (((d) & ~IPMI_BT_B2H_IRQ_EN_MASK) |\ + (!!(v) << IPMI_BT_B2H_IRQ_EN_BIT))) #define IPMI_BT_B2H_IRQ_MASK (1 << IPMI_BT_B2H_IRQ_BIT) #define IPMI_BT_GET_B2H_IRQ(d) (((d) >> IPMI_BT_B2H_IRQ_BIT) & 0x1) -#define IPMI_BT_SET_B2H_IRQ(d, v) (d) = (((d) & ~IPMI_BT_B2H_IRQ_MASK) | \ - (((v & 1) << IPMI_BT_B2H_IRQ_BIT))) +#define IPMI_BT_SET_B2H_IRQ(d, v) ((d) = (((d) & ~IPMI_BT_B2H_IRQ_MASK) | \ + (!!(v) << IPMI_BT_B2H_IRQ_BIT))) typedef struct IPMIBT { IPMIBmc *bmc;