linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: user - fix potential warnings in cryptouser.h
@ 2019-06-09  6:57 Masahiro Yamada
  2019-06-13  6:01 ` Herbert Xu
  0 siblings, 1 reply; 2+ messages in thread
From: Masahiro Yamada @ 2019-06-09  6:57 UTC (permalink / raw)
  To: Herbert Xu, linux-crypto
  Cc: Masahiro Yamada, David S. Miller, linux-kernel, Eric Biggers,
	Corentin Labbe

Function definitions in headers are usually marked as 'static inline'.

Since 'inline' is missing for crypto_reportstat(), if it were not
referenced from a .c file that includes this header, it would produce
a warning.

Also, 'struct crypto_user_alg' should be forward declared so that
we do not rely on the specific order of header inclusion.

Detected by compile-testing cryptouser.h as a standalone unit:

/include/crypto/internal/cryptouser.h:6:44: warning: ‘struct crypto_user_alg’ declared inside parameter list will not be visible outside of this definition or declaration
 struct crypto_alg *crypto_alg_match(struct crypto_user_alg *p, int exact);
                                            ^~~~~~~~~~~~~~~
./include/crypto/internal/cryptouser.h:11:12: warning: ‘crypto_reportstat’ defined but not used [-Wunused-function]
 static int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh, struct nlattr **attrs)
            ^~~~~~~~~~~~~~~~~

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
---

 include/crypto/internal/cryptouser.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/crypto/internal/cryptouser.h b/include/crypto/internal/cryptouser.h
index 8c602b187c58..2339cb06dbf8 100644
--- a/include/crypto/internal/cryptouser.h
+++ b/include/crypto/internal/cryptouser.h
@@ -3,12 +3,15 @@
 
 extern struct sock *crypto_nlsk;
 
+struct crypto_user_alg;
 struct crypto_alg *crypto_alg_match(struct crypto_user_alg *p, int exact);
 
 #ifdef CONFIG_CRYPTO_STATS
 int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh, struct nlattr **attrs);
 #else
-static int crypto_reportstat(struct sk_buff *in_skb, struct nlmsghdr *in_nlh, struct nlattr **attrs)
+static inline int crypto_reportstat(struct sk_buff *in_skb,
+				    struct nlmsghdr *in_nlh,
+				    struct nlattr **attrs)
 {
 	return -ENOTSUPP;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] crypto: user - fix potential warnings in cryptouser.h
  2019-06-09  6:57 [PATCH] crypto: user - fix potential warnings in cryptouser.h Masahiro Yamada
@ 2019-06-13  6:01 ` Herbert Xu
  0 siblings, 0 replies; 2+ messages in thread
From: Herbert Xu @ 2019-06-13  6:01 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: linux-crypto, David S. Miller, linux-kernel, Eric Biggers,
	Corentin Labbe

On Sun, Jun 09, 2019 at 03:57:10PM +0900, Masahiro Yamada wrote:
>
> diff --git a/include/crypto/internal/cryptouser.h b/include/crypto/internal/cryptouser.h
> index 8c602b187c58..2339cb06dbf8 100644
> --- a/include/crypto/internal/cryptouser.h
> +++ b/include/crypto/internal/cryptouser.h
> @@ -3,12 +3,15 @@
>  
>  extern struct sock *crypto_nlsk;
>  
> +struct crypto_user_alg;

Please change this to instead include <linux/cryptouser.h>.

In the crypto API the internal header file should always include the
external header file.

You can also remove the inclusion of the external header file from
the users of crypto/internal/cryptouser.h.

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-06-13 16:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-09  6:57 [PATCH] crypto: user - fix potential warnings in cryptouser.h Masahiro Yamada
2019-06-13  6:01 ` Herbert Xu

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).