cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] moving const instead of not matching?
@ 2018-09-18  9:20 Johannes Berg
  2018-09-18 10:41 ` Julia Lawall
  0 siblings, 1 reply; 4+ messages in thread
From: Johannes Berg @ 2018-09-18  9:20 UTC (permalink / raw)
  To: cocci

I was trying to do something like this:

@@
typedef u8;
expression D, T, S2;
@@
(
 memcpy(
-(u8 *)(D)
+D
 ,
-(u8 *)(T)
+T
 , S2)
|
 memcpy(
-(u8 *)(D)
+D
 ,
-(T)
+T
 , S2)
|
 memcpy(
-(D)
+D
 ,
-(u8 *)(T)
+T
 , S2)
)


but then I ran across a place that had a const, and the result was
rather unexpected:

$ spatch --sp-file /tmp/test3.spatch /tmp/test.c
init_defs_builtins: /usr/lib64/coccinelle/standard.h
HANDLING: /tmp/test.c
diff = 
--- /tmp/test.c
+++ /tmp/cocci-output-8879-8411db-test.c
@@ -1,4 +1,4 @@
 int main()
 {
-	memcpy(dst, (const u8 *)src, sz);
+	memcpy(dst, src const, sz);
 }


Why is the const being moved there, rather than not matching?

spatch version 1.0.6.

johannes

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

end of thread, other threads:[~2018-09-18 11:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-18  9:20 [Cocci] moving const instead of not matching? Johannes Berg
2018-09-18 10:41 ` Julia Lawall
2018-09-18 10:43   ` Johannes Berg
2018-09-18 11:47     ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).