Commit Graph

39 Commits

Author SHA1 Message Date
teor
ac3a9aaf0d
Makefile/git scripts: Add comments to keep owned file lists in sync 2019-12-20 09:35:18 +10:00
teor
9a556dee81
cocci: Require spatch >= 1.0.4 to run checks
No changes file required: not in any released version of tor.

Fixes bug 32663.
2019-12-05 10:27:47 +10:00
teor
3479024cb1 scripts: Change to the top source directory as needed
Bugfix on 31919; not in any released version of tor.
2019-10-28 13:28:50 +10:00
teor
71b8b7ee2d
scripts/cocci: Check owned src in check_cocci_parse.sh by default
Check the tor-owned sources in an 0.3.5 directory layout, if no
files are provided on the command line.

Part of 31919.
2019-10-24 14:09:45 +10:00
teor
330717f018
scripts/cocci: Add check_cocci_parse.sh and default exceptions
Add check_cocci_parse.sh, which is a thin wrapper around
try_parse.sh. Add a default exceptions file, and use it in
check_cocci_parse.sh.

Part of 31919.
2019-10-24 11:40:58 +10:00
teor
87ee49e016
scripts/cocci: Remove unused arguments from try_parse.sh spatch
Part of 31919.
2019-10-24 11:40:54 +10:00
teor
9a96068a0b
scripts/cocci: Add an exceptions file to try_parse.sh
Set $TOR_COCCI_EXCEPTIONS_FILE to the name of an exceptions file,
containing a list of filename patterns matched by 'grep -f'.

Part of 31919.
2019-10-24 11:40:51 +10:00
Nick Mathewson
b2d487ae22 Merge branch 'ticket31705_v2' into ticket31705_v2_merged
Conflicts:
	src/feature/dirparse/authcert_parse.c
	src/feature/dirparse/ns_parse.c
	src/feature/hs/hs_service.c
	src/lib/conf/conftesting.h
	src/lib/log/log.h
	src/lib/thread/threads.h
	src/test/test_options.c

These conflicts were mostly related to autostyle improvements, with
one or two due to doxygen fixes.
2019-10-22 09:39:06 -04:00
Nick Mathewson
3e41459dff confmacros.h: fix coccinelle parsing. 2019-10-22 09:32:13 -04:00
Nick Mathewson
d6ce8527f8 tor-coccinelle.h: add a definition for EXTERN 2019-10-22 09:32:13 -04:00
Nick Mathewson
6696a5bbae tor-coccinelle.h: add HANDLE_{DECL,IMPL} 2019-10-22 09:32:13 -04:00
Nick Mathewson
d129b503c0 tor-coccinelle.h: add EAT_SEMICOLON 2019-10-22 09:32:13 -04:00
Nick Mathewson
2e64dfea95 tor-coccinelle.h: add CHECK_SCANF 2019-10-22 09:32:13 -04:00
Nick Mathewson
7798c53c98 tor-coccinelle.h: add MOCK_DECL 2019-10-22 09:24:25 -04:00
Nick Mathewson
18f1624bbe tor-coccinelle.h: handle SLIST and LIST. 2019-10-22 09:24:25 -04:00
Nick Mathewson
a2bb66c355 Add a "COCCI" macro that we tell coccinelle is always defined.
This will let us give specific in-file equivalents to given macros
or preprocessor directives, to make things parse.
2019-10-22 09:24:25 -04:00
Nick Mathewson
ea47e53252 tor-coccinelle.h: handle NS and NS_DECL. 2019-10-22 09:24:25 -04:00
Nick Mathewson
017c62000c tor-coccinelle: handle SIMPLEQ and TAILQ better. 2019-10-22 09:24:25 -04:00
Nick Mathewson
c13c0c8999 tor-coccinelle.h: Add {EN,DIS}ABLE_GCC_WARNING. 2019-10-22 09:24:25 -04:00
Nick Mathewson
eb1260e346 tor-coccinelle: expect parentheses after HT_INITIALIZER 2019-10-22 09:24:25 -04:00
Nick Mathewson
51c2097586 try_parse.sh: add a verbose mode and a meaningful exit code. 2019-10-22 09:24:25 -04:00
Nick Mathewson
9ab96550da document test-operator-cleanup 2019-10-22 09:24:25 -04:00
Nick Mathewson
4ab85f4928 Document tor-coccinelle.h 2019-10-09 09:23:49 -04:00
Nick Mathewson
387cfccee4 Add a coccinelle script to look for {inc,dec}rements in log_debug
We want to forbid this pattern since, unlike the other log_*()
macros, log_debug() conditionally evaluates its arguments only if
debug-level logging is enabled.  Thus, a call to
    log_debug("%d", x++);
