mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Kyle Moffett <mrmacman_g4@mac.com>
To: Kyle Moffett <mrmacman_g4@mac.com>
Cc: Herbert Xu <herbert@gondor.apana.org.au>,
	David Miller <davem@davemloft.net>,
	linux-kernel@vger.kernel.org, torvalds@osdl.org
Subject: Re: [PATCH]: Fix ALIGN() macro
Date: Sat, 23 Sep 2006 16:42:47 -0400	[thread overview]
Message-ID: <818B7FCF-3713-42E8-8EFF-2ECC98217BEE@mac.com> (raw)
In-Reply-To: <0C3FEC03-29A8-49B0-9D12-BBFA4AE99A78@mac.com>

On Sep 23, 2006, at 16:36:33, Kyle Moffett wrote:
> On Sep 23, 2006, at 10:40:41, Herbert Xu wrote:
>> diff --git a/crypto/hmac.c b/crypto/hmac.c
>> index f403b69..d52b234 100644
>> --- a/crypto/hmac.c
>> +++ b/crypto/hmac.c
>> @@ -98,7 +98,7 @@ static int hmac_init(struct hash_desc *p
>>  	sg_set_buf(&tmp, ipad, bs);
>>
>>  	return unlikely(crypto_hash_init(&desc)) ?:
>> -	       crypto_hash_update(&desc, &tmp, 1);
>> +	       crypto_hash_update(&desc, &tmp, bs);
>>  }
>>
>>  static int hmac_update(struct hash_desc *pdesc,
>
> Quick question:  does "crypto_hash_init()" ever return anything  
> other than 0 or 1?  If so this is a subtle bug, as "unlikely()" is  
> implemented like this:
>
> # define unlikely(x) __builtin_expect(!!(x), 0)
>
> IMO any usage of likely/unlikely other than if(unlikely()), if 
> (likely()) is probably a bug.

With a bit more contemplation, I think this is one place where (if  
the compiler or sparse are cooperative) we should really look at the  
_Bool type or similar.  If we could cast likely()/unlikely() to  
return (_Bool), then these sorts of problems would be caught at  
compile time, and likewise for other functions which return boolean  
values.

Cheers,
Kyle Moffett


  reply	other threads:[~2006-09-23 20:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-23  5:31 David Miller
2006-09-23 12:46 ` Herbert Xu
2006-09-23 12:54   ` Herbert Xu
2006-09-23 14:40     ` Herbert Xu
2006-09-23 20:12       ` David Miller
2006-09-23 20:36       ` Kyle Moffett
2006-09-23 20:42         ` Kyle Moffett [this message]
2006-09-23 23:30         ` Herbert Xu
2006-09-23 19:57     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=818B7FCF-3713-42E8-8EFF-2ECC98217BEE@mac.com \
    --to=mrmacman_g4@mac.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®