linux/drivers/crypto/nx
Gustavo A. R. Silva 1e6b251ce1 crypto: nx - Avoid -Wflex-array-member-not-at-end warning
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally. So, we are deprecating flexible-array
members in the middle of another structure.

There is currently an object (`header`) in `struct nx842_crypto_ctx`
that contains a flexible structure (`struct nx842_crypto_header`):

struct nx842_crypto_ctx {
	...
        struct nx842_crypto_header header;
        struct nx842_crypto_header_group group[NX842_CRYPTO_GROUP_MAX];
	...
};

So, in order to avoid ending up with a flexible-array member in the
middle of another struct, we use the `struct_group_tagged()` helper to
separate the flexible array from the rest of the members in the flexible
structure:

struct nx842_crypto_header {
	struct_group_tagged(nx842_crypto_header_hdr, hdr,

		... the rest of the members

	);
        struct nx842_crypto_header_group group[];
} __packed;

With the change described above, we can now declare an object of the
type of the tagged struct, without embedding the flexible array in the
middle of another struct:

struct nx842_crypto_ctx {
	...
        struct nx842_crypto_header_hdr header;
        struct nx842_crypto_header_group group[NX842_CRYPTO_GROUP_MAX];
	...
 } __packed;

We also use `container_of()` whenever we need to retrieve a pointer to
the flexible structure, through which we can access the flexible
array if needed.

So, with these changes, fix the following warning:

In file included from drivers/crypto/nx/nx-842.c:55:
drivers/crypto/nx/nx-842.h:174:36: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
  174 |         struct nx842_crypto_header header;
      |                                    ^~~~~~

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2024-04-02 10:49:38 +08:00
..
Kconfig crypto/nx: Register and unregister VAS interface on PowerVM 2021-06-20 21:58:58 +10:00
Makefile crypto: nx - fix build warnings when DEBUG_FS is not enabled 2023-05-24 18:12:33 +08:00
nx_csbcpb.h crypto: nx - Fix numerous sparse byte-order warnings 2021-06-24 14:51:35 +08:00
nx_debugfs.c crypto: nx - Repair some kernel-doc problems 2021-03-26 20:02:36 +11:00
nx-842.c crypto: nx - Avoid -Wflex-array-member-not-at-end warning 2024-04-02 10:49:38 +08:00
nx-842.h crypto: nx - Avoid -Wflex-array-member-not-at-end warning 2024-04-02 10:49:38 +08:00
nx-aes-cbc.c crypto: nx - Fix numerous sparse byte-order warnings 2021-06-24 14:51:35 +08:00
nx-aes-ccm.c crypto: nx - Remove the unneeded result variable 2022-09-09 16:18:33 +08:00
nx-aes-ctr.c crypto: nx - Fix numerous sparse byte-order warnings 2021-06-24 14:51:35 +08:00
nx-aes-ecb.c crypto: nx - Fix numerous sparse byte-order warnings 2021-06-24 14:51:35 +08:00
nx-aes-gcm.c crypto: nx - Fix numerous sparse byte-order warnings 2021-06-24 14:51:35 +08:00
nx-aes-xcbc.c crypto: nx - fix incorrect kernel-doc comment syntax in files 2021-03-26 20:15:58 +11:00
nx-common-powernv.c crypto: nx - Fix sparse warnings 2023-02-14 13:39:33 +08:00
nx-common-pseries.c crypto: nx - Fix sparse warnings 2023-02-14 13:39:33 +08:00
nx-sha256.c crypto: nx - Fix numerous sparse byte-order warnings 2021-06-24 14:51:35 +08:00
nx-sha512.c crypto: nx - Fix numerous sparse byte-order warnings 2021-06-24 14:51:35 +08:00
nx.c Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2021-04-26 08:51:23 -07:00
nx.h crypto: nx - fix build warnings when DEBUG_FS is not enabled 2023-05-24 18:12:33 +08:00