History

sctp: change return type of sctp_get_port_local

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.

Mao Wenan committed 7 years ago

Commit 8e2ef6a1 parent 8f6617b1 file · +4 −4Browse files

Unified · Split

net/sctp/socket.c+4−4
@@ -309,7 +309,7 @@ static int sctp_bind(struct sock *sk, struct sockaddr *addr, int addr_len) · 308 unmodified lines
309309 return retval;
310310 }
311311
312−static long sctp_get_port_local(struct sock *, union sctp_addr *);
312+static int sctp_get_port_local(struct sock *, union sctp_addr *);
313313
314314 /* Verify this is a valid sockaddr. */
315315 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
79997999 static struct sctp_bind_bucket *sctp_bucket_create(
80008000 struct sctp_bind_hashbucket *head, struct net *, unsigned short snum);
80018001
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)
80038003 {
80048004 struct sctp_sock *sp = sctp_sk(sk);
80058005 bool reuse = (sk->sk_reuse || sp->reuse);
@@ -8109,7 +8109,7 @@ pp_found: · 103 unmodified lines
81098109
81108110 if (sctp_bind_addr_conflict(&ep2->base.bind_addr,
81118111 addr, sp2, sp)) {
8112− ret = (long)sk2;
8112+ ret = 1;
81138113 goto fail_unlock;
81148114 }
81158115 }
@@ -8181,7 +8181,7 @@ static int sctp_get_port(struct sock *sk, unsigned short snum) · 65 unmodified lines
81818181 addr.v4.sin_port = htons(snum);
81828182
81838183 /* 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);
81858185 }
81868186
81878187 /*