drbd: Replace zero-length array with flexible-array

There is a regular need in the kernel to provide a way to declare having a
dynamically sized set of trailing elements in a structure. Kernel code should
always use “flexible array members”[1] for these cases. The older style of
one-element or zero-length arrays should no longer be used[2].

[1] https://en.wikipedia.org/wiki/Flexible_array_member
[2] https://github.com/KSPP/linux/issues/21

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
This commit is contained in:
Gustavo A. R. Silva 2020-05-28 09:35:11 -05:00
Родитель 6c48764aa4
Коммит 1060bfc8e2
2 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -620,7 +620,7 @@ struct fifo_buffer {
unsigned int head_index; unsigned int head_index;
unsigned int size; unsigned int size;
int total; /* sum of all values */ int total; /* sum of all values */
int values[0]; int values[];
}; };
extern struct fifo_buffer *fifo_alloc(unsigned int fifo_size); extern struct fifo_buffer *fifo_alloc(unsigned int fifo_size);

Просмотреть файл

@ -271,7 +271,7 @@ struct p_rs_param {
u32 resync_rate; u32 resync_rate;
/* Since protocol version 88 and higher. */ /* Since protocol version 88 and higher. */
char verify_alg[0]; char verify_alg[];
} __packed; } __packed;
struct p_rs_param_89 { struct p_rs_param_89 {
@ -305,7 +305,7 @@ struct p_protocol {
u32 two_primaries; u32 two_primaries;
/* Since protocol version 87 and higher. */ /* Since protocol version 87 and higher. */
char integrity_alg[0]; char integrity_alg[];
} __packed; } __packed;
@ -360,7 +360,7 @@ struct p_sizes {
u16 dds_flags; /* use enum dds_flags here. */ u16 dds_flags; /* use enum dds_flags here. */
/* optional queue_limits if (agreed_features & DRBD_FF_WSAME) */ /* optional queue_limits if (agreed_features & DRBD_FF_WSAME) */
struct o_qlim qlim[0]; struct o_qlim qlim[];
} __packed; } __packed;
struct p_state { struct p_state {
@ -409,7 +409,7 @@ struct p_compressed_bm {
*/ */
u8 encoding; u8 encoding;
u8 code[0]; u8 code[];
} __packed; } __packed;
struct p_delay_probe93 { struct p_delay_probe93 {