Skip to content

Commit a51a40b

Browse files
committed
Merge branch 'sctp-fix-sparse-errors'
Xin Long says: ==================== sctp: fix some other sparse errors After the last fixes for sparse errors, there are still three sparse errors in sctp codes, two of them are type cast, and the other one is using extern. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents f95d5bf + 1ba896f commit a51a40b

File tree

8 files changed

+49
-16
lines changed

8 files changed

+49
-16
lines changed

include/net/sctp/checksum.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,31 +48,32 @@ static inline __wsum sctp_csum_update(const void *buff, int len, __wsum sum)
4848
/* This uses the crypto implementation of crc32c, which is either
4949
* implemented w/ hardware support or resolves to __crc32c_le().
5050
*/
51-
return crc32c(sum, buff, len);
51+
return (__force __wsum)crc32c((__force __u32)sum, buff, len);
5252
}
5353

5454
static inline __wsum sctp_csum_combine(__wsum csum, __wsum csum2,
5555
int offset, int len)
5656
{
57-
return __crc32c_le_combine(csum, csum2, len);
57+
return (__force __wsum)__crc32c_le_combine((__force __u32)csum,
58+
(__force __u32)csum2, len);
5859
}
5960

6061
static inline __le32 sctp_compute_cksum(const struct sk_buff *skb,
6162
unsigned int offset)
6263
{
6364
struct sctphdr *sh = sctp_hdr(skb);
64-
__le32 ret, old = sh->checksum;
6565
const struct skb_checksum_ops ops = {
6666
.update = sctp_csum_update,
6767
.combine = sctp_csum_combine,
6868
};
69+
__le32 old = sh->checksum;
70+
__wsum new;
6971

7072
sh->checksum = 0;
71-
ret = cpu_to_le32(~__skb_checksum(skb, offset, skb->len - offset,
72-
~(__u32)0, &ops));
73+
new = ~__skb_checksum(skb, offset, skb->len - offset, ~(__wsum)0, &ops);
7374
sh->checksum = old;
7475

75-
return ret;
76+
return cpu_to_le32((__force __u32)new);
7677
}
7778

7879
#endif /* __sctp_checksum_h__ */

include/net/sctp/sctp.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ void sctp_remaddr_proc_exit(struct net *net);
194194
*/
195195
int sctp_offload_init(void);
196196

197+
/*
198+
* sctp/stream_sched.c
199+
*/
200+
void sctp_sched_ops_init(void);
201+
197202
/*
198203
* sctp/stream.c
199204
*/

include/net/sctp/stream_sched.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,9 @@ void sctp_sched_dequeue_common(struct sctp_outq *q, struct sctp_chunk *ch);
6969
int sctp_sched_init_sid(struct sctp_stream *stream, __u16 sid, gfp_t gfp);
7070
struct sctp_sched_ops *sctp_sched_ops_from_stream(struct sctp_stream *stream);
7171

72+
void sctp_sched_ops_register(enum sctp_sched_type sched,
73+
struct sctp_sched_ops *sched_ops);
74+
void sctp_sched_ops_prio_init(void);
75+
void sctp_sched_ops_rr_init(void);
76+
7277
#endif /* __sctp_stream_sched_h__ */

net/sctp/protocol.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,6 +1499,7 @@ static __init int sctp_init(void)
14991499
INIT_LIST_HEAD(&sctp_address_families);
15001500
sctp_v4_pf_init();
15011501
sctp_v6_pf_init();
1502+
sctp_sched_ops_init();
15021503

15031504
status = register_pernet_subsys(&sctp_defaults_ops);
15041505
if (status)

net/sctp/stream.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void sctp_stream_outq_migrate(struct sctp_stream *stream,
6464
*/
6565

6666
/* Mark as failed send. */
67-
sctp_chunk_fail(ch, SCTP_ERROR_INV_STRM);
67+
sctp_chunk_fail(ch, (__force __u32)SCTP_ERROR_INV_STRM);
6868
if (asoc->peer.prsctp_capable &&
6969
SCTP_PR_PRIO_ENABLED(ch->sinfo.sinfo_flags))
7070
asoc->sent_cnt_removable--;

net/sctp/stream_sched.c

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,27 @@ static struct sctp_sched_ops sctp_sched_fcfs = {
119119
.unsched_all = sctp_sched_fcfs_unsched_all,
120120
};
121121

122+
static void sctp_sched_ops_fcfs_init(void)
123+
{
124+
sctp_sched_ops_register(SCTP_SS_FCFS, &sctp_sched_fcfs);
125+
}
126+
122127
/* API to other parts of the stack */
123128

124-
extern struct sctp_sched_ops sctp_sched_prio;
125-
extern struct sctp_sched_ops sctp_sched_rr;
129+
static struct sctp_sched_ops *sctp_sched_ops[SCTP_SS_MAX + 1];
126130

127-
static struct sctp_sched_ops *sctp_sched_ops[] = {
128-
&sctp_sched_fcfs,
129-
&sctp_sched_prio,
130-
&sctp_sched_rr,
131-
};
131+
void sctp_sched_ops_register(enum sctp_sched_type sched,
132+
struct sctp_sched_ops *sched_ops)
133+
{
134+
sctp_sched_ops[sched] = sched_ops;
135+
}
136+
137+
void sctp_sched_ops_init(void)
138+
{
139+
sctp_sched_ops_fcfs_init();
140+
sctp_sched_ops_prio_init();
141+
sctp_sched_ops_rr_init();
142+
}
132143

133144
int sctp_sched_set_sched(struct sctp_association *asoc,
134145
enum sctp_sched_type sched)

net/sctp/stream_sched_prio.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ static void sctp_sched_prio_unsched_all(struct sctp_stream *stream)
333333
sctp_sched_prio_unsched(soute);
334334
}
335335

336-
struct sctp_sched_ops sctp_sched_prio = {
336+
static struct sctp_sched_ops sctp_sched_prio = {
337337
.set = sctp_sched_prio_set,
338338
.get = sctp_sched_prio_get,
339339
.init = sctp_sched_prio_init,
@@ -345,3 +345,8 @@ struct sctp_sched_ops sctp_sched_prio = {
345345
.sched_all = sctp_sched_prio_sched_all,
346346
.unsched_all = sctp_sched_prio_unsched_all,
347347
};
348+
349+
void sctp_sched_ops_prio_init(void)
350+
{
351+
sctp_sched_ops_register(SCTP_SS_PRIO, &sctp_sched_prio);
352+
}

net/sctp/stream_sched_rr.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ static void sctp_sched_rr_unsched_all(struct sctp_stream *stream)
187187
sctp_sched_rr_unsched(stream, soute);
188188
}
189189

190-
struct sctp_sched_ops sctp_sched_rr = {
190+
static struct sctp_sched_ops sctp_sched_rr = {
191191
.set = sctp_sched_rr_set,
192192
.get = sctp_sched_rr_get,
193193
.init = sctp_sched_rr_init,
@@ -199,3 +199,8 @@ struct sctp_sched_ops sctp_sched_rr = {
199199
.sched_all = sctp_sched_rr_sched_all,
200200
.unsched_all = sctp_sched_rr_unsched_all,
201201
};
202+
203+
void sctp_sched_ops_rr_init(void)
204+
{
205+
sctp_sched_ops_register(SCTP_SS_RR, &sctp_sched_rr);
206+
}

0 commit comments

Comments
 (0)