Currently sctp_get_port_local() returns a long which is either 0,1 or a pointer casted to long. It's neither of the callers use the return value since commit 62208f12451f ("net: sctp: simplify sctp_get_port"). Now two callers are sctp_get_port and sctp_do_bind, they actually assumend a casted to an int was the same as a pointer casted to a long, and they don't save the return value just check whether it is zero or non-zero, so it would better change return type from long to int for sctp_get_port_local.
Unified · Split
| @@ -309,7 +309,7 @@ static int sctp_bind(struct sock *sk, struct sockaddr *addr, int addr_len) · 308 unmodified lines | ||
| 309 | 309 | return retval; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | −static long sctp_get_port_local(struct sock *, union sctp_addr *); | |
| 312 | +static int sctp_get_port_local(struct sock *, union sctp_addr *); | |
| 313 | 313 | |
| 314 | 314 | /* Verify this is a valid sockaddr. */ |
| 315 | 315 | static struct sctp_af *sctp_sockaddr_af(struct sctp_sock *opt, |
| @@ -7999,7 +7999,7 @@ static void sctp_unhash(struct sock *sk) · 7683 unmodified lines | ||
| 7999 | 7999 | static struct sctp_bind_bucket *sctp_bucket_create( |
| 8000 | 8000 | struct sctp_bind_hashbucket *head, struct net *, unsigned short snum); |
| 8001 | 8001 | |
| 8002 | −static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr) | |
| 8002 | +static int sctp_get_port_local(struct sock *sk, union sctp_addr *addr) | |
| 8003 | 8003 | { |
| 8004 | 8004 | struct sctp_sock *sp = sctp_sk(sk); |
| 8005 | 8005 | bool reuse = (sk->sk_reuse || sp->reuse); |
| @@ -8109,7 +8109,7 @@ pp_found: · 103 unmodified lines | ||
| 8109 | 8109 | |
| 8110 | 8110 | if (sctp_bind_addr_conflict(&ep2->base.bind_addr, |
| 8111 | 8111 | addr, sp2, sp)) { |
| 8112 | − ret = (long)sk2; | |
| 8112 | + ret = 1; | |
| 8113 | 8113 | goto fail_unlock; |
| 8114 | 8114 | } |
| 8115 | 8115 | } |
| @@ -8181,7 +8181,7 @@ static int sctp_get_port(struct sock *sk, unsigned short snum) · 65 unmodified lines | ||
| 8181 | 8181 | addr.v4.sin_port = htons(snum); |
| 8182 | 8182 | |
| 8183 | 8183 | /* Note: sk->sk_num gets filled in if ephemeral port request. */ |
| 8184 | − return !!sctp_get_port_local(sk, &addr); | |
| 8184 | + return sctp_get_port_local(sk, &addr); | |
| 8185 | 8185 | } |
| 8186 | 8186 | |
| 8187 | 8187 | /* |