Skip to content

Commit af6bb61

Browse files
sctp: 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#21 Signed-off-by: Gustavo A. R. Silva <[email protected]>
1 parent 50f894d commit af6bb61

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

include/linux/sctp.h

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ struct sctp_datahdr {
221221
__be16 stream;
222222
__be16 ssn;
223223
__u32 ppid;
224-
__u8 payload[0];
224+
__u8 payload[];
225225
};
226226

227227
struct sctp_data_chunk {
@@ -269,7 +269,7 @@ struct sctp_inithdr {
269269
__be16 num_outbound_streams;
270270
__be16 num_inbound_streams;
271271
__be32 initial_tsn;
272-
__u8 params[0];
272+
__u8 params[];
273273
};
274274

275275
struct sctp_init_chunk {
@@ -299,13 +299,13 @@ struct sctp_cookie_preserve_param {
299299
/* Section 3.3.2.1 Host Name Address (11) */
300300
struct sctp_hostname_param {
301301
struct sctp_paramhdr param_hdr;
302-
uint8_t hostname[0];
302+
uint8_t hostname[];
303303
};
304304

305305
/* Section 3.3.2.1 Supported Address Types (12) */
306306
struct sctp_supported_addrs_param {
307307
struct sctp_paramhdr param_hdr;
308-
__be16 types[0];
308+
__be16 types[];
309309
};
310310

311311
/* ADDIP Section 3.2.6 Adaptation Layer Indication */
@@ -317,25 +317,25 @@ struct sctp_adaptation_ind_param {
317317
/* ADDIP Section 4.2.7 Supported Extensions Parameter */
318318
struct sctp_supported_ext_param {
319319
struct sctp_paramhdr param_hdr;
320-
__u8 chunks[0];
320+
__u8 chunks[];
321321
};
322322

323323
/* AUTH Section 3.1 Random */
324324
struct sctp_random_param {
325325
struct sctp_paramhdr param_hdr;
326-
__u8 random_val[0];
326+
__u8 random_val[];
327327
};
328328

329329
/* AUTH Section 3.2 Chunk List */
330330
struct sctp_chunks_param {
331331
struct sctp_paramhdr param_hdr;
332-
__u8 chunks[0];
332+
__u8 chunks[];
333333
};
334334

335335
/* AUTH Section 3.3 HMAC Algorithm */
336336
struct sctp_hmac_algo_param {
337337
struct sctp_paramhdr param_hdr;
338-
__be16 hmac_ids[0];
338+
__be16 hmac_ids[];
339339
};
340340

341341
/* RFC 2960. Section 3.3.3 Initiation Acknowledgement (INIT ACK) (2):
@@ -350,7 +350,7 @@ struct sctp_initack_chunk {
350350
/* Section 3.3.3.1 State Cookie (7) */
351351
struct sctp_cookie_param {
352352
struct sctp_paramhdr p;
353-
__u8 body[0];
353+
__u8 body[];
354354
};
355355

356356
/* Section 3.3.3.1 Unrecognized Parameters (8) */
@@ -384,7 +384,7 @@ struct sctp_sackhdr {
384384
__be32 a_rwnd;
385385
__be16 num_gap_ack_blocks;
386386
__be16 num_dup_tsns;
387-
union sctp_sack_variable variable[0];
387+
union sctp_sack_variable variable[];
388388
};
389389

390390
struct sctp_sack_chunk {
@@ -436,7 +436,7 @@ struct sctp_shutdown_chunk {
436436
struct sctp_errhdr {
437437
__be16 cause;
438438
__be16 length;
439-
__u8 variable[0];
439+
__u8 variable[];
440440
};
441441

442442
struct sctp_operr_chunk {
@@ -594,7 +594,7 @@ struct sctp_fwdtsn_skip {
594594

595595
struct sctp_fwdtsn_hdr {
596596
__be32 new_cum_tsn;
597-
struct sctp_fwdtsn_skip skip[0];
597+
struct sctp_fwdtsn_skip skip[];
598598
};
599599

600600
struct sctp_fwdtsn_chunk {
@@ -611,7 +611,7 @@ struct sctp_ifwdtsn_skip {
611611

612612
struct sctp_ifwdtsn_hdr {
613613
__be32 new_cum_tsn;
614-
struct sctp_ifwdtsn_skip skip[0];
614+
struct sctp_ifwdtsn_skip skip[];
615615
};
616616

617617
struct sctp_ifwdtsn_chunk {
@@ -658,7 +658,7 @@ struct sctp_addip_param {
658658

659659
struct sctp_addiphdr {
660660
__be32 serial;
661-
__u8 params[0];
661+
__u8 params[];
662662
};
663663

664664
struct sctp_addip_chunk {
@@ -718,7 +718,7 @@ struct sctp_addip_chunk {
718718
struct sctp_authhdr {
719719
__be16 shkey_id;
720720
__be16 hmac_id;
721-
__u8 hmac[0];
721+
__u8 hmac[];
722722
};
723723

724724
struct sctp_auth_chunk {
@@ -733,21 +733,21 @@ struct sctp_infox {
733733

734734
struct sctp_reconf_chunk {
735735
struct sctp_chunkhdr chunk_hdr;
736-
__u8 params[0];
736+
__u8 params[];
737737
};
738738

739739
struct sctp_strreset_outreq {
740740
struct sctp_paramhdr param_hdr;
741741
__be32 request_seq;
742742
__be32 response_seq;
743743
__be32 send_reset_at_tsn;
744-
__be16 list_of_streams[0];
744+
__be16 list_of_streams[];
745745
};
746746

747747
struct sctp_strreset_inreq {
748748
struct sctp_paramhdr param_hdr;
749749
__be32 request_seq;
750-
__be16 list_of_streams[0];
750+
__be16 list_of_streams[];
751751
};
752752

753753
struct sctp_strreset_tsnreq {

0 commit comments

Comments
 (0)