From 1029772b39c7aab734c43df1188180764ff5c34b Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Thu, 8 Dec 2022 17:52:42 +0900 Subject: TESTING: Properly handle label allocations --- src/transport/test_transport_plugin_cmd_udp_backchannel.c | 11 ++++++----- src/transport/transport-testing-cmds.h | 9 ++++++--- src/transport/transport_api_cmd_backchannel_check.c | 2 +- src/transport/transport_api_cmd_connecting_peers.c | 2 +- src/transport/transport_api_cmd_start_peer.c | 11 +++++++---- src/transport/transport_api_cmd_stop_peer.c | 2 +- 6 files changed, 22 insertions(+), 15 deletions(-) (limited to 'src/transport') diff --git a/src/transport/test_transport_plugin_cmd_udp_backchannel.c b/src/transport/test_transport_plugin_cmd_udp_backchannel.c index 81445b25e..1bc965848 100644 --- a/src/transport/test_transport_plugin_cmd_udp_backchannel.c +++ b/src/transport/test_transport_plugin_cmd_udp_backchannel.c @@ -90,7 +90,7 @@ get_waiting_for_barriers () { struct GNUNET_TESTING_Barrier *barrier; - //No Barrier + // No Barrier return NULL; } @@ -98,7 +98,8 @@ get_waiting_for_barriers () static void barrier_advanced (const char *barrier_name) { - struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is, barrier_name); + struct GNUNET_TESTING_Barrier *barrier = GNUNET_TESTING_get_barrier (is, + barrier_name); GNUNET_TESTING_finish_attached_cmds (is, barrier); } @@ -329,9 +330,9 @@ start_testcase (TESTING_CMD_HELPER_write_cb write_message, ts->write_message = write_message; is = GNUNET_TESTING_run (commands, - TIMEOUT, - &handle_result, - ts); + TIMEOUT, + &handle_result, + ts); } diff --git a/src/transport/transport-testing-cmds.h b/src/transport/transport-testing-cmds.h index 680162563..26933a575 100644 --- a/src/transport/transport-testing-cmds.h +++ b/src/transport/transport-testing-cmds.h @@ -109,20 +109,22 @@ struct StartPeerState /** * The ip of a node. */ - const char *node_ip; + char *node_ip; /** * Receive callback */ struct GNUNET_MQ_MessageHandler *handlers; - const char *cfgname; + //FIXME documentation + char *cfgname; /** * Peer's configuration */ struct GNUNET_CONFIGURATION_Handle *cfg; + //FIXME documentation struct GNUNET_TESTING_Peer *peer; /** @@ -165,13 +167,14 @@ struct StartPeerState */ size_t hello_size; + /** All of the below: FIXME documentation */ char *m; char *n; char *local_m; - const char *system_label; + char *system_label; /** * An unique number to identify the peer diff --git a/src/transport/transport_api_cmd_backchannel_check.c b/src/transport/transport_api_cmd_backchannel_check.c index 0376275a3..e67d9a79c 100644 --- a/src/transport/transport_api_cmd_backchannel_check.c +++ b/src/transport/transport_api_cmd_backchannel_check.c @@ -547,7 +547,7 @@ GNUNET_TRANSPORT_cmd_backchannel_check (const char *label, struct GNUNET_TESTING_Command cmd = { .cls = cs, - .label = label, + .label = GNUNET_strdup (label), .run = &backchannel_check_run, .ac = &cs->ac, .cleanup = &backchannel_check_cleanup, diff --git a/src/transport/transport_api_cmd_connecting_peers.c b/src/transport/transport_api_cmd_connecting_peers.c index a6006f698..d610bbcb7 100644 --- a/src/transport/transport_api_cmd_connecting_peers.c +++ b/src/transport/transport_api_cmd_connecting_peers.c @@ -254,7 +254,7 @@ GNUNET_TRANSPORT_cmd_connect_peers (const char *label, { struct GNUNET_TESTING_Command cmd = { .cls = cps, - .label = label, + .label = GNUNET_strdup (label), .run = &connect_peers_run, .ac = &cps->ac, .cleanup = &connect_peers_cleanup, diff --git a/src/transport/transport_api_cmd_start_peer.c b/src/transport/transport_api_cmd_start_peer.c index 5dfb820e0..7de1d842e 100644 --- a/src/transport/transport_api_cmd_start_peer.c +++ b/src/transport/transport_api_cmd_start_peer.c @@ -386,6 +386,9 @@ start_peer_cleanup (void *cls) GNUNET_CONFIGURATION_destroy (sps->cfg); sps->cfg = NULL; } + GNUNET_free (sps->cfgname); + GNUNET_free (sps->node_ip); + GNUNET_free (sps->system_label); GNUNET_free (sps->hello); GNUNET_free (sps->connected_peers_map); GNUNET_free (sps); @@ -449,10 +452,10 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label, sps = GNUNET_new (struct StartPeerState); sps->no = no; - sps->system_label = system_label; + sps->system_label = GNUNET_strdup (system_label); sps->connected_peers_map = connected_peers_map; - sps->cfgname = cfgname; - sps->node_ip = node_ip; + sps->cfgname = GNUNET_strdup (cfgname); + sps->node_ip = GNUNET_strdup (node_ip); sps->notify_connect = notify_connect; sps->broadcast = broadcast; @@ -469,7 +472,7 @@ GNUNET_TRANSPORT_cmd_start_peer (const char *label, struct GNUNET_TESTING_Command cmd = { .cls = sps, - .label = label, + .label = GNUNET_strdup (label), .run = &start_peer_run, .ac = &sps->ac, .cleanup = &start_peer_cleanup, diff --git a/src/transport/transport_api_cmd_stop_peer.c b/src/transport/transport_api_cmd_stop_peer.c index 4ca730add..04c822155 100644 --- a/src/transport/transport_api_cmd_stop_peer.c +++ b/src/transport/transport_api_cmd_stop_peer.c @@ -146,7 +146,7 @@ GNUNET_TRANSPORT_cmd_stop_peer (const char *label, { struct GNUNET_TESTING_Command cmd = { .cls = sps, - .label = label, + .label = GNUNET_strdup (label), .run = &stop_peer_run, .cleanup = &stop_peer_cleanup, .traits = &stop_peer_traits -- cgit v1.2.3