Skip to contentSkip to conversation

Following up on Coccinelle.

DISCUSSION Sam Muhammed 2 participants 4 messages Mar 24, 2020

lore
Share & tools
lore
#0 lore raw

Following this thread:
<20200311181134.GA17847%40supernova>

While tinkering with Coccinelle, i found that this error:

coccicheck failed
make: *** [Makefile:1742: coccicheck] Error 255

only happens with (as far as i tried) two COCCIs:
using MODE=patch
scripts/coccinelle/api/atomic_as_refcounter.cocci
scripts/coccinelle/api/check_bq27xxx_data.cocci

So running make coccicheck with no COCCI= will always fail at the scripts/coccinelle/api/atomic_as_refcounter.cocci

Adding that MODE=report is okay to report all ERRORs ..etc

so specifying a COCCI to get round it worked for me.

++
but i have a question, maybe a couple:

+ If i have a simple .cocci and it produces patches, how do i make a
commit of it? _newbie_ :)

+ If this .cocci propagated across a driver, a patchset of this change across the driver will have the same subject for all patches, I guess thats not okay? so one patch of all the driver files should do it?

+ Basically, how to format a patch found by EITHER an existing .cocci in the source tree, or one that is made and not included in the /scripts/coccinelle ??
++

Thank you!

Sam

#1 lore raw
Quoted 13 lines · Sam Muhammed

Following this thread:
<20200311181134.GA17847%40supernova>

While tinkering with Coccinelle, i found that this error:

coccicheck failed
make: *** [Makefile:1742: coccicheck] Error 255

only happens with (as far as i tried) two COCCIs:
using MODE=patch
scripts/coccinelle/api/atomic_as_refcounter.cocci
scripts/coccinelle/api/check_bq27xxx_data.cocci

Quoted 6 lines

So running make coccicheck with no COCCI= will always fail at the scripts/coccinelle/api/atomic_as_refcounter.cocci

Adding that MODE=report is okay to report all ERRORs ..etc

so specifying a COCCI to get round it worked for me.

Could you try with the option DEBUG_FILE="err.log" and then see what is in err.log when it crashes?

Quoted 6 lines

++
but i have a question, maybe a couple:

+ If i have a simple .cocci and it produces patches, how do i make a
commit of it? _newbie_ :)

Apply the patch to your code:

patch -p1 < the_patch

Then proceed as if you had made the change by hand.

Quoted 3 lines

+ If this .cocci propagated across a driver, a patchset of this change across the driver will have the same subject for all patches, I guess thats not okay? so one patch of all the driver files should do it?

It depends on the changes. If all of the changes are quite uniform, then putting multiple changes in a single patch could be ok. If each change is a special case, you may want to put more detail about the file in the subject line, ie before the :

In general, the point of a patch is to make something that is understandable for the person who has to review it.

Quoted 3 lines

+ Basically, how to format a patch found by EITHER an existing .cocci in the source tree, or one that is made and not included in the /scripts/coccinelle ??

If it is made by a semanitic patch that is in the kernel tree, then you can use the tag Generated-by: and then give the path to the semantic patch.

If you do something on your own, it could be helpful to include the semantic patch in the log message, or a simplified version. The point is to show the maintainer what reasoning you have used to come to your change, without overwhelming him with tedious detail.

julia

#2 lore raw
Quoted 19 lines · Julia Lawall
Quoted 16 lines · Sam Muhammed

Following this thread:
<20200311181134.GA17847%40supernova>

While tinkering with Coccinelle, i found that this error:

coccicheck failed
make: *** [Makefile:1742: coccicheck] Error 255

only happens with (as far as i tried) two COCCIs:
using MODE=patch
scripts/coccinelle/api/atomic_as_refcounter.cocci
scripts/coccinelle/api/check_bq27xxx_data.cocci

So running make coccicheck with no COCCI= will always fail at the scripts/coccinelle/api/atomic_as_refcounter.cocci

Quoted 8 lines
Quoted 3 lines

Adding that MODE=report is okay to report all ERRORs ..etc

so specifying a COCCI to get round it worked for me.

Could you try with the option DEBUG_FILE="err.log" and then see what is in err.log when it crashes?

Okay, on both files, it complained:
virtual rule patch not supported

