]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
squash! Pass const uint64_t pointers, document array length.
authorKarsten Loesing <karsten.loesing@gmx.net>
Mon, 28 Oct 2013 09:48:18 +0000 (10:48 +0100)
committerKarsten Loesing <karsten.loesing@gmx.net>
Mon, 28 Oct 2013 09:48:18 +0000 (10:48 +0100)
Don't cast uint64_t * to const uint64_t * explicitly.  The cast is always
safe, so C does it for us.  Doing the cast explitictly can hide bugs if
the input is secretly the wrong type.

Suggested by Nick.

src/or/control.c
src/test/test_controller_events.c

index 73769733cbe99f69d784cecaec3636e8992a34f0..9e026b391c1f56e9752a81827fb3f4ec496eafda 100644 (file)
@@ -4093,14 +4093,14 @@ format_cell_stats(char **event_string, circuit_t *circ,
     smartlist_add_asprintf(event_parts, "InboundConn="U64_FORMAT,
                  U64_PRINTF_ARG(or_circ->p_chan->global_identifier));
     append_cell_stats_by_command(event_parts, "InboundAdded",
-                 (const uint64_t *) cell_stats->added_cells_appward,
-                 (const uint64_t *) cell_stats->added_cells_appward);
+                                 cell_stats->added_cells_appward,
+                                 cell_stats->added_cells_appward);
     append_cell_stats_by_command(event_parts, "InboundRemoved",
-                 (const uint64_t *) cell_stats->removed_cells_appward,
-                 (const uint64_t *) cell_stats->removed_cells_appward);
+                                 cell_stats->removed_cells_appward,
+                                 cell_stats->removed_cells_appward);
     append_cell_stats_by_command(event_parts, "InboundTime",
-                 (const uint64_t *) cell_stats->removed_cells_appward,
-                 (const uint64_t *) cell_stats->total_time_appward);
+                                 cell_stats->removed_cells_appward,
+                                 cell_stats->total_time_appward);
   }
   if (circ->n_chan) {
     smartlist_add_asprintf(event_parts, "OutboundQueue=%lu",
@@ -4108,14 +4108,14 @@ format_cell_stats(char **event_string, circuit_t *circ,
     smartlist_add_asprintf(event_parts, "OutboundConn="U64_FORMAT,
                  U64_PRINTF_ARG(circ->n_chan->global_identifier));
     append_cell_stats_by_command(event_parts, "OutboundAdded",
-                 (const uint64_t *) cell_stats->added_cells_exitward,
-                 (const uint64_t *) cell_stats->added_cells_exitward);
+                                 cell_stats->added_cells_exitward,
+                                 cell_stats->added_cells_exitward);
     append_cell_stats_by_command(event_parts, "OutboundRemoved",
-                 (const uint64_t *) cell_stats->removed_cells_exitward,
-                 (const uint64_t *) cell_stats->removed_cells_exitward);
+                                 cell_stats->removed_cells_exitward,
+                                 cell_stats->removed_cells_exitward);
     append_cell_stats_by_command(event_parts, "OutboundTime",
-                 (const uint64_t *) cell_stats->removed_cells_exitward,
-                 (const uint64_t *) cell_stats->total_time_exitward);
+                                 cell_stats->removed_cells_exitward,
+                                 cell_stats->total_time_exitward);
   }
   *event_string = smartlist_join_strings(event_parts, " ", 0, NULL);
   SMARTLIST_FOREACH(event_parts, char *, cp, tor_free(cp));
index 0b5434cd38ecc3cd66d8c65c22924a3e30f32f52..04a04de5b00566f94b4b1f61aa668646a537c62a 100644 (file)
@@ -159,31 +159,31 @@ test_cntev_append_cell_stats(void *arg)
 
   /* All array entries empty. */
   append_cell_stats_by_command(event_parts, key,
-                               (const uint64_t *) include_if_non_zero,
-                               (const uint64_t *) number_to_include);
+                               include_if_non_zero,
+                               number_to_include);
   tt_int_op(0, ==, smartlist_len(event_parts));
 
   /* There's a RELAY cell to include, but the corresponding field in
    * include_if_non_zero is still zero. */
   number_to_include[CELL_RELAY] = 1;
   append_cell_stats_by_command(event_parts, key,
-                               (const uint64_t *) include_if_non_zero,
-                               (const uint64_t *) number_to_include);
+                               include_if_non_zero,
+                               number_to_include);
   tt_int_op(0, ==, smartlist_len(event_parts));
 
   /* Now include single RELAY cell. */
   include_if_non_zero[CELL_RELAY] = 2;
   append_cell_stats_by_command(event_parts, key,
-                               (const uint64_t *) include_if_non_zero,
-                               (const uint64_t *) number_to_include);
+                               include_if_non_zero,
+                               number_to_include);
   tt_str_op("Z=relay:1", ==, smartlist_pop_last(event_parts));
 
   /* Add four CREATE cells. */
   include_if_non_zero[CELL_CREATE] = 3;
   number_to_include[CELL_CREATE] = 4;
   append_cell_stats_by_command(event_parts, key,
-                               (const uint64_t *) include_if_non_zero,
-                               (const uint64_t *) number_to_include);
+                               include_if_non_zero,
+                               number_to_include);
   tt_str_op("Z=create:4,relay:1", ==, smartlist_pop_last(event_parts));
 
  done: