cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [Cocci] detecting false positive sparse with coccinelle
@ 2019-04-29  6:05 Nicholas Mc Guire
  2019-04-29 14:42 ` [Cocci] Detecting false positive sparse with Coccinelle Markus Elfring
  2019-04-29 16:26 ` [Cocci] detecting false positive sparse with coccinelle Julia Lawall
  0 siblings, 2 replies; 5+ messages in thread
From: Nicholas Mc Guire @ 2019-04-29  6:05 UTC (permalink / raw)
  To: cocci


Hi !

 I'm trying to detect false positive sparse messages by taking
 the pattern and scanning with coccinelle for it so that the
 fix could be generated. Basically the identification seems
 to be working (a type-check on var is stil missing - but thats
 a different issue) - the problem though is that I'm unable
 to insert the (__force __be16) cast in the patch rule as 
 coccinelle is refusing hose lines. Any hint how that could be 
 done or is the problem the syntactic oddity of having a 
 unknown keyworkd followed by a type that is confusing coccinelle 
 here ?

thx!
hofrat

virtual report
virtual patch

@acheck depends on report@
identifier var;
position p;
@@

(
* var = be16_to_cpu@p(var);
|
* var = be32_to_cpu@p(var);
|
* var = be64_to_cpu@p(var);
|
* var = le16_to_cpu@p(var);
|
* var = le32_to_cpu@p(var);
|
* var = le64_to_cpu@p(var);
)

@script:python depends on report@
p << acheck.p;
@@

msg = "forced endiannes annotation needed"
coccilib.report.print_report(p[0],msg)

@afix depends on patch@
identifier var;
position p;
typedef __be16, __be32, __b64, __le16, __le32, __le64;
@@

(
- var = be16_to_cpu@p(var);
+ var = be16_to_cpu((__force __be16)var);
|
- var = be32_to_cpu@p(var);
+ var = be32_to_cpu((__force __be32)var);
|
- var = be64_to_cpu@p(var);
+ var = be64_to_cpu((__force __be64)var);
|
- var = le16_to_cpu@p(var);
+ var = le16_to_cpu((__force __le16)var);
|
- var = le32_to_cpu@p(var);
+ var = le32_to_cpu((__force __le32)var);
|
- var = le64_to_cpu@p(var);
+ var = le64_to_cpu((__force __le64)var);
)

@script:python depends on patch@
p << afix.p;
@@

msg = "forced endiannes annotation added"
coccilib.report.print_report(p[0],msg)
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci

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

end of thread, other threads:[~2019-04-30 10:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-29  6:05 [Cocci] detecting false positive sparse with coccinelle Nicholas Mc Guire
2019-04-29 14:42 ` [Cocci] Detecting false positive sparse with Coccinelle Markus Elfring
2019-04-29 16:26 ` [Cocci] detecting false positive sparse with coccinelle Julia Lawall
2019-04-30  3:26   ` Nicholas Mc Guire
2019-04-30 10:56     ` 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).