I think we need two pieces of coccinelle tooling to be able to use it effectively:
A script that tells us which files have parsing problems.
A script to invoke spatch with the right arguments.
Based on 1 and 2, we can improve our tor-coccinelle.h file to handle more of our codebase, and we can apply coccinelle scripts without trying to remember the name of the "-macro-file-builtins" flag.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
The design and overall structure looks good. I am not that familiar with coccinelle, so I will need to run these scripts myself as part of my review.
Should we be running these scripts as part of our code quality checks?
(We could install coccinelle on Travis, so it runs them.)
Is that a separate ticket?
I have fixed all of the issues above, and gotten the number of files with parsing errors down from 143 to 12. The remaining unhandled files are:
Those with funny case statement macros:
src/core/mainloop/connection.c
src/core/or/reasons.c
src/lib/tls/tortls.h
Those that use SMARTLIST_FOREACH_JOIN():
src/feature/nodelist/networkstatus.c
Those that consist entirely or almost entirely of macro definitions that Coccinelle does not understand:
src/lib/pubsub/pubsub_macros.h
src/lib/testsupport/testsupport.h
src/lib/smartlist_core/smartlist_foreach.h
src/lib/container/order.c
src/lib/container/handles.h
src/lib/container/map.c
src/lib/container/map.h
src/lib/cc/compat_compiler.h
Also, in some cases, I had to disable parsing of certain things with an #ifdef COCCI macro. In the future, if we can figure out how to parse those things, we should use this macro less often.
After these changes, I ran into some merge conflicts with master and its improved annotate_ifdef_directives. I have made a new branch ticket31705_merged to handle those conflicts, which has a PR at https://github.com/torproject/tor/pull/1403 . If CI passes, I'll call it needs_review.
Seems fine, but there are some typos and minor commit message/content issues.
I've added a fixup commits for the typos. To solve the commit message/content issues, I had to squash those and make a new rebased branch, as ticket31705_v2. This still had merge conflicts with master, so it is merged in a ticket31705_v2_merged branch. The PR for that is https://github.com/torproject/tor/pull/1447 .
How do you want to make progress on the remaining files?
Do you want to set up CI, so we preserve cocci compatibility over time?
I don't have a strong opinion here right now: I think it would make more sense to get some experience using coccinelle more in our regular development workflow, so we can decide how to prioritize these items.
I would like to check the fixed files using cocci in CI. If we don't, they will degrade over time.
The CI shouldn't take long, I'll see if I can get it done today,
We can exclude the files that are hard to fix, and open a ticket to deal with them later.