All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] modifying initializers with spatch?
@ 2017-01-26 12:28 Johannes Berg
  2017-01-26 13:17 ` Julia Lawall
  0 siblings, 1 reply; 21+ messages in thread
From: Johannes Berg @ 2017-01-26 12:28 UTC (permalink / raw)
  To: cocci

Hi,

I've been playing with C99 initializers a bit, what I'm trying to do is
replace them with explicit memset()/assignments.

This works as expected:

@@
identifier x;
type t;
@@
?t x =
-{0};
+{};


This actually removes the braces, but not only if they're empty, and it
leaves the inner content there without braces, which won't even compile
afterwards:

@@
identifier x;
type t;
@@
?t x
- ={}
?;

e.g.:

-	const u8 q[] = { 1, (const u8) '*', 0 };
+	const u8 q[] 1, (const u8) '*', 0;


I've also not managed to add any memset(&x, 0, sizeof(x)); in the same
patch, especially since it should go after all other declarations.

Do you think this is possible at all?

johannes

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

end of thread, other threads:[~2017-01-28  8:20 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-26 12:28 [Cocci] modifying initializers with spatch? Johannes Berg
2017-01-26 13:17 ` Julia Lawall
2017-01-26 13:32   ` Johannes Berg
2017-01-26 14:20     ` Julia Lawall
2017-01-26 14:28       ` Johannes Berg
2017-01-26 15:47         ` Julia Lawall
2017-01-26 15:52           ` Johannes Berg
2017-01-26 15:57             ` Julia Lawall
2017-01-27 21:43               ` Johannes Berg
2017-01-27 21:52                 ` Julia Lawall
2017-01-27 22:03                   ` Johannes Berg
2017-01-27 22:09                     ` Julia Lawall
2017-01-27 22:23                       ` Johannes Berg
2017-01-27 23:02                       ` Johannes Berg
2017-01-27 23:20                         ` Johannes Berg
2017-01-28  6:47                           ` Julia Lawall
2017-01-28  8:20                             ` Johannes Berg
2017-01-27  7:09             ` Julia Lawall
2017-01-27  8:55               ` Johannes Berg
2017-01-27 13:11                 ` Julia Lawall
2017-01-27 16:13                   ` Johannes Berg

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.