Skip to content

Commit f97278f

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

4 files changed

Lines changed: 9 additions & 10 deletions

File tree

include/net/sctp/structs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ struct sctp_cookie {
332332
* the association TCB is re-constructed from the cookie.
333333
*/
334334
__u32 raw_addr_list_len;
335-
struct sctp_init_chunk peer_init[];
335+
/* struct sctp_init_chunk peer_init[]; */
336336
};
337337

338338

net/sctp/associola.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,9 +1597,10 @@ int sctp_assoc_set_bind_addr_from_cookie(struct sctp_association *asoc,
15971597
struct sctp_cookie *cookie,
15981598
gfp_t gfp)
15991599
{
1600-
int var_size2 = ntohs(cookie->peer_init->chunk_hdr.length);
1600+
struct sctp_init_chunk *peer_init = (struct sctp_init_chunk *)(cookie + 1);
1601+
int var_size2 = ntohs(peer_init->chunk_hdr.length);
16011602
int var_size3 = cookie->raw_addr_list_len;
1602-
__u8 *raw = (__u8 *)cookie->peer_init + var_size2;
1603+
__u8 *raw = (__u8 *)peer_init + var_size2;
16031604

16041605
return sctp_raw_to_bind_addrs(&asoc->base.bind_addr, raw, var_size3,
16051606
asoc->ep->base.bind_addr.port, gfp);

net/sctp/sm_make_chunk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,11 +1707,11 @@ static struct sctp_cookie_param *sctp_pack_cookie(
17071707
ktime_get_real());
17081708

17091709
/* Copy the peer's init packet. */
1710-
memcpy(&cookie->c.peer_init[0], init_chunk->chunk_hdr,
1710+
memcpy(cookie + 1, init_chunk->chunk_hdr,
17111711
ntohs(init_chunk->chunk_hdr->length));
17121712

17131713
/* Copy the raw local address list of the association. */
1714-
memcpy((__u8 *)&cookie->c.peer_init[0] +
1714+
memcpy((__u8 *)(cookie + 1) +
17151715
ntohs(init_chunk->chunk_hdr->length), raw_addrs, addrs_len);
17161716

17171717
if (sctp_sk(ep->base.sk)->hmac) {

net/sctp/sm_statefuns.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -794,8 +794,7 @@ enum sctp_disposition sctp_sf_do_5_1D_ce(struct net *net,
794794
/* This is a brand-new association, so these are not yet side
795795
* effects--it is safe to run them here.
796796
*/
797-
peer_init = &chunk->subh.cookie_hdr->c.peer_init[0];
798-
797+
peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1);
799798
if (!sctp_process_init(new_asoc, chunk,
800799
&chunk->subh.cookie_hdr->c.peer_addr,
801800
peer_init, GFP_ATOMIC))
@@ -1869,8 +1868,7 @@ static enum sctp_disposition sctp_sf_do_dupcook_a(
18691868
/* new_asoc is a brand-new association, so these are not yet
18701869
* side effects--it is safe to run them here.
18711870
*/
1872-
peer_init = &chunk->subh.cookie_hdr->c.peer_init[0];
1873-
1871+
peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1);
18741872
if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init,
18751873
GFP_ATOMIC))
18761874
goto nomem;
@@ -1990,7 +1988,7 @@ static enum sctp_disposition sctp_sf_do_dupcook_b(
19901988
/* new_asoc is a brand-new association, so these are not yet
19911989
* side effects--it is safe to run them here.
19921990
*/
1993-
peer_init = &chunk->subh.cookie_hdr->c.peer_init[0];
1991+
peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1);
19941992
if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init,
19951993
GFP_ATOMIC))
19961994
goto nomem;

0 commit comments

Comments
 (0)