Re: [PATCH] crypto: caam - Avoid GCC memset bug warning

From: Herbert Xu
Date: Wed Dec 28 2022 - 20:48:57 EST


On Wed, Dec 28, 2022 at 12:30:35PM +0100, Uwe Kleine-König wrote:
>
> > - if (len) /* avoid sparse warning: memcpy with byte count of 0 */
> > + /* Avoid gcc warning: memcpy with data == NULL */
> > + if (!IS_ENABLED(CONFIG_CRYPTO_DEV_FSL_CAAM_DEBUG) || data)
>
> I just tried: For me a plain
>
> if (data)
>
> is also enough to make both gcc and sparse happy.

Of course it is. The point of the extra condition is to remove
the unnecessary check on data unless we are in debugging mode
(as it is only needed in debugging mode to work around the buggy
compiler).

> (On a related note, sparse reports:
>
> CHECK drivers/crypto/caam/jr.c
> drivers/crypto/caam/jr.c: note: in included file (through arch/arm64/include/asm/io.h, include/linux/io.h, include/linux/irq.h, ...):
> include/asm-generic/io.h:290:22: warning: incorrect type in argument 1 (different base types)
> include/asm-generic/io.h:290:22: expected unsigned long long [usertype] val
> include/asm-generic/io.h:290:22: got restricted __le64 [usertype]
> include/asm-generic/io.h:290:22: warning: incorrect type in argument 1 (different base types)
> include/asm-generic/io.h:290:22: expected unsigned long long [usertype] val
> include/asm-generic/io.h:290:22: got restricted __le64 [usertype]

That's a bug in include/asm-generic/io.h. It feeds an __le64 to
__raw_writeq which wants a u64.

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