commit cc48eff2d3b07a8dd2f621f09217ba29b4e6771c Merge: 4b1e0dd5b 0f4b245b2 Author: Nick Mathewson nickm@torproject.org Date: Wed Aug 21 09:46:20 2019 -0400
Merge branch 'ticket31176' into ticket31176_merged
Makefile.am | 3 +- changes/ticket31176 | 5 + scripts/git/pre-commit.git-hook | 4 +- scripts/maint/checkIncludes.py | 183 +------------------- scripts/maint/practracker/exceptions.txt | 45 ++++- scripts/maint/practracker/includes.py | 285 +++++++++++++++++++++++++++++++ scripts/maint/practracker/practracker.py | 23 ++- scripts/maint/practracker/problem.py | 17 ++ src/core/crypto/.may_include | 10 ++ src/core/mainloop/.may_include | 20 +++ src/core/or/.may_include | 38 +++++ src/core/proto/.may_include | 10 ++ 12 files changed, 462 insertions(+), 181 deletions(-)
diff --cc Makefile.am index bb5dee52e,e973593bd..d3cce3934 --- a/Makefile.am +++ b/Makefile.am @@@ -166,23 -166,10 +166,24 @@@ EXTRA_DIST+= Makefile.nmake \ README \ ReleaseNotes \ - scripts/maint/practracker/includes.py \ - scripts/maint/checkSpace.pl \ - scripts/maint/practracker - + scripts/maint/checkIncludes.py \ + scripts/maint/checkSpace.pl \ + scripts/maint/practracker/exceptions.txt \ ++ scripts/maint/practracker/includes.py \ + scripts/maint/practracker/metrics.py \ + scripts/maint/practracker/practracker.py \ + scripts/maint/practracker/practracker_tests.py \ + scripts/maint/practracker/problem.py \ + scripts/maint/practracker/testdata/a.c \ + scripts/maint/practracker/testdata/b.c \ + scripts/maint/practracker/testdata/ex0-expected.txt \ + scripts/maint/practracker/testdata/ex0.txt \ + scripts/maint/practracker/testdata/ex1-expected.txt \ + scripts/maint/practracker/testdata/ex1.txt \ + scripts/maint/practracker/testdata/ex.txt \ + scripts/maint/practracker/testdata/not_c_file \ + scripts/maint/practracker/test_practracker.sh \ + scripts/maint/practracker/util.py
## This tells etags how to find mockable function definitions. AM_ETAGSFLAGS=--regex='{c}/MOCK_IMPL([^,]+,\W*([a-zA-Z0-9_]+)\W*,/\1/s' diff --cc scripts/maint/practracker/exceptions.txt index 4f3943f21,39eb7a437..ce6004fe1 --- a/scripts/maint/practracker/exceptions.txt +++ b/scripts/maint/practracker/exceptions.txt @@@ -67,8 -73,15 +74,16 @@@ problem dependency-violation /src/core/ problem include-count /src/core/mainloop/mainloop.c 63 problem function-size /src/core/mainloop/mainloop.c:conn_close_if_marked() 108 problem function-size /src/core/mainloop/mainloop.c:run_connection_housekeeping() 123 + problem dependency-violation /src/core/mainloop/mainloop.c 49 + problem dependency-violation /src/core/mainloop/mainloop_pubsub.c 1 + problem dependency-violation /src/core/mainloop/mainloop_sys.c 1 + problem dependency-violation /src/core/mainloop/netstatus.c 4 + problem dependency-violation /src/core/mainloop/periodic.c 2 + problem dependency-violation /src/core/or/address_set.c 1 problem file-size /src/core/or/channel.c 3487 +problem file-size /src/core/or/channel.h 780 + problem dependency-violation /src/core/or/channel.c 9 + problem dependency-violation /src/core/or/channelpadding.c 6 problem function-size /src/core/or/channeltls.c:channel_tls_handle_var_cell() 160 problem function-size /src/core/or/channeltls.c:channel_tls_process_versions_cell() 170 problem function-size /src/core/or/channeltls.c:channel_tls_process_netinfo_cell() 214 @@@ -84,14 -99,18 +101,19 @@@ problem function-size /src/core/or/circ problem function-size /src/core/or/circuitlist.c:circuit_find_to_cannibalize() 101 problem function-size /src/core/or/circuitlist.c:circuit_about_to_free() 120 problem function-size /src/core/or/circuitlist.c:circuits_handle_oom() 117 + problem dependency-violation /src/core/or/circuitlist.c 19 problem function-size /src/core/or/circuitmux.c:circuitmux_set_policy() 109 problem function-size /src/core/or/circuitmux.c:circuitmux_attach_circuit() 113 + problem dependency-violation /src/core/or/circuitmux_ewma.c 2 problem file-size /src/core/or/circuitpadding.c 3043 problem function-size /src/core/or/circuitpadding.c:circpad_machine_schedule_padding() 107 +problem file-size /src/core/or/circuitpadding.h 809 + problem dependency-violation /src/core/or/circuitpadding.c 6 problem function-size /src/core/or/circuitpadding_machines.c:circpad_machine_relay_hide_intro_circuits() 103 problem function-size /src/core/or/circuitpadding_machines.c:circpad_machine_client_hide_rend_circuits() 112 + problem dependency-violation /src/core/or/circuitpadding_machines.c 1 problem function-size /src/core/or/circuitstats.c:circuit_build_times_parse_state() 123 + problem dependency-violation /src/core/or/circuitstats.c 11 problem file-size /src/core/or/circuituse.c 3162 problem function-size /src/core/or/circuituse.c:circuit_is_acceptable() 128 problem function-size /src/core/or/circuituse.c:circuit_expire_building() 394 @@@ -117,13 -139,17 +142,19 @@@ problem include-count /src/core/or/conn problem function-size /src/core/or/connection_or.c:connection_or_group_set_badness_() 105 problem function-size /src/core/or/connection_or.c:connection_or_client_learned_peer_id() 142 problem function-size /src/core/or/connection_or.c:connection_or_compute_authenticate_cell_body() 231 +problem file-size /src/core/or/or.h 1103 +problem include-count /src/core/or/or.h 49 + problem dependency-violation /src/core/or/connection_or.c 20 + problem dependency-violation /src/core/or/dos.c 5 + problem dependency-violation /src/core/or/onion.c 2 + problem dependency-violation /src/core/or/or_periodic.c 1 problem file-size /src/core/or/policies.c 3249 problem function-size /src/core/or/policies.c:policy_summarize() 107 + problem dependency-violation /src/core/or/policies.c 14 problem function-size /src/core/or/protover.c:protover_all_supported() 117 - problem file-size /src/core/or/relay.c 3264 -problem dependency-violation /src/core/or/reasons.c 2 +problem function-size /src/core/or/relay.c:circuit_receive_relay_cell() 127 + problem file-size /src/core/or/relay.c 3263 -problem function-size /src/core/or/relay.c:circuit_receive_relay_cell() 126 ++problem dependency-violation /src/core/or/reasons.c 2 problem function-size /src/core/or/relay.c:relay_send_command_from_edge_() 109 problem function-size /src/core/or/relay.c:connection_ap_process_end_not_open() 192 problem function-size /src/core/or/relay.c:connection_edge_process_relay_cell_not_open() 137 diff --cc scripts/maint/practracker/practracker.py index 0fdfd4a40,16ccec3d7..6483b88da --- a/scripts/maint/practracker/practracker.py +++ b/scripts/maint/practracker/practracker.py @@@ -35,10 -36,8 +36,12 @@@ MAX_FILE_SIZE = 3000 # line MAX_FUNCTION_SIZE = 100 # lines # Recommended number of #includes MAX_INCLUDE_COUNT = 50 +# Recommended file size for headers +MAX_H_FILE_SIZE = 500 +# Recommended include count for headers +MAX_H_INCLUDE_COUNT = 15 + # Recommended number of dependency violations + MAX_DEP_VIOLATIONS = 0
# Map from problem type to functions that adjust for tolerance TOLERANCE_FNS = { @@@ -188,11 -200,10 +208,12 @@@ def main(argv)
# 0) Configure our thresholds of "what is a problem actually" filt = problem.ProblemFilter() - filt.addThreshold(problem.FileSizeItem("*", int(args.max_file_size))) - filt.addThreshold(problem.IncludeCountItem("*", int(args.max_include_count))) - filt.addThreshold(problem.FunctionSizeItem("*", int(args.max_function_size))) + filt.addThreshold(problem.FileSizeItem("*.c", int(args.max_file_size))) + filt.addThreshold(problem.IncludeCountItem("*.c", int(args.max_include_count))) + filt.addThreshold(problem.FileSizeItem("*.h", int(args.max_h_file_size))) + filt.addThreshold(problem.IncludeCountItem("*.h", int(args.max_h_include_count))) + filt.addThreshold(problem.FunctionSizeItem("*.c", int(args.max_function_size))) + filt.addThreshold(problem.DependencyViolationItem("*", int(args.max_dependency_violations)))
# 1) Get all the .c files we care about files_list = util.get_tor_c_files(TOR_TOPDIR)