Message ID | 1408705410-28558-2-git-send-email-dborkman@redhat.com |
---|---|
State | Accepted, archived |
Delegated to: | David Miller |
Headers | show |
On Fri, Aug 22, 2014 at 01:03:29PM +0200, Daniel Borkmann wrote: > 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 <dborkman@redhat.com> > --- > net/sctp/associola.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/sctp/associola.c b/net/sctp/associola.c > index aaafb32..104fae4 100644 > --- a/net/sctp/associola.c > +++ b/net/sctp/associola.c > @@ -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); Acked-by: Neil Horman <nhorman@tuxdriver.com> > -- > 1.7.11.7 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-sctp" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On 08/22/2014 07:03 AM, Daniel Borkmann wrote: > 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 <dborkman@redhat.com> Acked-by: Vlad Yasevich <vyasevich@gmail.com> -vlad > --- > net/sctp/associola.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/net/sctp/associola.c b/net/sctp/associola.c > index aaafb32..104fae4 100644 > --- a/net/sctp/associola.c > +++ b/net/sctp/associola.c > @@ -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); > -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/sctp/associola.c b/net/sctp/associola.c index aaafb32..104fae4 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c @@ -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);
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 <dborkman@redhat.com> --- net/sctp/associola.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)