Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c83c885 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'sctp-endianness-fixes'



Xin Long says:

====================
sctp: a bunch of fixes for some sparse warnings

As Eric noticed, when running 'make C=2 M=net/sctp/', a plenty of
warnings or errors checked by sparse appear. They are all problems
about Endian and type cast.

Most of them are just warnings by which no issues could be caused
while some might be bugs.

This patchset fixes them with four patches basically according to
how they are introduced.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 50317fce 978aa047
Loading
Loading
Loading
Loading
+17 −17
Original line number Original line Diff line number Diff line
@@ -231,7 +231,7 @@ struct sctp_datahdr {
	__be32 tsn;
	__be32 tsn;
	__be16 stream;
	__be16 stream;
	__be16 ssn;
	__be16 ssn;
	__be32 ppid;
	__u32 ppid;
	__u8  payload[0];
	__u8  payload[0];
};
};


@@ -716,28 +716,28 @@ struct sctp_reconf_chunk {


struct sctp_strreset_outreq {
struct sctp_strreset_outreq {
	struct sctp_paramhdr param_hdr;
	struct sctp_paramhdr param_hdr;
	__u32 request_seq;
	__be32 request_seq;
	__u32 response_seq;
	__be32 response_seq;
	__u32 send_reset_at_tsn;
	__be32 send_reset_at_tsn;
	__u16 list_of_streams[0];
	__be16 list_of_streams[0];
};
};


struct sctp_strreset_inreq {
struct sctp_strreset_inreq {
	struct sctp_paramhdr param_hdr;
	struct sctp_paramhdr param_hdr;
	__u32 request_seq;
	__be32 request_seq;
	__u16 list_of_streams[0];
	__be16 list_of_streams[0];
};
};


struct sctp_strreset_tsnreq {
struct sctp_strreset_tsnreq {
	struct sctp_paramhdr param_hdr;
	struct sctp_paramhdr param_hdr;
	__u32 request_seq;
	__be32 request_seq;
};
};


struct sctp_strreset_addstrm {
struct sctp_strreset_addstrm {
	struct sctp_paramhdr param_hdr;
	struct sctp_paramhdr param_hdr;
	__u32 request_seq;
	__be32 request_seq;
	__u16 number_of_streams;
	__be16 number_of_streams;
	__u16 reserved;
	__be16 reserved;
};
};


enum {
enum {
@@ -752,16 +752,16 @@ enum {


struct sctp_strreset_resp {
struct sctp_strreset_resp {
	struct sctp_paramhdr param_hdr;
	struct sctp_paramhdr param_hdr;
	__u32 response_seq;
	__be32 response_seq;
	__u32 result;
	__be32 result;
};
};


struct sctp_strreset_resptsn {
struct sctp_strreset_resptsn {
	struct sctp_paramhdr param_hdr;
	struct sctp_paramhdr param_hdr;
	__u32 response_seq;
	__be32 response_seq;
	__u32 result;
	__be32 result;
	__u32 senders_next_tsn;
	__be32 senders_next_tsn;
	__u32 receivers_next_tsn;
	__be32 receivers_next_tsn;
};
};


#endif /* __LINUX_SCTP_H__ */
#endif /* __LINUX_SCTP_H__ */
+1 −1
Original line number Original line Diff line number Diff line
@@ -261,7 +261,7 @@ struct sctp_chunk *sctp_make_fwdtsn(const struct sctp_association *asoc,
				    struct sctp_fwdtsn_skip *skiplist);
				    struct sctp_fwdtsn_skip *skiplist);
struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc);
struct sctp_chunk *sctp_make_auth(const struct sctp_association *asoc);
struct sctp_chunk *sctp_make_strreset_req(const struct sctp_association *asoc,
struct sctp_chunk *sctp_make_strreset_req(const struct sctp_association *asoc,
					  __u16 stream_num, __u16 *stream_list,
					  __u16 stream_num, __be16 *stream_list,
					  bool out, bool in);
					  bool out, bool in);
struct sctp_chunk *sctp_make_strreset_tsnreq(
struct sctp_chunk *sctp_make_strreset_tsnreq(
					const struct sctp_association *asoc);
					const struct sctp_association *asoc);
+1 −1
Original line number Original line Diff line number Diff line
@@ -130,7 +130,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_sender_dry_event(


struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event(
struct sctp_ulpevent *sctp_ulpevent_make_stream_reset_event(
	const struct sctp_association *asoc, __u16 flags,
	const struct sctp_association *asoc, __u16 flags,
	__u16 stream_num, __u16 *stream_list, gfp_t gfp);
	__u16 stream_num, __be16 *stream_list, gfp_t gfp);


struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event(
struct sctp_ulpevent *sctp_ulpevent_make_assoc_reset_event(
	const struct sctp_association *asoc, __u16 flags,
	const struct sctp_association *asoc, __u16 flags,
+1 −1
Original line number Original line Diff line number Diff line
@@ -376,7 +376,7 @@ struct sctp_remote_error {
	__u16 sre_type;
	__u16 sre_type;
	__u16 sre_flags;
	__u16 sre_flags;
	__u32 sre_length;
	__u32 sre_length;
	__u16 sre_error;
	__be16 sre_error;
	sctp_assoc_t sre_assoc_id;
	sctp_assoc_t sre_assoc_id;
	__u8 sre_data[0];
	__u8 sre_data[0];
};
};
+11 −11
Original line number Original line Diff line number Diff line
@@ -794,7 +794,7 @@ static struct sctp_endpoint *__sctp_rcv_lookup_endpoint(struct net *net,
struct sctp_hash_cmp_arg {
struct sctp_hash_cmp_arg {
	const union sctp_addr	*paddr;
	const union sctp_addr	*paddr;
	const struct net	*net;
	const struct net	*net;
	u16			lport;
	__be16			lport;
};
};


static inline int sctp_hash_cmp(struct rhashtable_compare_arg *arg,
static inline int sctp_hash_cmp(struct rhashtable_compare_arg *arg,
@@ -820,37 +820,37 @@ static inline int sctp_hash_cmp(struct rhashtable_compare_arg *arg,
	return err;
	return err;
}
}


static inline u32 sctp_hash_obj(const void *data, u32 len, u32 seed)
static inline __u32 sctp_hash_obj(const void *data, u32 len, u32 seed)
{
{
	const struct sctp_transport *t = data;
	const struct sctp_transport *t = data;
	const union sctp_addr *paddr = &t->ipaddr;
	const union sctp_addr *paddr = &t->ipaddr;
	const struct net *net = sock_net(t->asoc->base.sk);
	const struct net *net = sock_net(t->asoc->base.sk);
	u16 lport = htons(t->asoc->base.bind_addr.port);
	__be16 lport = htons(t->asoc->base.bind_addr.port);
	u32 addr;
	__u32 addr;


	if (paddr->sa.sa_family == AF_INET6)
	if (paddr->sa.sa_family == AF_INET6)
		addr = jhash(&paddr->v6.sin6_addr, 16, seed);
		addr = jhash(&paddr->v6.sin6_addr, 16, seed);
	else
	else
		addr = paddr->v4.sin_addr.s_addr;
		addr = (__force __u32)paddr->v4.sin_addr.s_addr;


	return  jhash_3words(addr, ((__u32)paddr->v4.sin_port) << 16 |
	return  jhash_3words(addr, ((__force __u32)paddr->v4.sin_port) << 16 |
			     (__force __u32)lport, net_hash_mix(net), seed);
			     (__force __u32)lport, net_hash_mix(net), seed);
}
}


static inline u32 sctp_hash_key(const void *data, u32 len, u32 seed)
static inline __u32 sctp_hash_key(const void *data, u32 len, u32 seed)
{
{
	const struct sctp_hash_cmp_arg *x = data;
	const struct sctp_hash_cmp_arg *x = data;
	const union sctp_addr *paddr = x->paddr;
	const union sctp_addr *paddr = x->paddr;
	const struct net *net = x->net;
	const struct net *net = x->net;
	u16 lport = x->lport;
	__be16 lport = x->lport;
	u32 addr;
	__u32 addr;


	if (paddr->sa.sa_family == AF_INET6)
	if (paddr->sa.sa_family == AF_INET6)
		addr = jhash(&paddr->v6.sin6_addr, 16, seed);
		addr = jhash(&paddr->v6.sin6_addr, 16, seed);
	else
	else
		addr = paddr->v4.sin_addr.s_addr;
		addr = (__force __u32)paddr->v4.sin_addr.s_addr;


	return  jhash_3words(addr, ((__u32)paddr->v4.sin_port) << 16 |
	return  jhash_3words(addr, ((__force __u32)paddr->v4.sin_port) << 16 |
			     (__force __u32)lport, net_hash_mix(net), seed);
			     (__force __u32)lport, net_hash_mix(net), seed);
}
}


Loading