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 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>

authored by

Xin Long and committed by
David S. Miller
f97278ff 9789c1c6

+9 -10
+1 -1
include/net/sctp/structs.h
··· 332 332 * the association TCB is re-constructed from the cookie. 333 333 */ 334 334 __u32 raw_addr_list_len; 335 - struct sctp_init_chunk peer_init[]; 335 + /* struct sctp_init_chunk peer_init[]; */ 336 336 }; 337 337 338 338
+3 -2
net/sctp/associola.c
··· 1597 1597 struct sctp_cookie *cookie, 1598 1598 gfp_t gfp) 1599 1599 { 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); 1601 1602 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; 1603 1604 1604 1605 return sctp_raw_to_bind_addrs(&asoc->base.bind_addr, raw, var_size3, 1605 1606 asoc->ep->base.bind_addr.port, gfp);
+2 -2
net/sctp/sm_make_chunk.c
··· 1707 1707 ktime_get_real()); 1708 1708 1709 1709 /* 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, 1711 1711 ntohs(init_chunk->chunk_hdr->length)); 1712 1712 1713 1713 /* Copy the raw local address list of the association. */ 1714 - memcpy((__u8 *)&cookie->c.peer_init[0] + 1714 + memcpy((__u8 *)(cookie + 1) + 1715 1715 ntohs(init_chunk->chunk_hdr->length), raw_addrs, addrs_len); 1716 1716 1717 1717 if (sctp_sk(ep->base.sk)->hmac) {
+3 -5
net/sctp/sm_statefuns.c
··· 794 794 /* This is a brand-new association, so these are not yet side 795 795 * effects--it is safe to run them here. 796 796 */ 797 - peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; 798 - 797 + peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); 799 798 if (!sctp_process_init(new_asoc, chunk, 800 799 &chunk->subh.cookie_hdr->c.peer_addr, 801 800 peer_init, GFP_ATOMIC)) ··· 1868 1869 /* new_asoc is a brand-new association, so these are not yet 1869 1870 * side effects--it is safe to run them here. 1870 1871 */ 1871 - peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; 1872 - 1872 + peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); 1873 1873 if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init, 1874 1874 GFP_ATOMIC)) 1875 1875 goto nomem; ··· 1988 1990 /* new_asoc is a brand-new association, so these are not yet 1989 1991 * side effects--it is safe to run them here. 1990 1992 */ 1991 - peer_init = &chunk->subh.cookie_hdr->c.peer_init[0]; 1993 + peer_init = (struct sctp_init_chunk *)(chunk->subh.cookie_hdr + 1); 1992 1994 if (!sctp_process_init(new_asoc, chunk, sctp_source(chunk), peer_init, 1993 1995 GFP_ATOMIC)) 1994 1996 goto nomem;