Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+5 -5
+1 -1
drivers/block/drbd/drbd_int.h
··· 620 620 unsigned int head_index; 621 621 unsigned int size; 622 622 int total; /* sum of all values */ 623 - int values[0]; 623 + int values[]; 624 624 }; 625 625 extern struct fifo_buffer *fifo_alloc(unsigned int fifo_size); 626 626
+4 -4
drivers/block/drbd/drbd_protocol.h
··· 271 271 u32 resync_rate; 272 272 273 273 /* Since protocol version 88 and higher. */ 274 - char verify_alg[0]; 274 + char verify_alg[]; 275 275 } __packed; 276 276 277 277 struct p_rs_param_89 { ··· 305 305 u32 two_primaries; 306 306 307 307 /* Since protocol version 87 and higher. */ 308 - char integrity_alg[0]; 308 + char integrity_alg[]; 309 309 310 310 } __packed; 311 311 ··· 360 360 u16 dds_flags; /* use enum dds_flags here. */ 361 361 362 362 /* optional queue_limits if (agreed_features & DRBD_FF_WSAME) */ 363 - struct o_qlim qlim[0]; 363 + struct o_qlim qlim[]; 364 364 } __packed; 365 365 366 366 struct p_state { ··· 409 409 */ 410 410 u8 encoding; 411 411 412 - u8 code[0]; 412 + u8 code[]; 413 413 } __packed; 414 414 415 415 struct p_delay_probe93 {