On Mon, 29 Apr 2019, Nicholas Mc Guire wrote:
>
> 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 ?
Types like this are currently not parsed properly - see the GSoC project.
I'm not sure that there is a good solution at the moment. This should be
parsed OK by the C parser, so you could try passing through python. See
python_mdecl.cocci. It may be necessary to construct the complete
expression (__force __be16)var in python.
julia
>
> 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
>
_______________________________________________
Cocci mailing list
Cocci@systeme.lip6.fr
https://systeme.lip6.fr/mailman/listinfo/cocci