On 20 June 2012 08:10, yafo lee <[email protected]> wrote:
> Hi guys, I wanna delete conditional compilation code such as #ifdef, can
> Coccinelle do that?

The unifdef program, http://dotat.at/prog/unifdef/,  is created
specifically for such tasks:


(hlovdal) localhost:/tmp/test>cat test.c
#ifdef CONFIG_PM_SLEEP
static int alx_suspend(struct device *dev)
{
        struct pci_dev *pdev = to_pci_dev(dev);
        int retval;
        bool wakeup;

        retval = alx_shutdown_internal(pdev, &wakeup);
        if (retval)
                return retval;

        if (wakeup) {
                pci_prepare_to_sleep(pdev);
        } else {
                pci_wake_from_d3(pdev, false);
                pci_set_power_state(pdev, PCI_D3hot);
        }

        return 0;
}
#endif
(hlovdal) localhost:/tmp/test>unifdef -DCONFIG_PM_SLEEP test.c
static int alx_suspend(struct device *dev)
{
        struct pci_dev *pdev = to_pci_dev(dev);
        int retval;
        bool wakeup;

        retval = alx_shutdown_internal(pdev, &wakeup);
        if (retval)
                return retval;

        if (wakeup) {
                pci_prepare_to_sleep(pdev);
        } else {
                pci_wake_from_d3(pdev, false);
                pci_set_power_state(pdev, PCI_D3hot);
        }

        return 0;
}
(hlovdal) localhost:/tmp/test>

BR Håkon Løvdal
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to