mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Pass const uint64_t pointers, document array length.
Suggested by nickm.
This commit is contained in:
parent
d5f0d792dd
commit
b43a37bc5b
@ -4048,13 +4048,14 @@ sum_up_cell_stats_by_command(circuit_t *circ, cell_stats_t *cell_stats)
|
|||||||
* key:value pairs with lower-case command strings as keys and cell
|
* key:value pairs with lower-case command strings as keys and cell
|
||||||
* numbers or total waiting times as values. A key:value pair is included
|
* numbers or total waiting times as values. A key:value pair is included
|
||||||
* if the entry in <code>include_if_non_zero</code> is not zero, but with
|
* if the entry in <code>include_if_non_zero</code> is not zero, but with
|
||||||
* the (possibly zero) entry from <code>number_to_include</code>. If no
|
* the (possibly zero) entry from <code>number_to_include</code>. Both
|
||||||
|
* arrays are expected to have a length of CELL_COMMAND_MAX_ + 1. If no
|
||||||
* entry in <code>include_if_non_zero</code> is positive, no string will
|
* entry in <code>include_if_non_zero</code> is positive, no string will
|
||||||
* be added to <code>event_parts</code>. */
|
* be added to <code>event_parts</code>. */
|
||||||
void
|
void
|
||||||
append_cell_stats_by_command(smartlist_t *event_parts, const char *key,
|
append_cell_stats_by_command(smartlist_t *event_parts, const char *key,
|
||||||
uint64_t *include_if_non_zero,
|
const uint64_t *include_if_non_zero,
|
||||||
uint64_t *number_to_include)
|
const uint64_t *number_to_include)
|
||||||
{
|
{
|
||||||
smartlist_t *key_value_strings = smartlist_new();
|
smartlist_t *key_value_strings = smartlist_new();
|
||||||
int i;
|
int i;
|
||||||
@ -4092,14 +4093,14 @@ format_cell_stats(char **event_string, circuit_t *circ,
|
|||||||
smartlist_add_asprintf(event_parts, "InboundConn="U64_FORMAT,
|
smartlist_add_asprintf(event_parts, "InboundConn="U64_FORMAT,
|
||||||
U64_PRINTF_ARG(or_circ->p_chan->global_identifier));
|
U64_PRINTF_ARG(or_circ->p_chan->global_identifier));
|
||||||
append_cell_stats_by_command(event_parts, "InboundAdded",
|
append_cell_stats_by_command(event_parts, "InboundAdded",
|
||||||
cell_stats->added_cells_appward,
|
(const uint64_t *) cell_stats->added_cells_appward,
|
||||||
cell_stats->added_cells_appward);
|
(const uint64_t *) cell_stats->added_cells_appward);
|
||||||
append_cell_stats_by_command(event_parts, "InboundRemoved",
|
append_cell_stats_by_command(event_parts, "InboundRemoved",
|
||||||
cell_stats->removed_cells_appward,
|
(const uint64_t *) cell_stats->removed_cells_appward,
|
||||||
cell_stats->removed_cells_appward);
|
(const uint64_t *) cell_stats->removed_cells_appward);
|
||||||
append_cell_stats_by_command(event_parts, "InboundTime",
|
append_cell_stats_by_command(event_parts, "InboundTime",
|
||||||
cell_stats->removed_cells_appward,
|
(const uint64_t *) cell_stats->removed_cells_appward,
|
||||||
cell_stats->total_time_appward);
|
(const uint64_t *) cell_stats->total_time_appward);
|
||||||
}
|
}
|
||||||
if (circ->n_chan) {
|
if (circ->n_chan) {
|
||||||
smartlist_add_asprintf(event_parts, "OutboundQueue=%lu",
|
smartlist_add_asprintf(event_parts, "OutboundQueue=%lu",
|
||||||
@ -4107,14 +4108,14 @@ format_cell_stats(char **event_string, circuit_t *circ,
|
|||||||
smartlist_add_asprintf(event_parts, "OutboundConn="U64_FORMAT,
|
smartlist_add_asprintf(event_parts, "OutboundConn="U64_FORMAT,
|
||||||
U64_PRINTF_ARG(circ->n_chan->global_identifier));
|
U64_PRINTF_ARG(circ->n_chan->global_identifier));
|
||||||
append_cell_stats_by_command(event_parts, "OutboundAdded",
|
append_cell_stats_by_command(event_parts, "OutboundAdded",
|
||||||
cell_stats->added_cells_exitward,
|
(const uint64_t *) cell_stats->added_cells_exitward,
|
||||||
cell_stats->added_cells_exitward);
|
(const uint64_t *) cell_stats->added_cells_exitward);
|
||||||
append_cell_stats_by_command(event_parts, "OutboundRemoved",
|
append_cell_stats_by_command(event_parts, "OutboundRemoved",
|
||||||
cell_stats->removed_cells_exitward,
|
(const uint64_t *) cell_stats->removed_cells_exitward,
|
||||||
cell_stats->removed_cells_exitward);
|
(const uint64_t *) cell_stats->removed_cells_exitward);
|
||||||
append_cell_stats_by_command(event_parts, "OutboundTime",
|
append_cell_stats_by_command(event_parts, "OutboundTime",
|
||||||
cell_stats->removed_cells_exitward,
|
(const uint64_t *) cell_stats->removed_cells_exitward,
|
||||||
cell_stats->total_time_exitward);
|
(const uint64_t *) cell_stats->total_time_exitward);
|
||||||
}
|
}
|
||||||
*event_string = smartlist_join_strings(event_parts, " ", 0, NULL);
|
*event_string = smartlist_join_strings(event_parts, " ", 0, NULL);
|
||||||
SMARTLIST_FOREACH(event_parts, char *, cp, tor_free(cp));
|
SMARTLIST_FOREACH(event_parts, char *, cp, tor_free(cp));
|
||||||
|
@ -120,8 +120,8 @@ void sum_up_cell_stats_by_command(circuit_t *circ,
|
|||||||
cell_stats_t *cell_stats);
|
cell_stats_t *cell_stats);
|
||||||
void append_cell_stats_by_command(smartlist_t *event_parts,
|
void append_cell_stats_by_command(smartlist_t *event_parts,
|
||||||
const char *key,
|
const char *key,
|
||||||
uint64_t *include_if_non_zero,
|
const uint64_t *include_if_non_zero,
|
||||||
uint64_t *number_to_include);
|
const uint64_t *number_to_include);
|
||||||
void format_cell_stats(char **event_string, circuit_t *circ,
|
void format_cell_stats(char **event_string, circuit_t *circ,
|
||||||
cell_stats_t *cell_stats);
|
cell_stats_t *cell_stats);
|
||||||
#endif
|
#endif
|
||||||
|
@ -158,28 +158,32 @@ test_cntev_append_cell_stats(void *arg)
|
|||||||
(CELL_COMMAND_MAX_ + 1) * sizeof(uint64_t));
|
(CELL_COMMAND_MAX_ + 1) * sizeof(uint64_t));
|
||||||
|
|
||||||
/* All array entries empty. */
|
/* All array entries empty. */
|
||||||
append_cell_stats_by_command(event_parts, key, include_if_non_zero,
|
append_cell_stats_by_command(event_parts, key,
|
||||||
number_to_include);
|
(const uint64_t *) include_if_non_zero,
|
||||||
|
(const uint64_t *) number_to_include);
|
||||||
tt_int_op(0, ==, smartlist_len(event_parts));
|
tt_int_op(0, ==, smartlist_len(event_parts));
|
||||||
|
|
||||||
/* There's a RELAY cell to include, but the corresponding field in
|
/* There's a RELAY cell to include, but the corresponding field in
|
||||||
* include_if_non_zero is still zero. */
|
* include_if_non_zero is still zero. */
|
||||||
number_to_include[CELL_RELAY] = 1;
|
number_to_include[CELL_RELAY] = 1;
|
||||||
append_cell_stats_by_command(event_parts, key, include_if_non_zero,
|
append_cell_stats_by_command(event_parts, key,
|
||||||
number_to_include);
|
(const uint64_t *) include_if_non_zero,
|
||||||
|
(const uint64_t *) number_to_include);
|
||||||
tt_int_op(0, ==, smartlist_len(event_parts));
|
tt_int_op(0, ==, smartlist_len(event_parts));
|
||||||
|
|
||||||
/* Now include single RELAY cell. */
|
/* Now include single RELAY cell. */
|
||||||
include_if_non_zero[CELL_RELAY] = 2;
|
include_if_non_zero[CELL_RELAY] = 2;
|
||||||
append_cell_stats_by_command(event_parts, key, include_if_non_zero,
|
append_cell_stats_by_command(event_parts, key,
|
||||||
number_to_include);
|
(const uint64_t *) include_if_non_zero,
|
||||||
|
(const uint64_t *) number_to_include);
|
||||||
tt_str_op("Z=relay:1", ==, smartlist_pop_last(event_parts));
|
tt_str_op("Z=relay:1", ==, smartlist_pop_last(event_parts));
|
||||||
|
|
||||||
/* Add four CREATE cells. */
|
/* Add four CREATE cells. */
|
||||||
include_if_non_zero[CELL_CREATE] = 3;
|
include_if_non_zero[CELL_CREATE] = 3;
|
||||||
number_to_include[CELL_CREATE] = 4;
|
number_to_include[CELL_CREATE] = 4;
|
||||||
append_cell_stats_by_command(event_parts, key, include_if_non_zero,
|
append_cell_stats_by_command(event_parts, key,
|
||||||
number_to_include);
|
(const uint64_t *) include_if_non_zero,
|
||||||
|
(const uint64_t *) number_to_include);
|
||||||
tt_str_op("Z=create:4,relay:1", ==, smartlist_pop_last(event_parts));
|
tt_str_op("Z=create:4,relay:1", ==, smartlist_pop_last(event_parts));
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
Loading…
Reference in New Issue
Block a user