From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5CA9C352AA for ; Wed, 2 Oct 2019 14:08:15 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BA6E221A4C for ; Wed, 2 Oct 2019 14:08:15 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZNqoNUf1"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="YMj7eUT/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BA6E221A4C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AOsBtWc98qKXpFjaGn9SHmjZGBLtx91XR0qjPtwQVV8=; b=ZNqoNUf1ZzTY9b nqQLsqk9mKMxVYgBA7VKqaBu9pyAPZZ437cQF32Ca3PUcC1/9djfWh4sunU7geRHyXd33iApNxC80 IujLosevrTMBy2DqxzT9OwsWLvjQokgQ1LJRX8pBFpD8n0aP3CiZZzpO9px5suRrgBIwjL1z/5Wh0 bXn8+awj1CnCCa2uLSR7b5cbQWQsQ/H46qWk5VWLK2NW2Do/cUqjYEWlle4w6kT+Q2g1Ocoo60lVw yaD92Odw1Bkeqj3+igV/jyuzdAyGkyHV78280zY8aGGDhy2q8DWCu8lsSJIfV9/+C3fXonVFcEFuq 4WpTeXOxnLhnKHcAfkfw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.2 #3 (Red Hat Linux)) id 1iFfIV-0006qa-C0; Wed, 02 Oct 2019 14:08:07 +0000 Received: from userp2120.oracle.com ([156.151.31.85]) by bombadil.infradead.org with esmtps (Exim 4.92.2 #3 (Red Hat Linux)) id 1iFfIR-0006px-Fe for linux-arm-kernel@lists.infradead.org; Wed, 02 Oct 2019 14:08:04 +0000 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x92E3uep070461; Wed, 2 Oct 2019 14:07:54 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2019-08-05; bh=+FGGI5TvFktU0/JRb3dnLjz/7hh1wncwHFnR3J2FD1U=; b=YMj7eUT/xa6f248L9zN5raJaaIPi2upRO7Tba4zBrhB/FFYYDkLKPeAcFy5TFSfP5k9I 1TmW52eOj6+7BwliM/xSp+aXKkD9Aw8fOFaJQV7NEYzXst+1zeAP0vEdAKLSu90leQQr Ax38400CmkNxEGa3batH2Nvg7Ye3yBx1oVsfqbK75h5gN8BXYyvdPJimVWUXhgBDzAJX 6DAEn+5GvMsY51gaBich2d7ikokUg6Umcvq2MrHBJrGhMLi52DIvpgACn/6+7omszspn A6FoQP/JZkDXPVa+b9YpiKu4IwnWPi+XIZdJ5387AKPtoX42DwvVV9jwP9XLrNXmKxv+ EQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2va05rw3pu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 02 Oct 2019 14:07:53 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x92E3SKB024837; Wed, 2 Oct 2019 14:07:53 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2vc9dkju5d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 02 Oct 2019 14:07:53 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x92E7pgg001505; Wed, 2 Oct 2019 14:07:51 GMT Received: from kadam (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 02 Oct 2019 07:07:50 -0700 Date: Wed, 2 Oct 2019 17:07:33 +0300 From: Dan Carpenter To: Colin Ian King Subject: Re: [PATCH] net: stmmac: xgmac: add missing parentheses to fix precendence error Message-ID: <20191002140733.GQ29696@kadam> References: <20191002110849.13405-1-colin.king@canonical.com> <20191002133356.GP22609@kadam> <20191002134238.GP29696@kadam> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9397 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910020136 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9397 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910020136 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191002_070803_617599_253CB04A X-CRM114-Status: GOOD ( 24.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Torgue , netdev@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Jose Abreu , Maxime Coquelin , Giuseppe Cavallaro , "David S . Miller" , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Oct 02, 2019 at 02:53:17PM +0100, Colin Ian King wrote: > On 02/10/2019 14:42, Dan Carpenter wrote: > > On Wed, Oct 02, 2019 at 04:33:57PM +0300, Dan Carpenter wrote: > >> On Wed, Oct 02, 2019 at 12:08:49PM +0100, Colin King wrote: > >>> From: Colin Ian King > >>> > >>> The expression !(hw_cap & XGMAC_HWFEAT_RAVSEL) >> 10 is always zero, so > >>> the masking operation is incorrect. Fix this by adding the missing > >>> parentheses to correctly bind the negate operator on the entire expression. > >>> > >>> Addresses-Coverity: ("Operands don't affect result") > >>> Fixes: c2b69474d63b ("net: stmmac: xgmac: Correct RAVSEL field interpretation") > >>> Signed-off-by: Colin Ian King > >>> --- > >>> drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c | 2 +- > >>> 1 file changed, 1 insertion(+), 1 deletion(-) > >>> > >>> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c > >>> index 965cbe3e6f51..2e814aa64a5c 100644 > >>> --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c > >>> +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c > >>> @@ -369,7 +369,7 @@ static void dwxgmac2_get_hw_feature(void __iomem *ioaddr, > >>> dma_cap->eee = (hw_cap & XGMAC_HWFEAT_EEESEL) >> 13; > >>> dma_cap->atime_stamp = (hw_cap & XGMAC_HWFEAT_TSSEL) >> 12; > >>> dma_cap->av = (hw_cap & XGMAC_HWFEAT_AVSEL) >> 11; > >>> - dma_cap->av &= !(hw_cap & XGMAC_HWFEAT_RAVSEL) >> 10; > >>> + dma_cap->av &= !((hw_cap & XGMAC_HWFEAT_RAVSEL) >> 10); > >> > >> There is no point to the shift at all. > > > > Sorry I meant to say it should be a bitwise NOT, right? I was just > > looking at some other dma_cap stuff that did this same thing... I can't > > find it now... > > In drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c it is being used like > a boolean and not a bitmask'd value: > > if (!priv->dma_cap.av) > > so the original logic is to do boolean flag merging rather than bit-wise > logic. Oh yeah. Thanks. This code is hard to read. It would be better to just write it like this: if (hw_cap & XGMAC_HWFEAT_AVSEL) && !(hw_cap & XGMAC_HWFEAT_RAVSEL) dma_cap->av = true; else dma_cap->av = false; All these very shifts are concise but they introduce bugs like this one you have found. regards, dan carpenter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel