Fix parse error in presence of symbols named far
PATCH 1/1 Fix parse error in presence of symbols named far
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.
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
--- scripts/coccicheck/cocci/notand.h | 1 - standard.h | 1 - 2 files changed, 2 deletions(-)
scripts/coccicheck/cocci/notand.h +0 -1
@@ -302,7 +302,6 @@#define fastcall#define asmlinkage -#define far#define SK_FAR // pb
standard.h +0 -1
@@ -298,7 +298,6 @@#define fastcall#define asmlinkage -#define far#define SK_FAR // pb
Signature · 6 lines
2.31.1.368.gbe11c130af-goog _______________________________________________ Cocci mailing list [email protected] https://systeme.lip6.fr/mailman/listinfo/cocci
Julia Lawall
maintainerQuoted 8 lines · Fuad Tabba
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
Quoted 63 lines
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;
}
EOFcat >
test.cocci<< EOF
@@
identifier x;
@@
- x
+ y
EOFspatch --sp-file
test.coccitest.c--debug --verbose-parsingSigned-off-by Fuad Tabba <[email protected]>--- scripts/coccicheck/cocci/notand.h | 1 - standard.h | 1 - 2 files changed, 2 deletions(-)scripts/coccicheck/cocci/notand.h +0
-1@@ -302,7 +302,6 @@#define fastcall#define asmlinkage -#define far#define SK_FAR // pb standard.h +0
-2@@ -298,7 +298,6 @@#define fastcall#define asmlinkage -#define far#define SK_FAR // pb --2.31.1.368.gbe11c130af-goog
Quoted 5 lines
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci
_______________________________________________
Cocci mailing list
[email protected]
https://systeme.lip6.fr/mailman/listinfo/cocci