will only increment x if debugging logs are enabled, which is
probably not what the programmer intended.

One bug caused by this pattern was #30628.

This script detects log_debug( ) calls with any of E++, E--, ++E,
or --E in their arguments, where E is an arbitrary expression.

Closes ticket 30743.
2019-09-18 13:43:42 -04:00
Nick Mathewson
25ed698fb8 Add some more of our trickier macros to tor-coccinelle.h
Note that this header file behaves a bit strangely.  It is used by
coccinelle just for the purpose of knowing how to parse
difficult-to-parse stuff.  It doesn't need to produce good C -- just
grammatical C.
2019-09-11 18:45:52 -04:00
Nick Mathewson
c6191983e9 Add a script to tell whether a file can be perfectly parsed by spatch
spatch can let us know whether a file has parsed "perfectly" or
not.  The more perfect it parses, the likelier any semantic patches
are to apply.  I've used this script to identify problem areas in
our code.
2019-09-11 18:44:10 -04:00
Nick Mathewson
9a101c2c0f Add a script to run spatch with appropriate arguments
It's a bit tricky to remember the right incantation to get the
proper include paths and incantations for coccinelle, but without
it, coccinelle is less effective at parsing our C.
2019-09-11 18:43:16 -04:00
Taylor Yu
58ec88e806 Coccinelle scripts for control.c refactor 2019-04-30 13:18:46 -05:00
Alexander Færøy
9e1fa95920 Add Coccinelle patch for replacing NULL/non-NULL tt_assert().
This patch replaces tt_assert() checks for NULL/non-NULL values with
tt_ptr_op().
2017-08-24 15:22:20 -04:00
Alexander Færøy
7666cd8881 Add Coccinelle patch for replacing tt_assert() usage on integer types.
This patch replaces tt_assert() comparison of integers and unsigned
integers with their respective tt_int_op or tt_uint_op counterpart.
2017-08-24 15:21:43 -04:00
Alexander Færøy
3fd68b249b Add Coccinelle patch for replacing tt_assert(0) with tt_abort(). 2017-08-24 15:21:07 -04:00
Alexander Færøy
25eaf77033 Add Coccinelle patch for detecing places where CEIL_DIV should be used. 2017-08-24 15:20:11 -04:00
Alexander Færøy
7c3e980fb9 Add script for cleaning op operator usage in test files.
This patch adds a script written by Nick for bug #13172 to clean up the
usage of ==, !=, <, >, <=, and >= by replacing them with their symbolic
OP_* counterpart. This will ensure that a tool like Coccinelle doesn't
get confused and silently ignore large blocks of code.
2017-08-24 15:19:11 -04:00
Mansour Moufid
3ab2c865bf Add a rule to the calloc semantic patch for argument ordering. 2014-11-02 11:54:42 -05:00
Mansour Moufid
533790ca77 The second argument to tor_calloc should be a constant.
Just like the conventional calloc.
2014-11-02 11:54:42 -05:00
Mansour Moufid
a746081f38 Refactor the calloc semantic patch.
This does not change its effects.
2014-11-02 11:54:42 -05:00
Nick Mathewson
1bb10353ff Add coccinelle script to remove pointless callocs 2014-09-16 11:11:17 -04:00
Nick Mathewson
ef9a0d2048 Add script to detect and remove unCish malloc-then-cast pattern
Also, apply it.
2014-09-16 10:57:00 -04:00
Nick Mathewson
5da821a8a3 Add a simple coccinelle script to replace malloc->calloc
Coccinelle is a semantic patching tool that can automatically change
C code via semantic patching.

This script also replaces realloc with reallocarray as appropriate.
2014-08-13 10:39:56 -04:00