2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-26 22:24:09 +08:00
linux-next/drivers/crypto/nx
Gustavo A. R. Silva 5a8a076506 crypto: Replace zero-length array with flexible-array member
The current codebase makes use of the zero-length array language
extension to the C90 standard, but the preferred mechanism to declare
variable-length types such as these ones is a flexible array member[1][2],
introduced in C99:

struct foo {
        int stuff;
        struct boo array[];
};

By making use of the mechanism above, we will get a compiler warning
in case the flexible array does not occur last in the structure, which
will help us prevent some kind of undefined behavior bugs from being
inadvertently introduced[3] to the codebase from now on.

Also, notice that, dynamic memory allocations won't be affected by
this change:

"Flexible array members have incomplete type, and so the sizeof operator
may not be applied. As a quirk of the original implementation of
zero-length arrays, sizeof evaluates to zero."[1]

This issue was found with the help of Coccinelle.

[1] https://gcc.gnu.org/onlinedocs/gcc/Zero-Length.html
[2] https://github.com/KSPP/linux/issues/21
[3] commit 7649773293 ("cxgb3/l2t: Fix undefined behaviour")

Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2020-03-06 12:28:21 +11:00
..
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nx_csbcpb.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nx_debugfs.c crypto: nx - Improve debugfs_create_u{32,64}() handling for atomics 2019-10-26 02:09:59 +11:00
nx-842-powernv.c crypto: nx - Add of_node_put() before return in 842 2019-08-02 14:44:32 +10:00
nx-842-pseries.c locking/atomic, crypto/nx: Remove redundant casts 2019-06-03 12:32:57 +02:00
nx-842.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 157 2019-05-30 11:26:37 -07:00
nx-842.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
nx-aes-cbc.c crypto: nx - convert AES-CBC to skcipher API 2019-10-23 19:46:59 +11:00
nx-aes-ccm.c crypto: nx - remove stale comment referring to the blkcipher walk API 2019-11-17 09:02:49 +08:00
nx-aes-ctr.c crypto: nx - convert AES-CTR to skcipher API 2019-10-23 19:47:00 +11:00
nx-aes-ecb.c crypto: nx - convert AES-ECB to skcipher API 2019-10-23 19:46:59 +11:00
nx-aes-gcm.c crypto: nx - remove stale comment referring to the blkcipher walk API 2019-11-17 09:02:49 +08:00
nx-aes-xcbc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 299 2019-06-05 17:36:59 +02:00
nx-sha256.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 299 2019-06-05 17:36:59 +02:00
nx-sha512.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 299 2019-06-05 17:36:59 +02:00
nx.c crypto: nx - convert AES-CTR to skcipher API 2019-10-23 19:47:00 +11:00
nx.h crypto: Replace zero-length array with flexible-array member 2020-03-06 12:28:21 +11:00