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

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>

authored by

Xin Long and committed by
David S. Miller
9789c1c6 73175a04

+11 -9
+2 -2
include/linux/sctp.h
··· 385 385 __be32 a_rwnd; 386 386 __be16 num_gap_ack_blocks; 387 387 __be16 num_dup_tsns; 388 - union sctp_sack_variable variable[]; 388 + /* union sctp_sack_variable variable[]; */ 389 389 }; 390 390 391 391 struct sctp_sack_chunk { ··· 443 443 struct sctp_errhdr { 444 444 __be16 cause; 445 445 __be16 length; 446 - __u8 variable[]; 446 + /* __u8 variable[]; */ 447 447 }; 448 448 449 449 struct sctp_operr_chunk {
+7 -4
net/sctp/outqueue.c
··· 1231 1231 1232 1232 unack_data = assoc->next_tsn - assoc->ctsn_ack_point - 1; 1233 1233 1234 - frags = sack->variable; 1234 + frags = (union sctp_sack_variable *)(sack + 1); 1235 1235 for (i = 0; i < ntohs(sack->num_gap_ack_blocks); i++) { 1236 1236 unack_data -= ((ntohs(frags[i].gab.end) - 1237 1237 ntohs(frags[i].gab.start) + 1)); ··· 1252 1252 struct sctp_transport *transport; 1253 1253 struct sctp_chunk *tchunk = NULL; 1254 1254 struct list_head *lchunk, *transport_list, *temp; 1255 - union sctp_sack_variable *frags = sack->variable; 1256 1255 __u32 sack_ctsn, ctsn, tsn; 1257 1256 __u32 highest_tsn, highest_new_tsn; 1258 1257 __u32 sack_a_rwnd; ··· 1312 1313 1313 1314 /* Get the highest TSN in the sack. */ 1314 1315 highest_tsn = sack_ctsn; 1315 - if (gap_ack_blocks) 1316 + if (gap_ack_blocks) { 1317 + union sctp_sack_variable *frags = 1318 + (union sctp_sack_variable *)(sack + 1); 1319 + 1316 1320 highest_tsn += ntohs(frags[gap_ack_blocks - 1].gab.end); 1321 + } 1317 1322 1318 1323 if (TSN_lt(asoc->highest_sacked, highest_tsn)) 1319 1324 asoc->highest_sacked = highest_tsn; ··· 1792 1789 * Block are assumed to have been received correctly. 1793 1790 */ 1794 1791 1795 - frags = sack->variable; 1792 + frags = (union sctp_sack_variable *)(sack + 1); 1796 1793 blocks = ntohs(sack->num_gap_ack_blocks); 1797 1794 tsn_offset = tsn - ctsn; 1798 1795 for (i = 0; i < blocks; ++i) {
+1 -2
net/sctp/sm_sideeffect.c
··· 984 984 { 985 985 struct sctp_chunkhdr *unk_chunk_hdr; 986 986 987 - unk_chunk_hdr = (struct sctp_chunkhdr *) 988 - err_hdr->variable; 987 + unk_chunk_hdr = (struct sctp_chunkhdr *)(err_hdr + 1); 989 988 switch (unk_chunk_hdr->type) { 990 989 /* ADDIP 4.1 A9) If the peer responds to an ASCONF with 991 990 * an ERROR chunk reporting that it did not recognized
+1 -1
net/sctp/sm_statefuns.c
··· 1337 1337 * throughout the code today. 1338 1338 */ 1339 1339 errhdr = (struct sctp_errhdr *)buffer; 1340 - addrparm = (union sctp_addr_param *)errhdr->variable; 1340 + addrparm = (union sctp_addr_param *)(errhdr + 1); 1341 1341 1342 1342 /* Copy into a parm format. */ 1343 1343 len = af->to_addr_param(ssa, addrparm);