diff options
-rw-r--r-- | changes/ticket30979 | 5 | ||||
-rw-r--r-- | changes/ticket31030 | 3 | ||||
-rw-r--r-- | changes/ticket31175 | 3 | ||||
-rw-r--r-- | changes/ticket31406 | 3 | ||||
-rwxr-xr-x | scripts/git/pre-push.git-hook | 13 | ||||
-rw-r--r-- | scripts/maint/practracker/.enable_practracker_in_hooks | 1 | ||||
-rw-r--r-- | scripts/maint/practracker/exceptions.txt | 6 | ||||
-rw-r--r-- | scripts/maint/practracker/metrics.py | 4 | ||||
-rwxr-xr-x | scripts/maint/practracker/practracker.py | 18 | ||||
-rw-r--r-- | scripts/maint/practracker/problem.py | 11 | ||||
-rw-r--r-- | scripts/maint/practracker/util.py | 10 | ||||
-rw-r--r-- | src/app/config/auth_dirs.inc | 2 | ||||
-rw-r--r-- | src/feature/dirauth/keypin.c | 2 | ||||
-rw-r--r-- | src/test/test_btrack.c | 4 | ||||
-rw-r--r-- | src/test/test_controller_events.c | 3 | ||||
-rw-r--r-- | src/test/test_hs_common.c | 1 | ||||
-rw-r--r-- | src/test/test_hs_service.c | 1 | ||||
-rw-r--r-- | src/test/test_introduce.c | 3 | ||||
-rw-r--r-- | src/test/test_token_bucket.c | 2 | ||||
-rw-r--r-- | src/test/test_util.c | 2 |
20 files changed, 78 insertions, 19 deletions
diff --git a/changes/ticket30979 b/changes/ticket30979 new file mode 100644 index 0000000000..8ae9b3c418 --- /dev/null +++ b/changes/ticket30979 @@ -0,0 +1,5 @@ + o Minor features (git hooks): + - Our pre-push git hook now checks for a special file + before running practracker, so that it only runs on branches + that are based on master. + Closes ticket 30979. diff --git a/changes/ticket31030 b/changes/ticket31030 new file mode 100644 index 0000000000..4d99323b4e --- /dev/null +++ b/changes/ticket31030 @@ -0,0 +1,3 @@ + o Minor bugfixes (coverity, tests): + - Fix several coverity warnings from our unit tests. Fixes bug 31030; + bugfix on 0.2.4.1-alpha, 0.3.2.1-alpha, and 0.4.0.1-alpha. diff --git a/changes/ticket31175 b/changes/ticket31175 new file mode 100644 index 0000000000..cff13761a4 --- /dev/null +++ b/changes/ticket31175 @@ -0,0 +1,3 @@ + o Minor features (development tools): + - Our best-practices tracker now looks at headers as well as + C files. Closes ticket 31175. diff --git a/changes/ticket31406 b/changes/ticket31406 new file mode 100644 index 0000000000..0ebe6f6c47 --- /dev/null +++ b/changes/ticket31406 @@ -0,0 +1,3 @@ + o Minor features (directory authority): + - A new IP address the directory authority "dizum" has been changed. Closes + ticket 31406; diff --git a/scripts/git/pre-push.git-hook b/scripts/git/pre-push.git-hook index 71abc9aa2b..40a3bffa79 100755 --- a/scripts/git/pre-push.git-hook +++ b/scripts/git/pre-push.git-hook @@ -28,10 +28,14 @@ if [ -x "$workdir/.git/hooks/pre-commit" ]; then fi fi -if [ -e scripts/maint/practracker/practracker.py ]; then - if ! python3 ./scripts/maint/practracker/practracker.py "$workdir"; then - exit 1 - fi +PT_DIR=scripts/maint/practracker + +if [ -e "${PT_DIR}/practracker.py" ]; then + if [ -e "${PT_DIR}/.enable_practracker_in_hooks" ]; then + if ! python3 "${PT_DIR}/practracker.py" "$workdir"; then + exit 1 + fi + fi fi remote="$1" @@ -104,4 +108,3 @@ do done exit 0 - diff --git a/scripts/maint/practracker/.enable_practracker_in_hooks b/scripts/maint/practracker/.enable_practracker_in_hooks new file mode 100644 index 0000000000..a9e707f5da --- /dev/null +++ b/scripts/maint/practracker/.enable_practracker_in_hooks @@ -0,0 +1 @@ +This file is present to tell our git hooks to run practracker on this branch. diff --git a/scripts/maint/practracker/exceptions.txt b/scripts/maint/practracker/exceptions.txt index 75a8b50967..8e4618a72a 100644 --- a/scripts/maint/practracker/exceptions.txt +++ b/scripts/maint/practracker/exceptions.txt @@ -45,6 +45,7 @@ problem function-size /src/app/config/config.c:parse_dir_fallback_line() 101 problem function-size /src/app/config/config.c:parse_port_config() 446 problem function-size /src/app/config/config.c:parse_ports() 168 problem function-size /src/app/config/config.c:getinfo_helper_config() 113 +problem file-size /src/app/config/or_options_st.h 1112 problem include-count /src/app/main/main.c 68 problem function-size /src/app/main/main.c:dumpstats() 102 problem function-size /src/app/main/main.c:tor_init() 137 @@ -67,6 +68,7 @@ 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 file-size /src/core/or/channel.c 3487 +problem file-size /src/core/or/channel.h 780 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 @@ -86,6 +88,7 @@ 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 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 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 function-size /src/core/or/circuitstats.c:circuit_build_times_parse_state() 123 @@ -114,6 +117,8 @@ problem include-count /src/core/or/connection_or.c 51 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 file-size /src/core/or/policies.c 3249 problem function-size /src/core/or/policies.c:policy_summarize() 107 problem function-size /src/core/or/protover.c:protover_all_supported() 117 @@ -136,6 +141,7 @@ problem function-size /src/feature/client/dnsserv.c:evdns_server_callback() 153 problem file-size /src/feature/client/entrynodes.c 3824 problem function-size /src/feature/client/entrynodes.c:entry_guards_upgrade_waiting_circuits() 155 problem function-size /src/feature/client/entrynodes.c:entry_guard_parse_from_state() 246 +problem file-size /src/feature/client/entrynodes.h 639 problem function-size /src/feature/client/transports.c:handle_proxy_line() 108 problem function-size /src/feature/client/transports.c:parse_method_line_helper() 110 problem function-size /src/feature/client/transports.c:create_managed_proxy_environment() 109 diff --git a/scripts/maint/practracker/metrics.py b/scripts/maint/practracker/metrics.py index 82f1cd64e9..9f69b2ac1f 100644 --- a/scripts/maint/practracker/metrics.py +++ b/scripts/maint/practracker/metrics.py @@ -27,7 +27,9 @@ def get_function_lines(f): # Skip lines that look like they are defining functions with these # names: they aren't real function definitions. - REGEXP_CONFUSE_TERMS = {"MOCK_IMPL", "ENABLE_GCC_WARNINGS", "ENABLE_GCC_WARNING", "DUMMY_TYPECHECK_INSTANCE", + REGEXP_CONFUSE_TERMS = {"MOCK_IMPL", "MOCK_DECL", "HANDLE_DECL", + "ENABLE_GCC_WARNINGS", "ENABLE_GCC_WARNING", + "DUMMY_TYPECHECK_INSTANCE", "DISABLE_GCC_WARNING", "DISABLE_GCC_WARNINGS"} in_function = False diff --git a/scripts/maint/practracker/practracker.py b/scripts/maint/practracker/practracker.py index 7e51edb48f..0fdfd4a40a 100755 --- a/scripts/maint/practracker/practracker.py +++ b/scripts/maint/practracker/practracker.py @@ -35,6 +35,10 @@ MAX_FILE_SIZE = 3000 # lines 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 # Map from problem type to functions that adjust for tolerance TOLERANCE_FNS = { @@ -161,8 +165,12 @@ def main(argv): help="Make all warnings into errors") parser.add_argument("--terse", action="store_true", help="Do not emit helpful instructions.") + parser.add_argument("--max-h-file-size", default=MAX_H_FILE_SIZE, + help="Maximum lines per .H file") + parser.add_argument("--max-h-include-count", default=MAX_H_INCLUDE_COUNT, + help="Maximum includes per .H file") parser.add_argument("--max-file-size", default=MAX_FILE_SIZE, - help="Maximum lines per C file size") + help="Maximum lines per C file") parser.add_argument("--max-include-count", default=MAX_INCLUDE_COUNT, help="Maximum includes per C file") parser.add_argument("--max-function-size", default=MAX_FUNCTION_SIZE, @@ -180,9 +188,11 @@ 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))) # 1) Get all the .c files we care about files_list = util.get_tor_c_files(TOR_TOPDIR) diff --git a/scripts/maint/practracker/problem.py b/scripts/maint/practracker/problem.py index 73519d446f..13c8e55143 100644 --- a/scripts/maint/practracker/problem.py +++ b/scripts/maint/practracker/problem.py @@ -108,10 +108,11 @@ class ProblemFilter(object): self.thresholds = dict() def addThreshold(self, item): - self.thresholds[item.get_type()] = item + self.thresholds[(item.get_type(),item.get_file_type())] = item def matches(self, item): - filt = self.thresholds.get(item.get_type(), None) + key = (item.get_type(), item.get_file_type()) + filt = self.thresholds.get(key, None) if filt is None: return False return item.is_worse_than(filt) @@ -158,6 +159,12 @@ class Item(object): def get_type(self): return self.problem_type + def get_file_type(self): + if self.problem_location.endswith(".h"): + return "*.h" + else: + return "*.c" + class FileSizeItem(Item): """ Denotes a problem with the size of a .c file. diff --git a/scripts/maint/practracker/util.py b/scripts/maint/practracker/util.py index 5a8876a0f6..695668f561 100644 --- a/scripts/maint/practracker/util.py +++ b/scripts/maint/practracker/util.py @@ -5,12 +5,14 @@ import os EXCLUDE_SOURCE_DIRS = {"src/test/", "src/trunnel/", "src/rust/", "src/ext/", ".git/"} +EXCLUDE_FILES = {"orconfig.h"} + def _norm(p): return os.path.normcase(os.path.normpath(p)) def get_tor_c_files(tor_topdir): """ - Return a list with the .c filenames we want to get metrics of. + Return a list with the .c and .h filenames we want to get metrics of. """ files_list = [] exclude_dirs = { _norm(os.path.join(tor_topdir, p)) for p in EXCLUDE_SOURCE_DIRS } @@ -23,8 +25,10 @@ def get_tor_c_files(tor_topdir): directories.sort() filenames.sort() for filename in filenames: - # We only care about .c files - if not filename.endswith(".c"): + # We only care about .c and .h files + if not (filename.endswith(".c") or filename.endswith(".h")): + continue + if filename in EXCLUDE_FILES: continue full_path = os.path.join(root,filename) diff --git a/src/app/config/auth_dirs.inc b/src/app/config/auth_dirs.inc index 08a919b053..278f08bfcf 100644 --- a/src/app/config/auth_dirs.inc +++ b/src/app/config/auth_dirs.inc @@ -7,7 +7,7 @@ "86.59.21.38:80 847B 1F85 0344 D787 6491 A548 92F9 0493 4E4E B85D", "dizum orport=443 " "v3ident=E8A9C45EDE6D711294FADF8E7951F4DE6CA56B58 " - "194.109.206.212:80 7EA6 EAD6 FD83 083C 538F 4403 8BBF A077 587D D755", + "45.66.33.45:80 7EA6 EAD6 FD83 083C 538F 4403 8BBF A077 587D D755", "Serge orport=9001 bridge " "66.111.2.131:9030 BA44 A889 E64B 93FA A2B1 14E0 2C2A 279A 8555 C533", "gabelmoo orport=443 " diff --git a/src/feature/dirauth/keypin.c b/src/feature/dirauth/keypin.c index 667feb2c03..3ca2c3ef91 100644 --- a/src/feature/dirauth/keypin.c +++ b/src/feature/dirauth/keypin.c @@ -438,7 +438,7 @@ keypin_load_journal_impl(const char *data, size_t size) tor_log(severity, LD_DIRSERV, "Loaded %d entries from keypin journal. " "Found %d corrupt lines (ignored), %d duplicates (harmless), " - "and %d conflicts (resolved in favor or more recent entry).", + "and %d conflicts (resolved in favor of more recent entry).", n_entries, n_corrupt_lines, n_duplicates, n_conflicts); return 0; diff --git a/src/test/test_btrack.c b/src/test/test_btrack.c index 9e5d0d0723..21e88a57b6 100644 --- a/src/test/test_btrack.c +++ b/src/test/test_btrack.c @@ -44,6 +44,8 @@ test_btrack_launch(void *arg) { orconn_state_msg_t conn; ocirc_chan_msg_t circ; + memset(&conn, 0, sizeof(conn)); + memset(&circ, 0, sizeof(circ)); (void)arg; conn.gid = 1; @@ -93,6 +95,8 @@ test_btrack_delete(void *arg) { orconn_state_msg_t state; orconn_status_msg_t status; + memset(&state, 0, sizeof(state)); + memset(&status, 0, sizeof(status)); (void)arg; state.gid = 1; diff --git a/src/test/test_controller_events.c b/src/test/test_controller_events.c index a8967bba50..9fb2bc7256 100644 --- a/src/test/test_controller_events.c +++ b/src/test/test_controller_events.c @@ -429,6 +429,7 @@ static void test_cntev_orconn_state(void *arg) { orconn_state_msg_t conn; + memset(&conn, 0, sizeof(conn)); (void)arg; MOCK(queue_control_event_string, mock_queue_control_event_string); @@ -468,6 +469,7 @@ static void test_cntev_orconn_state_pt(void *arg) { orconn_state_msg_t conn; + memset(&conn, 0, sizeof(conn)); (void)arg; MOCK(queue_control_event_string, mock_queue_control_event_string); @@ -503,6 +505,7 @@ static void test_cntev_orconn_state_proxy(void *arg) { orconn_state_msg_t conn; + memset(&conn, 0, sizeof(conn)); (void)arg; MOCK(queue_control_event_string, mock_queue_control_event_string); diff --git a/src/test/test_hs_common.c b/src/test/test_hs_common.c index abded6021e..de3f7e04f7 100644 --- a/src/test/test_hs_common.c +++ b/src/test/test_hs_common.c @@ -502,6 +502,7 @@ test_desc_reupload_logic(void *arg) pubkey_hex, strlen(pubkey_hex)); hs_build_address(&pubkey, HS_VERSION_THREE, onion_addr); service = tor_malloc_zero(sizeof(hs_service_t)); + tt_assert(service); memcpy(service->onion_address, onion_addr, sizeof(service->onion_address)); ed25519_secret_key_generate(&service->keys.identity_sk, 0); ed25519_public_key_generate(&service->keys.identity_pk, diff --git a/src/test/test_hs_service.c b/src/test/test_hs_service.c index a303f10411..2e4be4e295 100644 --- a/src/test/test_hs_service.c +++ b/src/test/test_hs_service.c @@ -1265,6 +1265,7 @@ test_service_event(void *arg) /* Set a service for this circuit. */ service = helper_create_service(); + tt_assert(service); ed25519_pubkey_copy(&circ->hs_ident->identity_pk, &service->keys.identity_pk); diff --git a/src/test/test_introduce.c b/src/test/test_introduce.c index 4a6d90d97e..104e973b1f 100644 --- a/src/test/test_introduce.c +++ b/src/test/test_introduce.c @@ -383,8 +383,10 @@ make_intro_from_plaintext( /* Output the cell */ *cell_out = cell; + cell = NULL; done: + tor_free(cell); return cell_len; } @@ -535,4 +537,3 @@ struct testcase_t introduce_tests[] = { INTRODUCE_LEGACY(late_parse_v3), END_OF_TESTCASES }; - diff --git a/src/test/test_token_bucket.c b/src/test/test_token_bucket.c index d3ce591388..31670718d9 100644 --- a/src/test/test_token_bucket.c +++ b/src/test/test_token_bucket.c @@ -93,7 +93,7 @@ test_token_bucket_ctr_dec(void *arg) /* Keep underflowing shouldn't flag the bucket as empty. */ tt_uint_op(false, OP_EQ, token_bucket_ctr_dec(&tb, BURST)); - tt_int_op(tb.counter.bucket, OP_EQ, (int32_t) ((BURST + 1) * -1)); + tt_int_op(tb.counter.bucket, OP_EQ, - (int32_t) (BURST + 1)); done: ; diff --git a/src/test/test_util.c b/src/test/test_util.c index 41ecbfd388..c56d3488ba 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -5399,11 +5399,13 @@ test_util_socketpair(void *arg) tt_skip(); } #endif /* defined(__FreeBSD__) */ +#ifdef ENETUNREACH if (ersatz && socketpair_result == -ENETUNREACH) { /* We can also fail with -ENETUNREACH if we have no network stack at * all. */ tt_skip(); } +#endif tt_int_op(0, OP_EQ, socketpair_result); tt_assert(SOCKET_OK(fds[0])); |