linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Herbert Xu <herbert@gondor.hengli.com.au>
To: Mathias Krause <minipli@googlemail.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	linux-crypto@vger.kernel.org,
	Maxim Locktyukhin <maxim.locktyukhin@intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 1/2] crypto, sha1: export sha1_update for reuse
Date: Sat, 30 Jul 2011 21:46:50 +0800	[thread overview]
Message-ID: <20110730134650.GA26753@gondor.apana.org.au> (raw)
In-Reply-To: <CA+rthh-=qKpYM-9F0e=6DUpqxXWbMuMcXnGq9cZTK0V=Kbpg0A@mail.gmail.com>

On Thu, Jul 28, 2011 at 05:29:35PM +0200, Mathias Krause wrote:
> On Thu, Jul 28, 2011 at 4:58 PM, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> > On Sun, Jul 24, 2011 at 07:53:13PM +0200, Mathias Krause wrote:
> >>
> >> diff --git a/include/crypto/sha.h b/include/crypto/sha.h
> >> index 069e85b..7c46d0c 100644
> >> --- a/include/crypto/sha.h
> >> +++ b/include/crypto/sha.h
> >> @@ -82,4 +82,9 @@ struct sha512_state {
> >>       u8 buf[SHA512_BLOCK_SIZE];
> >>  };
> >>
> >> +#if defined(CONFIG_CRYPTO_SHA1) || defined (CONFIG_CRYPTO_SHA1_MODULE)
> >> +extern int crypto_sha1_update(struct shash_desc *desc, const u8 *data,
> >> +                           unsigned int len);
> >> +#endif
> >
> > Please remove the unnecessary #if.
> 
> The function will only be available when crypto/sha1_generic.o will
> either be build into the kernel or build as a module. Without the #if
> a potential wrong user of this function might not be detected as early
> as at compilation time but as late as at link time, or even worse, as
> late as on module load time -- which is pretty bad. IMHO it's better
> to detect errors early, as in reading "error: implicit declaration of
> function ‘crypto_sha1_update’" when trying to compile the code in
> question instead of "Unknown symbol crypto_sha1_update" in dmesg when
> trying to load the module. That for I would like to keep the #if.

In order to be consistent please remove the ifdef.  In most
similar cases in the crypto subsystem we don't do this.  As
adding such ifdefs all over the place would gain very little,
I'd much rather you left it out.

The one case where this would make sense is if it were a trivial
inline in the !defined case.

Thanks!
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

  reply	other threads:[~2011-07-30 13:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-24 17:53 [PATCH v2 0/2] crypto, x86: assembler implementation of SHA1 Mathias Krause
2011-07-24 17:53 ` [PATCH v2 1/2] crypto, sha1: export sha1_update for reuse Mathias Krause
2011-07-28 14:58   ` Herbert Xu
2011-07-28 15:29     ` Mathias Krause
2011-07-30 13:46       ` Herbert Xu [this message]
2011-07-31 13:24         ` Mathias Krause
2011-07-24 17:53 ` [PATCH v2 2/2] crypto, x86: SSSE3 based SHA1 implementation for x86-64 Mathias Krause
2011-08-04  6:44   ` Herbert Xu
2011-08-04 17:05     ` Mathias Krause
2011-08-04 17:08       ` Mathias Krause
2011-08-08  5:48       ` Locktyukhin, Maxim
2011-08-14 19:06         ` Mathias Krause
2011-08-11 14:50     ` Andy Lutomirski
2011-08-11 15:08       ` Herbert Xu
2011-08-11 15:15         ` Andrew Lutomirski
2011-08-14 19:09       ` Mathias Krause

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=20110730134650.GA26753@gondor.apana.org.au \
    --to=herbert@gondor.hengli.com.au \
    --cc=davem@davemloft.net \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maxim.locktyukhin@intel.com \
    --cc=minipli@googlemail.com \
    /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;
as well as URLs for NNTP newsgroup(s).