Skip to content

Commit 8e2ef6a

Browse files
Mao Wenandavem330
authored andcommitted
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 62208f1 ("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. Signed-off-by: Mao Wenan <[email protected]> Acked-by: Marcelo Ricardo Leitner <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8f6617b commit 8e2ef6a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

net/sctp/socket.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ static int sctp_bind(struct sock *sk, struct sockaddr *addr, int addr_len)
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)
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 @@ static long sctp_get_port_local(struct sock *sk, union sctp_addr *addr)
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)
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
/*

0 commit comments

Comments
 (0)