On Wed, 21 Apr 2021, Fuad Tabba wrote:

> Hi,
>
> I just started using Coccinelle yesterday, and I can already see
> it saving me a lot of time and agony. Thank you.
>
> I ran into a problem, and I think that this patch might fix it,
> hopefully without causing other problems. I did some sanity
> checking on my kernel tree, and it seems to be fine.

Thanks very much for this.  I have applied the patch.

To check this sort of thing, you can do spatch --parse-c linux_path > old
then make your change
then spatch --parse-c linux_path > new

Then look at the end of old and new.  If you successfully parsed more
files and have fewer bad and passed tokens, then all should be good.

julia

>
> There are quite a few variables named "far" in the kernel, e.g.,
> arch/arm64/kvm/inject_fault.c. Coccinelle has special treatment
> for "far" as being linkage related, which causes parse errors in
> their presence. I've grepped for "far" in the kernel tree, and
> haven't noticed where it's used like that, but I could have
> missed it.
>
> To reproduce:
>
> cat > test.c << EOF
> int main(void)
> {
>         int far = 0;
>         int x;
>         x = 10;
>         return x;
> }
> EOF
>
> cat > test.cocci << EOF
> @@
> identifier x;
> @@
> - x
> + y
> EOF
>
> spatch --sp-file test.cocci test.c --debug --verbose-parsing
>
> Signed-off-by: Fuad Tabba <[email protected]>
> ---
>  scripts/coccicheck/cocci/notand.h | 1 -
>  standard.h                        | 1 -
>  2 files changed, 2 deletions(-)
>
> diff --git a/scripts/coccicheck/cocci/notand.h 
> b/scripts/coccicheck/cocci/notand.h
> index 3da8c303..91fa6c96 100644
> --- a/scripts/coccicheck/cocci/notand.h
> +++ b/scripts/coccicheck/cocci/notand.h
> @@ -302,7 +302,6 @@
>  #define  fastcall
>  #define  asmlinkage
>
> -#define  far
>  #define  SK_FAR
>
>  // pb
> diff --git a/standard.h b/standard.h
> index 7a7f96ea..936b19c3 100644
> --- a/standard.h
> +++ b/standard.h
> @@ -298,7 +298,6 @@
>  #define  fastcall
>  #define  asmlinkage
>
> -#define  far
>  #define  SK_FAR
>
>  // pb
> --
> 2.31.1.368.gbe11c130af-goog
>
> _______________________________________________
> Cocci mailing list
> [email protected]
> https://systeme.lip6.fr/mailman/listinfo/cocci
>
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci

Reply via email to