From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751973AbcF3LQd (ORCPT ); Thu, 30 Jun 2016 07:16:33 -0400 Received: from smtprelay0089.hostedemail.com ([216.40.44.89]:54683 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751895AbcF3LQc (ORCPT ); Thu, 30 Jun 2016 07:16:32 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3871:3872:3873:4321:5007:6119:6742:7901:7903:10004:10400:10848:11026:11232:11473:11657:11658:11783:11914:12043:12438:12517:12519:12740:13069:13161:13229:13311:13357:13439:13894:14181:14659:14721:21080:21434:30012:30051:30054:30064:30070:30079:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: army85_3873df2f41645 X-Filterd-Recvd-Size: 2774 Message-ID: <1467285386.24287.143.camel@perches.com> Subject: Re: [patch] crypto: sha256-mb - cleanup a || vs | typo From: Joe Perches To: Dan Carpenter , "H. Peter Anvin" Cc: Herbert Xu , "David S. Miller" , Thomas Gleixner , Ingo Molnar , x86@kernel.org, Tim Chen , Megha Dey , "Wang, Rui Y" , Denys Vlasenko , Xiaodong Liu , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Date: Thu, 30 Jun 2016 04:16:26 -0700 In-Reply-To: <20160630075056.GR32247@mwanda> References: <20160629144242.GE22818@mwanda> <8538242a-eab7-127e-e47e-26027fee4f6d@zytor.com> <20160630075056.GR32247@mwanda> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.2-0ubuntu3 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2016-06-30 at 10:50 +0300, Dan Carpenter wrote: > On Wed, Jun 29, 2016 at 10:05:53AM -0700, H. Peter Anvin wrote: > > On 06/29/16 07:42, Dan Carpenter wrote: > > > > > and | behave basically the same here but || is intended.  It causes a > > > static checker warning to mix up bitwise and logical operations. > > > > > > Signed-off-by: Dan Carpenter > > > > > > diff --git a/arch/x86/crypto/sha256-mb/sha256_mb.c b/arch/x86/crypto/sha256-mb/sha256_mb.c [] > > > @@ -299,7 +299,7 @@ static struct sha256_hash_ctx *sha256_ctx_mgr_submit(struct sha256_ctx_mgr *mgr, > > >    * Or if the user's buffer contains less than a whole block, > > >    * append as much as possible to the extra block. > > >    */ > > > - if ((ctx->partial_block_buffer_length) | (len < SHA256_BLOCK_SIZE)) { > > > + if ((ctx->partial_block_buffer_length) || (len < SHA256_BLOCK_SIZE)) { > > >   /* Compute how many bytes to copy from user buffer into > > >    * extra block > > >    */ > > > > > As far as I know the | was an intentional optimization, so you may way > > to look at the generated code. > I know how the rules work.  I just thought it looked more like a typo > than an optimization.  It's normally a typo.  It's hard to tell the > intent. The compiler could potentially emit the same code when optimizing but at least gcc 5.3 doesn't. It's probably useful to add a comment for the specific intent here rather than change a potentially useful static checker.