Skip to content

Commit

Permalink
net: sctp: spare unnecessary comparison in sctp_trans_elect_best
Browse files Browse the repository at this point in the history
When both transports are the same, we don't have to go down that
road only to realize that we will return the very same transport.
We are guaranteed that curr is always non-NULL. Therefore, just
short-circuit this special case.

Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Neil Horman <[email protected]>
Acked-by: Vlad Yasevich <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Daniel Borkmann authored and davem330 committed Aug 22, 2014
1 parent 7d149c5 commit ea4f19c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/sctp/associola.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ static struct sctp_transport *sctp_trans_elect_best(struct sctp_transport *curr,
{
u8 score_curr, score_best;

if (best == NULL)
if (best == NULL || curr == best)
return curr;

score_curr = sctp_trans_score(curr);
Expand Down

0 comments on commit ea4f19c

Please sign in to comment.