I think I've hit a C macro that's greatly confusing cocci.

cat i915_drv.c.cocci
@inteldeviceinfo@
identifier d;
@@
-struct intel_device_info d = {...};

This is part of the 'reverse extract' pattern. I'm trying to create a
file for patch -R that will let me extract the structs (and only the
structs).

This has worked in other files, but here I'm seeing a problem.

[rminnich@myhost tmp]$ cat drv.cocci
static struct drm_driver driver;
extern int intel_agp_enabled;

#define INTEL_VGA_DEVICE(id, info) {            \
        .class = PCI_CLASS_DISPLAY_VGA << 8,    \
        .class_mask = 0xff0000,                 \
        .vendor = 0x8086,                       \
        .device = id,                           \
        .subvendor = PCI_ANY_ID,                \
        .subdevice = PCI_ANY_ID,                \
        .driver_data = (unsigned long) info }

static const struct intel_device_info intel_i830_info = {
        .gen = 2, .is_mobile = 1, .cursor_needs_physical = 1,
        .has_overlay = 1, .overlay_needs_physical = 1,
};

That's the input. Simple enough. The only thing that should be
referenced is the struct, but:


[rminnich@myhost tmp]$ spatch -sp_file i915_drv.c.cocci drv.c
init_defs_builtins: /usr/local/share/coccinelle/standard.h
HANDLING: drv.c
diff =
--- drv.c
+++ /tmp/cocci-output-31560-fcfb57-drv.c
@@ -8,9 +8,4 @@ extern int intel_agp_enabled;
        .device = id,                           \
        .subvendor = PCI_ANY_ID,                \
        .subdevice = PCI_ANY_ID,                \
-       .driver_data = (unsigned long) info }
-
-static const struct intel_device_info intel_i830_info = {
-       .gen = 2, .is_mobile = 1, .cursor_needs_physical = 1,
-       .has_overlay = 1, .overlay_needs_physical = 1,
-};
+       .driver_data = (unsigned long) info }const

So a weirdly broken line is output with the extern int in it, then the
tail end of the macro is output, the struct is output, and that stuff
at the end is the
tail end of the macro again with this 'const' thing hanging on ... any ideas?

ron
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to