On Tue, Mar 12, 2019 at 10:03:57AM +0100, Julia Lawall wrote:
> >
> > @@
> > identifier fb;
> > @@
> > ...
> > struct drm_framebuffer *fb;
> > ...
> > - drm_format_num_planes(fb->format->format)
> > + fb->format->num_planes
> >
> > // This one seems to work properly
> 
> How about:
> 
> @@
> struct drm_framebuffer *fb;
> @@
> 
> - drm_format_num_planes(fb->format->format)
> + fb->format->num_planes
> 
> That is, you don't need to insist on there being a local variable
> declaration, you just want an expression of the right type.  This will
> also be much more efficient.

I have an extra question on that one. Are function parameters also
considered expressions with that syntax?

Let's say for example, I want to replace the call to drm_format_info
by drm_get_format_info in that function:
https://elixir.bootlin.com/linux/v5.0/source/drivers/gpu/drm/omapdrm/omap_fb.c#L340

That snippet doesn't work:
@@
struct drm_device *dev;
struct drm_mode_fb_cmd2 *cmd;
@@

- drm_format_info(cmd->pixel_format)
+ drm_get_format_info(dev, cmd)

with spatch producing the following warnings and errors:

warning: rule starting on line 1: metavariable dev not used in the - or context 
code
error: rule starting on line 1: dev appears only in + code

Does that mean I have to explicitly have the function prototype as
context?

Maxime

-- 
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

Attachment: signature.asc
Description: PGP signature

_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to