diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-05-29 14:09:11 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-05-29 14:09:11 -0400 |
commit | ba17968534ea51bbf5e3a0ab0cf4da97ef895252 (patch) | |
tree | 612063c4db36ba6ab54d30231d6be1222be1d513 /src/test/test_scheduler.c | |
parent | 10dd50dfcb19069465480c9cfdf57372123a0b3b (diff) | |
download | tor-ba17968534ea51bbf5e3a0ab0cf4da97ef895252.tar.gz tor-ba17968534ea51bbf5e3a0ab0cf4da97ef895252.zip |
Fix another int-to-ptr cast.
Diffstat (limited to 'src/test/test_scheduler.c')
-rw-r--r-- | src/test/test_scheduler.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/test/test_scheduler.c b/src/test/test_scheduler.c index 73a422088f..79a5534505 100644 --- a/src/test/test_scheduler.c +++ b/src/test/test_scheduler.c @@ -38,9 +38,9 @@ static circuitmux_t *mock_ccm_tgt_1 = NULL; static circuitmux_t *mock_ccm_tgt_2 = NULL; static circuitmux_t *mock_cgp_tgt_1 = NULL; -static const circuitmux_policy_t *mock_cgp_val_1 = NULL; +static circuitmux_policy_t *mock_cgp_val_1 = NULL; static circuitmux_t *mock_cgp_tgt_2 = NULL; -static const circuitmux_policy_t *mock_cgp_val_2 = NULL; +static circuitmux_policy_t *mock_cgp_val_2 = NULL; static int scheduler_compare_channels_mock_ctr = 0; static int scheduler_run_mock_ctr = 0; @@ -457,13 +457,19 @@ test_scheduler_compare_channels(void *arg) /* Configure circuitmux_get_policy() mock */ mock_cgp_tgt_1 = cm1; + mock_cgp_tgt_2 = cm2; + /* * This is to test the different-policies case, which uses the policy * cast to an intptr_t as an arbitrary but definite thing to compare. */ - mock_cgp_val_1 = (const circuitmux_policy_t *)(1); - mock_cgp_tgt_2 = cm2; - mock_cgp_val_2 = (const circuitmux_policy_t *)(2); + mock_cgp_val_1 = tor_malloc_zero(16); + mock_cgp_val_2 = tor_malloc_zero(16); + if ( ((intptr_t) mock_cgp_val_1) > ((intptr_t) mock_cgp_val_2) ) { + void *tmp = mock_cgp_val_1; + mock_cgp_val_1 = mock_cgp_val_2; + mock_cgp_val_2 = tmp; + } MOCK(circuitmux_get_policy, circuitmux_get_policy_mock); @@ -483,6 +489,7 @@ test_scheduler_compare_channels(void *arg) tt_int_op(result, ==, 1); /* Distinct channels, same policy */ + tor_free(mock_cgp_val_2); mock_cgp_val_2 = mock_cgp_val_1; result = scheduler_compare_channels(&c1, &c2); tt_int_op(result, ==, -1); @@ -497,13 +504,17 @@ test_scheduler_compare_channels(void *arg) UNMOCK(circuitmux_get_policy); mock_cgp_tgt_1 = NULL; - mock_cgp_val_1 = NULL; mock_cgp_tgt_2 = NULL; - mock_cgp_val_2 = NULL; tor_free(cm1); tor_free(cm2); + if (mock_cgp_val_1 != mock_cgp_val_2) + tor_free(mock_cgp_val_1); + tor_free(mock_cgp_val_2); + mock_cgp_val_1 = NULL; + mock_cgp_val_2 = NULL; + return; } |