Commit add7370a authored by Xin Long's avatar Xin Long Committed by David S. Miller

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: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2f3a247c
...@@ -270,7 +270,7 @@ struct sctp_inithdr { ...@@ -270,7 +270,7 @@ struct sctp_inithdr {
__be16 num_outbound_streams; __be16 num_outbound_streams;
__be16 num_inbound_streams; __be16 num_inbound_streams;
__be32 initial_tsn; __be32 initial_tsn;
__u8 params[]; /* __u8 params[]; */
}; };
struct sctp_init_chunk { struct sctp_init_chunk {
...@@ -667,7 +667,7 @@ struct sctp_addip_param { ...@@ -667,7 +667,7 @@ struct sctp_addip_param {
struct sctp_addiphdr { struct sctp_addiphdr {
__be32 serial; __be32 serial;
__u8 params[]; /* __u8 params[]; */
}; };
struct sctp_addip_chunk { struct sctp_addip_chunk {
...@@ -742,7 +742,7 @@ struct sctp_infox { ...@@ -742,7 +742,7 @@ struct sctp_infox {
struct sctp_reconf_chunk { struct sctp_reconf_chunk {
struct sctp_chunkhdr chunk_hdr; struct sctp_chunkhdr chunk_hdr;
__u8 params[]; /* __u8 params[]; */
}; };
struct sctp_strreset_outreq { struct sctp_strreset_outreq {
......
...@@ -425,11 +425,11 @@ static inline bool sctp_chunk_pending(const struct sctp_chunk *chunk) ...@@ -425,11 +425,11 @@ static inline bool sctp_chunk_pending(const struct sctp_chunk *chunk)
* the chunk length to indicate when to stop. Make sure * the chunk length to indicate when to stop. Make sure
* there is room for a param header too. * there is room for a param header too.
*/ */
#define sctp_walk_params(pos, chunk, member)\ #define sctp_walk_params(pos, chunk)\
_sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length), member) _sctp_walk_params((pos), (chunk), ntohs((chunk)->chunk_hdr.length))
#define _sctp_walk_params(pos, chunk, end, member)\ #define _sctp_walk_params(pos, chunk, end)\
for (pos.v = chunk->member;\ for (pos.v = (u8 *)(chunk + 1);\
(pos.v + offsetof(struct sctp_paramhdr, length) + sizeof(pos.p->length) <=\ (pos.v + offsetof(struct sctp_paramhdr, length) + sizeof(pos.p->length) <=\
(void *)chunk + end) &&\ (void *)chunk + end) &&\
pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\ pos.v <= (void *)chunk + end - ntohs(pos.p->length) &&\
......
...@@ -1150,7 +1150,7 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct net *net, ...@@ -1150,7 +1150,7 @@ static struct sctp_association *__sctp_rcv_init_lookup(struct net *net,
init = (struct sctp_init_chunk *)skb->data; init = (struct sctp_init_chunk *)skb->data;
/* Walk the parameters looking for embedded addresses. */ /* Walk the parameters looking for embedded addresses. */
sctp_walk_params(params, init, init_hdr.params) { sctp_walk_params(params, init) {
/* Note: Ignoring hostname addresses. */ /* Note: Ignoring hostname addresses. */
af = sctp_get_af_specific(param_type2af(params.p->type)); af = sctp_get_af_specific(param_type2af(params.p->type));
......
...@@ -2306,7 +2306,7 @@ int sctp_verify_init(struct net *net, const struct sctp_endpoint *ep, ...@@ -2306,7 +2306,7 @@ int sctp_verify_init(struct net *net, const struct sctp_endpoint *ep,
ntohl(peer_init->init_hdr.a_rwnd) < SCTP_DEFAULT_MINWINDOW) ntohl(peer_init->init_hdr.a_rwnd) < SCTP_DEFAULT_MINWINDOW)
return sctp_process_inv_mandatory(asoc, chunk, errp); return sctp_process_inv_mandatory(asoc, chunk, errp);
sctp_walk_params(param, peer_init, init_hdr.params) { sctp_walk_params(param, peer_init) {
if (param.p->type == SCTP_PARAM_STATE_COOKIE) if (param.p->type == SCTP_PARAM_STATE_COOKIE)
has_cookie = true; has_cookie = true;
} }
...@@ -2329,7 +2329,7 @@ int sctp_verify_init(struct net *net, const struct sctp_endpoint *ep, ...@@ -2329,7 +2329,7 @@ int sctp_verify_init(struct net *net, const struct sctp_endpoint *ep,
chunk, errp); chunk, errp);
/* Verify all the variable length parameters */ /* Verify all the variable length parameters */
sctp_walk_params(param, peer_init, init_hdr.params) { sctp_walk_params(param, peer_init) {
result = sctp_verify_param(net, ep, asoc, param, cid, result = sctp_verify_param(net, ep, asoc, param, cid,
chunk, errp); chunk, errp);
switch (result) { switch (result) {
...@@ -2381,7 +2381,7 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk, ...@@ -2381,7 +2381,7 @@ int sctp_process_init(struct sctp_association *asoc, struct sctp_chunk *chunk,
src_match = 1; src_match = 1;
/* Process the initialization parameters. */ /* Process the initialization parameters. */
sctp_walk_params(param, peer_init, init_hdr.params) { sctp_walk_params(param, peer_init) {
if (!src_match && if (!src_match &&
(param.p->type == SCTP_PARAM_IPV4_ADDRESS || (param.p->type == SCTP_PARAM_IPV4_ADDRESS ||
param.p->type == SCTP_PARAM_IPV6_ADDRESS)) { param.p->type == SCTP_PARAM_IPV6_ADDRESS)) {
...@@ -3202,7 +3202,7 @@ bool sctp_verify_asconf(const struct sctp_association *asoc, ...@@ -3202,7 +3202,7 @@ bool sctp_verify_asconf(const struct sctp_association *asoc,
union sctp_params param; union sctp_params param;
addip = (struct sctp_addip_chunk *)chunk->chunk_hdr; addip = (struct sctp_addip_chunk *)chunk->chunk_hdr;
sctp_walk_params(param, addip, addip_hdr.params) { sctp_walk_params(param, addip) {
size_t length = ntohs(param.p->length); size_t length = ntohs(param.p->length);
*errp = param.p; *errp = param.p;
...@@ -3215,14 +3215,14 @@ bool sctp_verify_asconf(const struct sctp_association *asoc, ...@@ -3215,14 +3215,14 @@ bool sctp_verify_asconf(const struct sctp_association *asoc,
/* ensure there is only one addr param and it's in the /* ensure there is only one addr param and it's in the
* beginning of addip_hdr params, or we reject it. * beginning of addip_hdr params, or we reject it.
*/ */
if (param.v != addip->addip_hdr.params) if (param.v != (addip + 1))
return false; return false;
addr_param_seen = true; addr_param_seen = true;
break; break;
case SCTP_PARAM_IPV6_ADDRESS: case SCTP_PARAM_IPV6_ADDRESS:
if (length != sizeof(struct sctp_ipv6addr_param)) if (length != sizeof(struct sctp_ipv6addr_param))
return false; return false;
if (param.v != addip->addip_hdr.params) if (param.v != (addip + 1))
return false; return false;
addr_param_seen = true; addr_param_seen = true;
break; break;
...@@ -3302,7 +3302,7 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc, ...@@ -3302,7 +3302,7 @@ struct sctp_chunk *sctp_process_asconf(struct sctp_association *asoc,
goto done; goto done;
/* Process the TLVs contained within the ASCONF chunk. */ /* Process the TLVs contained within the ASCONF chunk. */
sctp_walk_params(param, addip, addip_hdr.params) { sctp_walk_params(param, addip) {
/* Skip preceeding address parameters. */ /* Skip preceeding address parameters. */
if (param.p->type == SCTP_PARAM_IPV4_ADDRESS || if (param.p->type == SCTP_PARAM_IPV4_ADDRESS ||
param.p->type == SCTP_PARAM_IPV6_ADDRESS) param.p->type == SCTP_PARAM_IPV6_ADDRESS)
...@@ -3636,7 +3636,7 @@ static struct sctp_chunk *sctp_make_reconf(const struct sctp_association *asoc, ...@@ -3636,7 +3636,7 @@ static struct sctp_chunk *sctp_make_reconf(const struct sctp_association *asoc,
return NULL; return NULL;
reconf = (struct sctp_reconf_chunk *)retval->chunk_hdr; reconf = (struct sctp_reconf_chunk *)retval->chunk_hdr;
retval->param_hdr.v = reconf->params; retval->param_hdr.v = (u8 *)(reconf + 1);
return retval; return retval;
} }
...@@ -3878,7 +3878,7 @@ bool sctp_verify_reconf(const struct sctp_association *asoc, ...@@ -3878,7 +3878,7 @@ bool sctp_verify_reconf(const struct sctp_association *asoc,
__u16 cnt = 0; __u16 cnt = 0;
hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr;
sctp_walk_params(param, hdr, params) { sctp_walk_params(param, hdr) {
__u16 length = ntohs(param.p->length); __u16 length = ntohs(param.p->length);
*errp = param.p; *errp = param.p;
......
...@@ -4142,7 +4142,7 @@ enum sctp_disposition sctp_sf_do_reconf(struct net *net, ...@@ -4142,7 +4142,7 @@ enum sctp_disposition sctp_sf_do_reconf(struct net *net,
(void *)err_param, commands); (void *)err_param, commands);
hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr;
sctp_walk_params(param, hdr, params) { sctp_walk_params(param, hdr) {
struct sctp_chunk *reply = NULL; struct sctp_chunk *reply = NULL;
struct sctp_ulpevent *ev = NULL; struct sctp_ulpevent *ev = NULL;
......
...@@ -491,7 +491,7 @@ static struct sctp_paramhdr *sctp_chunk_lookup_strreset_param( ...@@ -491,7 +491,7 @@ static struct sctp_paramhdr *sctp_chunk_lookup_strreset_param(
return NULL; return NULL;
hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr; hdr = (struct sctp_reconf_chunk *)chunk->chunk_hdr;
sctp_walk_params(param, hdr, params) { sctp_walk_params(param, hdr) {
/* sctp_strreset_tsnreq is actually the basic structure /* sctp_strreset_tsnreq is actually the basic structure
* of all stream reconf params, so it's safe to use it * of all stream reconf params, so it's safe to use it
* to access request_seq. * to access request_seq.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment