diff mbox

[net-next,3/9] net: phy: dp83640: fix checkpath error

Message ID 1387345093-14168-4-git-send-email-f.fainelli@gmail.com
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

Florian Fainelli Dec. 18, 2013, 5:38 a.m. UTC
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
 drivers/net/phy/dp83640.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Joe Perches Dec. 19, 2013, 10:31 p.m. UTC | #1
On Tue, 2013-12-17 at 21:38 -0800, Florian Fainelli wrote:
> diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
[]
> @@ -851,8 +851,8 @@ static int match(struct sk_buff *skb, unsigned int type, struct rxts *rxts)
>  
>  	seqid = (u16 *)(data + offset + OFF_PTP_SEQUENCE_ID);
>  
> -	return (rxts->msgtype == (*msgtype & 0xf) &&
> -		rxts->seqid   == ntohs(*seqid));
> +	return rxts->msgtype == (*msgtype & 0xf) &&
> +		rxts->seqid   == ntohs(*seqid);

I think this isn't an improvement.

Maybe:

	return rxts->msgtype == (*msgtype & 0xf) &&
	       rxts->seqid == ntohs(*seqid);

or

	return (rxts->msgtype == (*msgtype & 0xf)) &&
	       (rxts->seqid == ntohs(*seqid));


--
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
David Laight Dec. 20, 2013, 9:46 a.m. UTC | #2
> From: Joe Perches
> Sent: 19 December 2013 22:31
> On Tue, 2013-12-17 at 21:38 -0800, Florian Fainelli wrote:
> > diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
> []
> > @@ -851,8 +851,8 @@ static int match(struct sk_buff *skb, unsigned int type, struct rxts *rxts)
> >
> >  	seqid = (u16 *)(data + offset + OFF_PTP_SEQUENCE_ID);
> >
> > -	return (rxts->msgtype == (*msgtype & 0xf) &&
> > -		rxts->seqid   == ntohs(*seqid));
> > +	return rxts->msgtype == (*msgtype & 0xf) &&
> > +		rxts->seqid   == ntohs(*seqid);
> 
> I think this isn't an improvement.
> 
> Maybe:
> 	return rxts->msgtype == (*msgtype & 0xf) &&
> 	       rxts->seqid == ntohs(*seqid);
> or
> 	return (rxts->msgtype == (*msgtype & 0xf)) &&
> 	       (rxts->seqid == ntohs(*seqid));

Or even (modulo stupid errors):
	return !((rxts->msgtype ^ (*msgtype & 0xf))
		  | (rxts->seqid ^ ntohs(*seqid)));
which saves a branch if the conditional is usually true.

	David



--
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 mbox

Patch

diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 7490b6c..547725f 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -851,8 +851,8 @@  static int match(struct sk_buff *skb, unsigned int type, struct rxts *rxts)
 
 	seqid = (u16 *)(data + offset + OFF_PTP_SEQUENCE_ID);
 
-	return (rxts->msgtype == (*msgtype & 0xf) &&
-		rxts->seqid   == ntohs(*seqid));
+	return rxts->msgtype == (*msgtype & 0xf) &&
+		rxts->seqid   == ntohs(*seqid);
 }
 
 static void dp83640_free_clocks(void)