All of lore.kernel.org
 help / color / mirror / Atom feed
* [cocci] Iterator macros
@ 2024-08-13  6:15 Peter Senna Tschudin
  2024-08-13  6:19 ` Julia Lawall
  2024-08-14  9:44 ` Julia Lawall
  0 siblings, 2 replies; 12+ messages in thread
From: Peter Senna Tschudin @ 2024-08-13  6:15 UTC (permalink / raw)
  To: cocci

Dear List, 

I am trying to make changes to a macro iterator from igt-gpu-tools*, and I am failing to use Coccinelle. My current attempt only captures about 1/2 of call sites, and I am not really sure how to ask Coccinelle to make the changes I want. Here is the pattern I am trying to change: 


From: 

const struct intel_execution_engine2 *e2; 
... 
for_each_ctx_engine(i915, ctx, e2) { 
    execbuf.flags = e2->flags; 
    gem_execbuf(i915, &execbuf); 
} 


To: 

struct intel_engine_data ied;
... 
for_each_ctx_engine(i915, ctx, ied) { 
    execbuf.flags = ied.current_engine->flags; 
    gem_execbuf(i915, &execbuf); 
} 

Changes I want: 
1. From `const struct intel_execution_engine2 *e2` to `struct intel_engine_data ied`. 
2. Replace the last argument of for_each_ctx_engine() following the change on previous step. 
3. Change references from `e2` to `ied.current_engine` inside the iterator statement. 

Here is my starting point that finds about half of the call sites: 

@r1@ 
iterator I =~ "for_each_ctx_engine"; 
statement S; 
@@ 
* I(...) 
S 

I assume that I should create other rules and import I from r1 as the core of the changes I want. Can you point me to an example to help me here?

Thank you,

Peter

* - https://gitlab.freedesktop.org/drm/igt-gpu-tools 

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-08-14  9:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-13  6:15 [cocci] Iterator macros Peter Senna Tschudin
2024-08-13  6:19 ` Julia Lawall
2024-08-13  6:27   ` Peter Senna Tschudin
2024-08-13  6:34     ` Julia Lawall
2024-08-13 11:05       ` Andrzej Hajda
2024-08-13 11:19         ` Julia Lawall
2024-08-14  7:19         ` Julia Lawall
2024-08-14  7:57           ` Andrzej Hajda
2024-08-14  8:02             ` Julia Lawall
2024-08-14  7:21         ` Julia Lawall
2024-08-14  6:22     ` Julia Lawall
2024-08-14  9:44 ` Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.