Re: [patch] crypto: sha256-mb - cleanup a || vs | typo

From: Tim Chen
Date: Thu Jun 30 2016 - 16:42:27 EST


On Wed, 2016-06-29 at 10:05 -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 <dan.carpenter@xxxxxxxxxx>
> >
> > diff --git a/arch/x86/crypto/sha256-mb/sha256_mb.c b/arch/x86/crypto/sha256-mb/sha256_mb.c
> > index c9d5dcc..4ec895a 100644
> > --- 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.
>
> -hpa
>

Yes, this is an intentional optimization. ÂIs there any scenario where things may
break with the compiler?

Tim