Hi Julia,
It can eliminate the error message, but still can not get a match:
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: test.c
the complete code I want to convert:
static void alx_set_multicase_list(struct net_device *netdev)
{
struct alx_adapter *adpt = netdev_priv(netdev);
struct alx_hw *hw = &adpt->hw;
struct netdev_hw_addr *ha;
/* Check for Promiscuous and All Multicast modes */
if (netdev->flags & IFF_PROMISC) {
SET_HW_FLAG(PROMISC_EN);
} else if (netdev->flags & IFF_ALLMULTI) {
SET_HW_FLAG(MULTIALL_EN);
CLI_HW_FLAG(PROMISC_EN);
} else {
CLI_HW_FLAG(MULTIALL_EN);
CLI_HW_FLAG(PROMISC_EN);
}
hw->cbs.config_mac_ctrl(hw);
/* clear the old settings from the multicast hash table */
hw->cbs.clear_mc_addr(hw);
/* comoute mc addresses' hash value ,and put it into hash table */
netdev_for_each_mc_addr(ha, netdev)
hw->cbs.set_mc_addr(hw, ha->addr);
}
---------------------------------------------------------
From: Julia Lawall
Sent: Monday, June 18, 2012 1:46 PM
To: yafo lee
Cc: [email protected]
Subject: Re: [Cocci] How to replace a macro?
On Mon, 18 Jun 2012, yafo lee wrote:
Hi guys, I have the following code:
netdev_for_each_mc_addr(ha, netdev)
hw->cbs.set_mc_addr(hw, ha->addr);
And I want it to be converted to:
TAILQ_FOREACH(ha, &netdev->if_multiaddrs, ifma_link) {
if (ha->ifma_addr->sa_family != AF_LINK)
continue;
hw->cbs.set_mc_addr(hw,
LLADDR((struct sockaddr_dl *)ha->ifma_addr));
}
Any suggests?
I've try :
@@
identifier ha;
identifier netdev;
declarer name TAILQ_FOREACH;
iterator name, not declarer name.
julia
@@
+ TAILQ_FOREACH(ha, &netdev->if_multiaddrs, ifma_link) {
- netdev_for_each_mc_addr(ha, netdev)
...;
+ }
but get error:
init_defs_builtins: /usr/local/share/coccinelle/standard.h
125 126
Fatal error: exception Failure("plus: parse error:
= File "c1.cocci", line 7, column 55, charpos = 125
around = '{', whole content = + TAILQ_FOREACH(ha,
&netdev->if_multiaddrs, ifma_link) {
")
Thanks. _______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)