Skip to contentSkip to conversation

About conditional compilation

Cocci Håkon Løvdal 1 participant 1 message Nov 17, 2012 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 2 lines · yafo lee

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
Cocci at diku.dk
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)