2022-03-27 12:47:00

by Ard Biesheuvel

[permalink] [raw]
Subject: Re: [PATCH] crypto: aes_generic: fixed styling warnings

On Sat, 26 Mar 2022 at 18:48, Paul Lemmermann
<[email protected]> wrote:
>
> Fixed all styling warnings from the checkpatch.pl script.
>
> Signed-off-by: Paul Lemmermann <[email protected]>

Did you test this code after 'fixing' it?

> ---
> crypto/aes_generic.c | 35 ++++++++++++++++++-----------------
> 1 file changed, 18 insertions(+), 17 deletions(-)
>
> diff --git a/crypto/aes_generic.c b/crypto/aes_generic.c
> index 27ab27931..322e345ac 100644
> --- a/crypto/aes_generic.c
> +++ b/crypto/aes_generic.c
> @@ -1,3 +1,4 @@
> +// SPDX-License-Identifier: GPL-2.0+
> /*
> * Cryptographic API.
> *
> @@ -56,7 +57,7 @@
> #include <asm/byteorder.h>
> #include <asm/unaligned.h>
>
> -static inline u8 byte(const u32 x, const unsigned n)
> +static inline u8 byte(const u32 x, const unsigned int n)
> {
> return x >> (n << 3);
> }
> @@ -325,6 +326,7 @@ __visible const u32 crypto_ft_tab[4][256] ____cacheline_aligned = {
> 0x7bcbb0b0, 0xa8fc5454, 0x6dd6bbbb, 0x2c3a1616,
> }
> };
> +EXPORT_SYMBOL_GPL(crypto_ft_tab);
>
> static const u32 crypto_fl_tab[4][256] ____cacheline_aligned = {
> {
> @@ -853,6 +855,7 @@ __visible const u32 crypto_it_tab[4][256] ____cacheline_aligned = {
> 0x7b6184cb, 0xd570b632, 0x48745c6c, 0xd04257b8,
> }
> };
> +EXPORT_SYMBOL_GPL(crypto_it_tab);
>
> static const u32 crypto_il_tab[4][256] ____cacheline_aligned = {
> {
> @@ -1118,8 +1121,6 @@ static const u32 crypto_il_tab[4][256] ____cacheline_aligned = {
> }
> };
>
> -EXPORT_SYMBOL_GPL(crypto_ft_tab);
> -EXPORT_SYMBOL_GPL(crypto_it_tab);
>
> /**
> * crypto_aes_set_key - Set the AES key.
> @@ -1144,34 +1145,34 @@ EXPORT_SYMBOL_GPL(crypto_aes_set_key);
>
> /* encrypt a block of text */
>
> -#define f_rn(bo, bi, n, k) do { \
> +#define f_rn(bo, bi, n, k) while (0) { \
> bo[n] = crypto_ft_tab[0][byte(bi[n], 0)] ^ \
> crypto_ft_tab[1][byte(bi[(n + 1) & 3], 1)] ^ \
> crypto_ft_tab[2][byte(bi[(n + 2) & 3], 2)] ^ \
> crypto_ft_tab[3][byte(bi[(n + 3) & 3], 3)] ^ *(k + n); \
> -} while (0)
> +}
>
> -#define f_nround(bo, bi, k) do {\
> +#define f_nround(bo, bi, k) while (0) {\
> f_rn(bo, bi, 0, k); \
> f_rn(bo, bi, 1, k); \
> f_rn(bo, bi, 2, k); \
> f_rn(bo, bi, 3, k); \
> k += 4; \
> -} while (0)
> +}
>
> -#define f_rl(bo, bi, n, k) do { \
> +#define f_rl(bo, bi, n, k) while (0) { \
> bo[n] = crypto_fl_tab[0][byte(bi[n], 0)] ^ \
> crypto_fl_tab[1][byte(bi[(n + 1) & 3], 1)] ^ \
> crypto_fl_tab[2][byte(bi[(n + 2) & 3], 2)] ^ \
> crypto_fl_tab[3][byte(bi[(n + 3) & 3], 3)] ^ *(k + n); \
> -} while (0)
> +}
>
> -#define f_lround(bo, bi, k) do {\
> +#define f_lround(bo, bi, k) while (0) {\
> f_rl(bo, bi, 0, k); \
> f_rl(bo, bi, 1, k); \
> f_rl(bo, bi, 2, k); \
> f_rl(bo, bi, 3, k); \
> -} while (0)
> +}
>
> static void crypto_aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
> {
> @@ -1214,12 +1215,12 @@ static void crypto_aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
>
> /* decrypt a block of text */
>
> -#define i_rn(bo, bi, n, k) do { \
> +#define i_rn(bo, bi, n, k) while (0) { \
> bo[n] = crypto_it_tab[0][byte(bi[n], 0)] ^ \
> crypto_it_tab[1][byte(bi[(n + 3) & 3], 1)] ^ \
> crypto_it_tab[2][byte(bi[(n + 2) & 3], 2)] ^ \
> crypto_it_tab[3][byte(bi[(n + 1) & 3], 3)] ^ *(k + n); \
> -} while (0)
> +}
>
> #define i_nround(bo, bi, k) do {\
> i_rn(bo, bi, 0, k); \
> @@ -1229,19 +1230,19 @@ static void crypto_aes_encrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
> k += 4; \
> } while (0)
>
> -#define i_rl(bo, bi, n, k) do { \
> +#define i_rl(bo, bi, n, k) while (0) { \
> bo[n] = crypto_il_tab[0][byte(bi[n], 0)] ^ \
> crypto_il_tab[1][byte(bi[(n + 3) & 3], 1)] ^ \
> crypto_il_tab[2][byte(bi[(n + 2) & 3], 2)] ^ \
> crypto_il_tab[3][byte(bi[(n + 1) & 3], 3)] ^ *(k + n); \
> -} while (0)
> +}
>
> -#define i_lround(bo, bi, k) do {\
> +#define i_lround(bo, bi, k) while (0) {\
> i_rl(bo, bi, 0, k); \
> i_rl(bo, bi, 1, k); \
> i_rl(bo, bi, 2, k); \
> i_rl(bo, bi, 3, k); \
> -} while (0)
> +}
>
> static void crypto_aes_decrypt(struct crypto_tfm *tfm, u8 *out, const u8 *in)
> {
> --
> 2.35.1
>