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 params

This patch deletes the flexible-array params[] from the structure
sctp_inithdr, sctp_addiphdr and sctp_reconf_chunk to avoid some
sparse warnings:

# make C=2 CF="-Wflexible-array-nested" M=./net/sctp/
net/sctp/input.c: note: in included file (through include/net/sctp/structs.h, include/net/sctp/sctp.h):
./include/linux/sctp.h:278:29: warning: nested flexible array
./include/linux/sctp.h:675:30: warning: nested flexible array

This warning is reported if a structure having a flexible array
member is included by other structures.

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
add7370a 2f3a247c

+19 -19
+3 -3
include/linux/sctp.h
··· 270 270 __be16 num_outbound_streams; 271 271 __be16 num_inbound_streams; 272 272 __be32 initial_tsn; 273 - __u8 params[]; 273 + /* __u8 params[]; */ 274 274 }; 275 275 276 276 struct sctp_init_chunk { ··· 667 667 668 668 struct sctp_addiphdr { 669 669 __be32 serial; 670 - __u8 params[]; 670 + /* __u8 params[]; */ 671 671 }; 672 672 673 673 struct sctp_addip_chunk { ··· 742 742 743 743 struct sctp_reconf_chunk { 744 744 struct sctp_chunkhdr chunk_hdr; 745 - __u8 params[]; 745 + /* __u8 params[]; */ 746 746 }; 747 747 748 748 struct sctp_strreset_outreq {
+4 -4
include/net/sctp/sctp.h
··· 425 425 * the chunk length to indicate when to stop. Make sure 426 426 * there is room for a param header too. 427 427 */ 428 - #define sctp_walk_params(pos, chunk, member)\ 429 - _sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length), member) 428 + #define sctp_walk_params(pos, chunk)\ 429 + _sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length)) 430 430 431 - #define _sctp_walk_params(pos, chunk, end, member)\ 432 - for (pos.v = chunk->member;\ 431 + #define _sctp_walk_params(pos, chunk, end)\ 432 + for (pos.v = (u8 *)(chunk + 1);\ 433 433 (pos.v + offsetof(struct sctp_paramhdr, length) + sizeof(pos.p->length) <=\ 434 434 (void *)chunk + end) &&\ 435 435 pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\
+1 -1
net/sctp/input.c
··· 1150 1150 init = (struct sctp_init_chunk *)skb->data; 1151 1151 1152 1152 /* Walk the parameters looking for embedded addresses. */ 1153 - sctp_walk_params(params, init, init_hdr.params) { 1153 + sctp_walk_params(params, init) { 1154 1154 1155 1155 /* Note: Ignoring hostname addresses. */ 1156 1156 af = sctp_get_af_specific(param_type2af(params.p->type));
+9 -9
net/sctp/sm_make_chunk.c
··· 2306 2306 ntohl(peer_init->init_hdr.a_rwnd) < SCTP_DEFAULT_MINWINDOW) 2307 2307 return sctp_process_inv_mandatory(asoc, chunk, errp); 2308 2308 2309 - sctp_walk_params(param, peer_init, init_hdr.params) { 2309 + sctp_walk_params(param, peer_init) { 2310 2310 if (param.p->type == SCTP_PARAM_STATE_COOKIE) 2311 2311 has_cookie = true; 2312 2312 } ··· 2329 2329 chunk, errp); 2330 2330 2331 2331 /* Verify all the variable length parameters */ 2332 - sctp_walk_params(param, peer_init, init_hdr.params) { 2332 + sctp_walk_params(param, peer_init) { 2333 2333 result = sctp_verify_param(net, ep, asoc, param, cid, 2334 2334 chunk, errp); 2335 2335 switch (result) { ··· 2381 2381 src_match = 1; 2382 2382 2383 2383 /* Process the initialization parameters. */ 2384 - sctp_walk_params(param, peer_init, init_hdr.params) { 2384 + sctp_walk_params(param, peer_init) { 2385 2385 if (!src_match && 2386 2386 (param.p->type == SCTP_PARAM_IPV4_ADDRESS || 2387 2387 param.p->type == SCTP_PARAM_IPV6_ADDRESS)) { ··· 3202 3202 union sctp_params param; 3203 3203 3204 3204 addip = (struct sctp_addip_chunk *)chunk->chunk_hdr; 3205 - sctp_walk_params(param, addip, addip_hdr.params) { 3205 + sctp_walk_params(param, addip) { 3206 3206 size_t length = ntohs(param.p->length); 3207 3207 3208 3208 *errp = param.p; ··· 3215 3215 /* ensure there is only one addr param and it's in the 3216 3216 * beginning of addip_hdr params, or we reject it. 3217 3217 */ 3218 - if (param.v != addip->addip_hdr.params) 3218 + if (param.v != (addip + 1)) 3219 3219 return false; 3220 3220 addr_param_seen = true; 3221 3221 break; 3222 3222 case SCTP_PARAM_IPV6_ADDRESS: 3223 3223 if (length != sizeof(struct sctp_ipv6addr_param)) 3224 3224 return false; 3225 - if (param.v != addip->addip_hdr.params) 3225 + if (param.v != (addip + 1)) 3226 3226 return false; 3227 3227 addr_param_seen = true; 3228 3228 break; ··· 3302 3302 goto done; 3303 3303 3304 3304 /* Process the TLVs contained within the ASCONF chunk. */ 3305 - sctp_walk_params(param, addip, addip_hdr.params) { 3305 + sctp_walk_params(param, addip) { 3306 3306 /* Skip preceeding address parameters. */ 3307 3307 if (param.p->type == SCTP_PARAM_IPV4_ADDRESS || 3308 3308 param.p->type == SCTP_PARAM_IPV6_ADDRESS) ··· 3636 3636 return NULL; 3637 3637 3638 3638 reconf = (struct sctp_reconf_chunk *)retval->chunk_hdr; 3639 - retval->param_hdr.v = reconf->params; 3639 + retval->param_hdr.v = (u8 *)(reconf + 1); 3640 3640 3641 3641 return retval; 3642 3642 } ··· 3878 3878 __u16 cnt = 0; 3879 3879 3880 3880 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; 3881 - sctp_walk_params(param, hdr, params) { 3881 + sctp_walk_params(param, hdr) { 3882 3882 __u16 length = ntohs(param.p->length); 3883 3883 3884 3884 *errp = param.p;
+1 -1
net/sctp/sm_statefuns.c
··· 4142 4142 (void *)err_param, commands); 4143 4143 4144 4144 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; 4145 - sctp_walk_params(param, hdr, params) { 4145 + sctp_walk_params(param, hdr) { 4146 4146 struct sctp_chunk *reply = NULL; 4147 4147 struct sctp_ulpevent *ev = NULL; 4148 4148
+1 -1
net/sctp/stream.c
··· 491 491 return NULL; 492 492 493 493 hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; 494 - sctp_walk_params(param, hdr, params) { 494 + sctp_walk_params(param, hdr) { 495 495 /* sctp_strreset_tsnreq is actually the basic structure 496 496 * of all stream reconf params, so it's safe to use it 497 497 * to access request_seq.