alistair23-linux/drivers/nvdimm
Gustavo A. R. Silva 1e361632da libnvdimm/label: 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>
Link: https://lore.kernel.org/r/20200319230737.GA16452@embeddedor.com
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2020-03-30 12:37:09 -07:00
..
badrange.c
blk.c
btt.c libnvdimm/btt: fix variable 'rc' set but not used 2019-11-17 09:17:38 -08:00
btt.h
btt_devs.c libnvdimm: Move attribute groups to device type 2019-11-17 09:17:38 -08:00
bus.c libnvdimm for 5.5 2019-12-01 18:43:25 -08:00
claim.c libnvdimm/namespace: Differentiate between probe mapping and runtime mapping 2019-11-14 19:08:47 -08:00
core.c libnvdimm for 5.5 2019-12-01 18:43:25 -08:00
dax_devs.c libnvdimm: Move attribute groups to device type 2019-11-17 09:17:38 -08:00
dimm.c
dimm_devs.c libnvdimm: Move nvdimm_attribute_group to device_type 2019-11-19 09:52:12 -08:00
e820.c libnvdimm: Move nvdimm_bus_attribute_group to device_type 2019-11-19 09:52:12 -08:00
Kconfig lib: Uplevel the pmem "region" ida to a global allocator 2019-11-07 15:44:29 +01:00
label.c libnvdimm/label: Remove the dpa align check 2019-09-05 16:11:14 -07:00
label.h libnvdimm/label: Replace zero-length array with flexible-array member 2020-03-30 12:37:09 -07:00
Makefile libnvdimm: Enable unit test infrastructure compile checks 2019-09-07 04:28:05 -03:00
namespace_devs.c libnvdimm: Simplify root read-only definition for the 'resource' attribute 2019-11-19 09:52:12 -08:00
nd-core.h libnvdimm for 5.5 2019-12-01 18:43:25 -08:00
nd.h libnvdimm: Move nvdimm_bus_attribute_group to device_type 2019-11-19 09:52:12 -08:00
nd_virtio.c virtio_pmem: fix sparse warning 2019-07-16 19:44:26 -07:00
of_pmem.c libnvdimm: Move nvdimm_bus_attribute_group to device_type 2019-11-19 09:52:12 -08:00
pfn.h libnvdimm/pfn_dev: Add page size and struct page size to pfn superblock 2019-09-05 16:11:14 -07:00
pfn_devs.c libnvdimm: Simplify root read-only definition for the 'resource' attribute 2019-11-19 09:52:12 -08:00
pmem.c mm: Cleanup __put_devmap_managed_page() vs ->page_free() 2020-01-31 10:30:37 -08:00
pmem.h
region.c libnvdimm/region: Initialize bad block for volatile namespaces 2019-09-24 10:27:51 -07:00
region_devs.c libnvdimm for 5.5 2019-12-01 18:43:25 -08:00
security.c libnvdimm: prevent nvdimm from requesting key when security is disabled 2019-09-24 10:30:10 -07:00
virtio_pmem.c virtio-pmem: Add virtio pmem driver 2019-07-05 15:19:10 -07:00
virtio_pmem.h virtio-pmem: Add virtio pmem driver 2019-07-05 15:19:10 -07:00