and when i looked into both COCCIs i found both only support (virtual report) --both are rules with no +/-/*--

i put "virtual patch" anyways and it obviously complained:

No rules apply. Perhaps your semantic patch doesn't contain any +/-/* code, or you have a failed dependency. If the problem is not clear, try --debug-parse-cocci or check whether any virtual rules (e.g., patch) should be defined.

So i guess both of these COCCIs are only for reporting? thats why its fine with MODE=report.

this has a workaround until we depend on make coccicheck with with MODE=patch and no COCCI=

Quoted 39 lines
Quoted 6 lines

++
but i have a question, maybe a couple:

+ If i have a simple .cocci and it produces patches, how do i make a
commit of it? _newbie_ :)

Apply the patch to your code:

patch -p1 < the_patch

Then proceed as if you had made the change by hand.

Quoted 3 lines

+ If this .cocci propagated across a driver, a patchset of this change across the driver will have the same subject for all patches, I guess thats not okay? so one patch of all the driver files should do it?

It depends on the changes. If all of the changes are quite uniform, then putting multiple changes in a single patch could be ok. If each change is a special case, you may want to put more detail about the file in the subject line, ie before the :

In general, the point of a patch is to make something that is understandable for the person who has to review it.

Quoted 3 lines

+ Basically, how to format a patch found by EITHER an existing .cocci in the source tree, or one that is made and not included in the /scripts/coccinelle ??

If it is made by a semanitic patch that is in the kernel tree, then you can use the tag Generated-by: and then give the path to the semantic patch.

If you do something on your own, it could be helpful to include the semantic patch in the log message, or a simplified version. The point is to show the maintainer what reasoning you have used to come to your change, without overwhelming him with tedious detail.

julia

#3 lore raw
Quoted 37 lines · Sam Muhammed
Quoted 19 lines · Julia Lawall
Quoted 16 lines · Sam Muhammed

Following this thread:
<20200311181134.GA17847%40supernova>

While tinkering with Coccinelle, i found that this error:

coccicheck failed
make: *** [Makefile:1742: coccicheck] Error 255

only happens with (as far as i tried) two COCCIs:
using MODE=patch
scripts/coccinelle/api/atomic_as_refcounter.cocci
scripts/coccinelle/api/check_bq27xxx_data.cocci

So running make coccicheck with no COCCI= will always fail at the scripts/coccinelle/api/atomic_as_refcounter.cocci

Quoted 8 lines
Quoted 3 lines

Adding that MODE=report is okay to report all ERRORs ..etc

so specifying a COCCI to get round it worked for me.

Could you try with the option DEBUG_FILE="err.log" and then see what is in err.log when it crashes?

Okay, on both files, it complained:
virtual rule patch not supported

and when i looked into both COCCIs i found both only support (virtual report) --both are rules with no +/-/*--

i put "virtual patch" anyways and it obviously complained:

Quoted 7 lines

No rules apply. Perhaps your semantic patch doesn't contain any +/-/* code, or you have a failed dependency. If the problem is not clear, try --debug-parse-cocci or check whether any virtual rules (e.g., patch) should be defined.

So i guess both of these COCCIs are only for reporting? thats why its fine with MODE=report.

Yes. But make coccicheck shouldn't crash if you run it with MODE=patch and some semantic patches don't support that. It should just move on to the next option.

julia

Quoted 47 lines

this has a workaround until we depend on make coccicheck with with MODE=patch and no COCCI=

Quoted 39 lines
Quoted 6 lines

++
but i have a question, maybe a couple:

+ If i have a simple .cocci and it produces patches, how do i make a
commit of it? _newbie_ :)

Apply the patch to your code:

patch -p1 < the_patch

Then proceed as if you had made the change by hand.

Quoted 3 lines

+ If this .cocci propagated across a driver, a patchset of this change across the driver will have the same subject for all patches, I guess thats not okay? so one patch of all the driver files should do it?

It depends on the changes. If all of the changes are quite uniform, then putting multiple changes in a single patch could be ok. If each change is a special case, you may want to put more detail about the file in the subject line, ie before the :

In general, the point of a patch is to make something that is understandable for the person who has to review it.

Quoted 3 lines

+ Basically, how to format a patch found by EITHER an existing .cocci in the source tree, or one that is made and not included in the /scripts/coccinelle ??

If it is made by a semanitic patch that is in the kernel tree, then you can use the tag Generated-by: and then give the path to the semantic patch.

If you do something on your own, it could be helpful to include the semantic patch in the log message, or a simplified version. The point is to show the maintainer what reasoning you have used to come to your change, without overwhelming him with tedious detail.

julia