cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
From: Nicholas Mc Guire <der.herr@hofr.at>
To: cocci@systeme.lip6.fr
Subject: [Cocci] detecting false positive sparse with coccinelle
Date: Mon, 29 Apr 2019 08:05:12 +0200	[thread overview]
Message-ID: <20190429060512.GA16251@osadl.at> (raw)


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

             reply	other threads:[~2019-04-29  6:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-29  6:05 Nicholas Mc Guire [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190429060512.GA16251@osadl.at \
    --to=der.herr@hofr.at \
    --cc=cocci@systeme.lip6.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).