Skip to content

Commit 9789c1c

Browse files
lxindavem330
authored andcommitted
sctp: delete the nested flexible array variable
This patch deletes the flexible-array variable[] from the structure sctp_sackhdr and sctp_errhdr to avoid some sparse warnings: # make C=2 CF="-Wflexible-array-nested" M=./net/sctp/ net/sctp/sm_statefuns.c: note: in included file (through include/net/sctp/structs.h, include/net/sctp/sctp.h): ./include/linux/sctp.h:451:28: warning: nested flexible array ./include/linux/sctp.h:393:29: warning: nested flexible array Signed-off-by: Xin Long <lucien.xin@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 73175a0 commit 9789c1c

4 files changed

Lines changed: 11 additions & 9 deletions

File tree

include/linux/sctp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ struct sctp_sackhdr {
385385
__be32 a_rwnd;
386386
__be16 num_gap_ack_blocks;
387387
__be16 num_dup_tsns;
388-
union sctp_sack_variable variable[];
388+
/* union sctp_sack_variable variable[]; */
389389
};
390390

391391
struct sctp_sack_chunk {
@@ -443,7 +443,7 @@ struct sctp_shutdown_chunk {
443443
struct sctp_errhdr {
444444
__be16 cause;
445445
__be16 length;
446-
__u8 variable[];
446+
/* __u8 variable[]; */
447447
};
448448

449449
struct sctp_operr_chunk {

net/sctp/outqueue.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ static void sctp_sack_update_unack_data(struct sctp_association *assoc,
12311231

12321232
unack_data = assoc->next_tsn - assoc->ctsn_ack_point - 1;
12331233

1234-
frags = sack->variable;
1234+
frags = (union sctp_sack_variable *)(sack + 1);
12351235
for (i = 0; i < ntohs(sack->num_gap_ack_blocks); i++) {
12361236
unack_data -= ((ntohs(frags[i].gab.end) -
12371237
ntohs(frags[i].gab.start) + 1));
@@ -1252,7 +1252,6 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_chunk *chunk)
12521252
struct sctp_transport *transport;
12531253
struct sctp_chunk *tchunk = NULL;
12541254
struct list_head *lchunk, *transport_list, *temp;
1255-
union sctp_sack_variable *frags = sack->variable;
12561255
__u32 sack_ctsn, ctsn, tsn;
12571256
__u32 highest_tsn, highest_new_tsn;
12581257
__u32 sack_a_rwnd;
@@ -1313,8 +1312,12 @@ int sctp_outq_sack(struct sctp_outq *q, struct sctp_chunk *chunk)
13131312

13141313
/* Get the highest TSN in the sack. */
13151314
highest_tsn = sack_ctsn;
1316-
if (gap_ack_blocks)
1315+
if (gap_ack_blocks) {
1316+
union sctp_sack_variable *frags =
1317+
(union sctp_sack_variable *)(sack + 1);
1318+
13171319
highest_tsn += ntohs(frags[gap_ack_blocks - 1].gab.end);
1320+
}
13181321

13191322
if (TSN_lt(asoc->highest_sacked, highest_tsn))
13201323
asoc->highest_sacked = highest_tsn;
@@ -1789,7 +1792,7 @@ static int sctp_acked(struct sctp_sackhdr *sack, __u32 tsn)
17891792
* Block are assumed to have been received correctly.
17901793
*/
17911794

1792-
frags = sack->variable;
1795+
frags = (union sctp_sack_variable *)(sack + 1);
17931796
blocks = ntohs(sack->num_gap_ack_blocks);
17941797
tsn_offset = tsn - ctsn;
17951798
for (i = 0; i < blocks; ++i) {

net/sctp/sm_sideeffect.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,8 +984,7 @@ static void sctp_cmd_process_operr(struct sctp_cmd_seq *cmds,
984984
{
985985
struct sctp_chunkhdr *unk_chunk_hdr;
986986

987-
unk_chunk_hdr = (struct sctp_chunkhdr *)
988-
err_hdr->variable;
987+
unk_chunk_hdr = (struct sctp_chunkhdr *)(err_hdr + 1);
989988
switch (unk_chunk_hdr->type) {
990989
/* ADDIP 4.1 A9) If the peer responds to an ASCONF with
991990
* an ERROR chunk reporting that it did not recognized

net/sctp/sm_statefuns.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1337,7 +1337,7 @@ static int sctp_sf_send_restart_abort(struct net *net, union sctp_addr *ssa,
13371337
* throughout the code today.
13381338
*/
13391339
errhdr = (struct sctp_errhdr *)buffer;
1340-
addrparm = (union sctp_addr_param *)errhdr->variable;
1340+
addrparm = (union sctp_addr_param *)(errhdr + 1);
13411341

13421342
/* Copy into a parm format. */
13431343
len = af->to_addr_param(ssa, addrparm);

0 commit comments

Comments
 (0)