[Cocci] changing function declaration
Julia Lawall
julia.lawall at lip6.fr
Thu Mar 1 07:51:16 CET 2012
On Wed, 29 Feb 2012, ron minnich wrote:
> I'm trying to change a function of this form:
> type T;
> identifier func;
> identifier dev;
> expression E;
>
> T funcname(struct drm_dev *dev, E){...}
>
> into
> funcname(struct pci_dev *dev, E)
>
> I'd like to change it and all its uses. I'm failing badly. I can
> change the uses:
> @ ruled @
> identifier t;
> identifier f;
> expression E1, E2;
Perhaps you want to declare E1 as struct drm_dev E1; instead of expression
E1? Then the function name can be a metavariable
> type T;
> @@
> T f(...){<...
> t = intel_bios_ssc_frequency(E1, E2);
> ...>}
What is the goal of this rule?
> @@
> identifier ruled.f;
> expression E1, E2;
> @@
>
> intel_bios_ssc_frequency(
> -E1,
> +video,
> E2
> )
>
> But I'm not really doing what I want; I don't want to hardcode the
> name, I want ANY function which uses
> struct drm_dev * as its first parameter to change.
>
> Similarly, I want to change the declarations.
>
> I tried this for the declarations:
>
> @ ruledd @
> identifier f, dev, E2;
E2 should be a parameter, not an identifier.
julia
> type T;
> @@
> T f(struct drm_dev *dev, E2){...}
> @@
> identifier ruledd.f;
> identifier dev, E2;
> @@
> f(
> -struct drm_dev *dev
> +struct pci_dev *dev
> , E2){...}
>
>
> but it's very angry with me:
> Fatal error: exception Failure("minus: parse error:
> = File "fixcalls.cocci", line 78, column 25, charpos = 830
> around = 'E2', whole content = T f(struct drm_dev *dev, E2){...}
> ")
>
> Any hints welcome ...
>
> thanks. I'm close :-)
>
> ron
> _______________________________________________
> Cocci mailing list
> Cocci at diku.dk
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)
>
More information about the Cocci
mailing list