Subject: Re: net: use NETDEV_TX_OK instead of 0 in ndo_start_xmit() functions

From: Patrick McHardy <[email-masked]>
Date: Tue, 23 Jun 2009 18:26:36 +0200

Joe Perches wrote:
> On Tue, 2009-06-23 at 18:03 +0200, Patrick McHardy wrote:
>> This patch is the result of an automatic spatch transformation to
>> convert all ndo_start_xmit() return values of 0 to NETDEV_TX_OK.
> 
> It might be useful if you submitted the spatch source
> that created this transformation.

I would have added it to the changelog, but it includes some workarounds
for false-negatives since the version used in Debian seems to be buggy.
Namely, it didn't manage to find occurences if there was only one, so I
included a number of NOP transformations to work around that. Or maybe
I'm doing something wrong :)

Attached for reference.

@ ndomatch @
identifier ndo, xmit;
@@

struct net_device_ops ndo = {
	.ndo_start_xmit		= xmit,
};

@forall@
identifier skb, dev;
identifier ndomatch.xmit;
@@

int xmit(struct sk_buff *skb, struct net_device *dev)
{
...
(
-	return 1;
+	return NETDEV_TX_BUSY;
|
-	return -1;
+	return NETDEV_TX_LOCKED;
|
-	return 0;
+	return NETDEV_TX_OK;
|
-	return NETDEV_TX_BUSY;
+	return NETDEV_TX_BUSY;
|
-	return NETDEV_TX_LOCKED;
+	return NETDEV_TX_LOCKED;
|
-	return NETDEV_TX_OK;
+	return NETDEV_TX_OK;
)
...
}