Skip to content

Commit 1060bfc

Browse files
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] KSPP/linux#21 Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
1 parent 6c48764 commit 1060bfc

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

‎drivers/block/drbd/drbd_int.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ struct fifo_buffer {
620620
unsigned int head_index;
621621
unsigned int size;
622622
int total; /* sum of all values */
623-
int values[0];
623+
int values[];
624624
};
625625
extern struct fifo_buffer *fifo_alloc(unsigned int fifo_size);
626626

‎drivers/block/drbd/drbd_protocol.h‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ struct p_rs_param {
271271
u32 resync_rate;
272272

273273
/* Since protocol version 88 and higher. */
274-
char verify_alg[0];
274+
char verify_alg[];
275275
} __packed;
276276

277277
struct p_rs_param_89 {
@@ -305,7 +305,7 @@ struct p_protocol {
305305
u32 two_primaries;
306306

307307
/* Since protocol version 87 and higher. */
308-
char integrity_alg[0];
308+
char integrity_alg[];
309309

310310
} __packed;
311311

@@ -360,7 +360,7 @@ struct p_sizes {
360360
u16 dds_flags; /* use enum dds_flags here. */
361361

362362
/* optional queue_limits if (agreed_features & DRBD_FF_WSAME) */
363-
struct o_qlim qlim[0];
363+
struct o_qlim qlim[];
364364
} __packed;
365365

366366
struct p_state {
@@ -409,7 +409,7 @@ struct p_compressed_bm {
409409
*/
410410
u8 encoding;
411411

412-
u8 code[0];
412+
u8 code[];
413413
} __packed;
414414

415415
struct p_delay_probe93 {

0 commit comments

Comments
 (0)