diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-02-13 00:11:53 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-02-13 00:11:53 +0000 |
commit | 3e693f3ceb1b3425b17900423628aecb609f2433 (patch) | |
tree | 2dd5d5694771de9458eb8c394ce704dea1d0c87e | |
parent | c1fa22fd40d14035c8d323cb4ae8724970850e73 (diff) | |
download | gnunet-3e693f3ceb1b3425b17900423628aecb609f2433.tar.gz gnunet-3e693f3ceb1b3425b17900423628aecb609f2433.zip |
-fixing misc minor bugs and style issues (unchecked return values, memory leaks, dead code
-rw-r--r-- | src/ats/ats_api_scheduling.c | 8 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_addresses.c | 15 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_performance.c | 6 | ||||
-rw-r--r-- | src/ats/gnunet-service-ats_reservations.c | 8 | ||||
-rw-r--r-- | src/ats/plugin_ats_proportional.c | 2 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_validation.c | 1 | ||||
-rw-r--r-- | src/transport/gnunet-transport.c | 11 | ||||
-rw-r--r-- | src/transport/plugin_transport_tcp.c | 4 | ||||
-rw-r--r-- | src/transport/plugin_transport_unix.c | 1 |
9 files changed, 25 insertions, 31 deletions
diff --git a/src/ats/ats_api_scheduling.c b/src/ats/ats_api_scheduling.c index 333881a37..646cb9b1f 100644 --- a/src/ats/ats_api_scheduling.c +++ b/src/ats/ats_api_scheduling.c | |||
@@ -491,9 +491,7 @@ send_add_address_message (struct GNUNET_ATS_SchedulingHandle *sh, | |||
491 | 491 | ||
492 | if (NULL == sh->mq) | 492 | if (NULL == sh->mq) |
493 | return; /* disconnected, skip for now */ | 493 | return; /* disconnected, skip for now */ |
494 | namelen = (NULL == ar->address->transport_name) | 494 | namelen = strlen (ar->address->transport_name) + 1; |
495 | ? 0 | ||
496 | : strlen (ar->address->transport_name) + 1; | ||
497 | msize = ar->address->address_length + namelen; | 495 | msize = ar->address->address_length + namelen; |
498 | ev = GNUNET_MQ_msg_extra (m, msize, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD); | 496 | ev = GNUNET_MQ_msg_extra (m, msize, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD); |
499 | m->peer = ar->address->peer; | 497 | m->peer = ar->address->peer; |
@@ -671,9 +669,7 @@ GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh, | |||
671 | GNUNET_break (0); | 669 | GNUNET_break (0); |
672 | return NULL; | 670 | return NULL; |
673 | } | 671 | } |
674 | namelen = (NULL == address->transport_name) | 672 | namelen = strlen (address->transport_name) + 1; |
675 | ? 0 | ||
676 | : strlen (address->transport_name) + 1; | ||
677 | msize = address->address_length + namelen; | 673 | msize = address->address_length + namelen; |
678 | if ((msize + sizeof (struct AddressUpdateMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 674 | if ((msize + sizeof (struct AddressUpdateMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || |
679 | (address->address_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || | 675 | (address->address_length >= GNUNET_SERVER_MAX_MESSAGE_SIZE) || |
diff --git a/src/ats/gnunet-service-ats_addresses.c b/src/ats/gnunet-service-ats_addresses.c index e96197813..28c474e2c 100644 --- a/src/ats/gnunet-service-ats_addresses.c +++ b/src/ats/gnunet-service-ats_addresses.c | |||
@@ -58,9 +58,10 @@ update_addresses_stat () | |||
58 | static void | 58 | static void |
59 | free_address (struct ATS_Address *addr) | 59 | free_address (struct ATS_Address *addr) |
60 | { | 60 | { |
61 | GNUNET_CONTAINER_multipeermap_remove (GSA_addresses, | 61 | GNUNET_assert (GNUNET_YES == |
62 | &addr->peer, | 62 | GNUNET_CONTAINER_multipeermap_remove (GSA_addresses, |
63 | addr); | 63 | &addr->peer, |
64 | addr)); | ||
64 | update_addresses_stat (); | 65 | update_addresses_stat (); |
65 | GAS_plugin_delete_address (addr); | 66 | GAS_plugin_delete_address (addr); |
66 | GAS_performance_notify_all_clients (&addr->peer, | 67 | GAS_performance_notify_all_clients (&addr->peer, |
@@ -551,6 +552,7 @@ transmit_req_addr (struct AddressIteration *ai, | |||
551 | char *addrp; | 552 | char *addrp; |
552 | size_t plugin_name_length; | 553 | size_t plugin_name_length; |
553 | size_t msize; | 554 | size_t msize; |
555 | struct GNUNET_SERVER_NotificationContext **uc; | ||
554 | struct GNUNET_SERVER_NotificationContext *nc; | 556 | struct GNUNET_SERVER_NotificationContext *nc; |
555 | 557 | ||
556 | if (NULL != plugin_name) | 558 | if (NULL != plugin_name) |
@@ -587,13 +589,14 @@ transmit_req_addr (struct AddressIteration *ai, | |||
587 | memcpy (addrp, plugin_addr, plugin_addr_len); | 589 | memcpy (addrp, plugin_addr, plugin_addr_len); |
588 | if (NULL != plugin_name) | 590 | if (NULL != plugin_name) |
589 | strcpy (&addrp[plugin_addr_len], plugin_name); | 591 | strcpy (&addrp[plugin_addr_len], plugin_name); |
590 | nc = *GNUNET_SERVER_client_get_user_context (ai->client, | 592 | uc = GNUNET_SERVER_client_get_user_context (ai->client, |
591 | struct GNUNET_SERVER_NotificationContext *); | 593 | struct GNUNET_SERVER_NotificationContext *); |
592 | if (NULL == nc) | 594 | if (NULL == uc) |
593 | { | 595 | { |
594 | GNUNET_break (0); | 596 | GNUNET_break (0); |
595 | return; | 597 | return; |
596 | } | 598 | } |
599 | nc = *uc; | ||
597 | GNUNET_SERVER_notification_context_unicast (nc, | 600 | GNUNET_SERVER_notification_context_unicast (nc, |
598 | ai->client, | 601 | ai->client, |
599 | &msg->header, | 602 | &msg->header, |
diff --git a/src/ats/gnunet-service-ats_performance.c b/src/ats/gnunet-service-ats_performance.c index 57e4e98ff..00b5de51c 100644 --- a/src/ats/gnunet-service-ats_performance.c +++ b/src/ats/gnunet-service-ats_performance.c | |||
@@ -76,6 +76,7 @@ notify_client (struct GNUNET_SERVER_Client *client, | |||
76 | plugin_addr_len + | 76 | plugin_addr_len + |
77 | plugin_name_length; | 77 | plugin_name_length; |
78 | char buf[msize] GNUNET_ALIGN; | 78 | char buf[msize] GNUNET_ALIGN; |
79 | struct GNUNET_SERVER_NotificationContext **uc; | ||
79 | struct GNUNET_SERVER_NotificationContext *nc; | 80 | struct GNUNET_SERVER_NotificationContext *nc; |
80 | char *addrp; | 81 | char *addrp; |
81 | 82 | ||
@@ -108,13 +109,14 @@ notify_client (struct GNUNET_SERVER_Client *client, | |||
108 | } | 109 | } |
109 | else | 110 | else |
110 | { | 111 | { |
111 | nc = *GNUNET_SERVER_client_get_user_context (client, | 112 | uc = GNUNET_SERVER_client_get_user_context (client, |
112 | struct GNUNET_SERVER_NotificationContext *); | 113 | struct GNUNET_SERVER_NotificationContext *); |
113 | if (NULL == nc) | 114 | if (NULL == uc) |
114 | { | 115 | { |
115 | GNUNET_break (0); | 116 | GNUNET_break (0); |
116 | return; | 117 | return; |
117 | } | 118 | } |
119 | nc = *uc; | ||
118 | GNUNET_SERVER_notification_context_unicast (nc, | 120 | GNUNET_SERVER_notification_context_unicast (nc, |
119 | client, | 121 | client, |
120 | &msg->header, | 122 | &msg->header, |
diff --git a/src/ats/gnunet-service-ats_reservations.c b/src/ats/gnunet-service-ats_reservations.c index ba06f7634..cea0352f5 100644 --- a/src/ats/gnunet-service-ats_reservations.c +++ b/src/ats/gnunet-service-ats_reservations.c | |||
@@ -152,17 +152,19 @@ GAS_handle_reservation_request (void *cls, | |||
152 | struct ReservationResultMessage result; | 152 | struct ReservationResultMessage result; |
153 | int32_t amount; | 153 | int32_t amount; |
154 | struct GNUNET_TIME_Relative res_delay; | 154 | struct GNUNET_TIME_Relative res_delay; |
155 | struct GNUNET_SERVER_NotificationContext **uc; | ||
155 | struct GNUNET_SERVER_NotificationContext *nc; | 156 | struct GNUNET_SERVER_NotificationContext *nc; |
156 | 157 | ||
157 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
158 | "Received RESERVATION_REQUEST message\n"); | 159 | "Received RESERVATION_REQUEST message\n"); |
159 | nc = *GNUNET_SERVER_client_get_user_context (client, | 160 | uc = GNUNET_SERVER_client_get_user_context (client, |
160 | struct GNUNET_SERVER_NotificationContext *); | 161 | struct GNUNET_SERVER_NotificationContext *); |
161 | if (NULL == nc) | 162 | if (NULL == uc) |
162 | { | 163 | { |
163 | GNUNET_break (0); | 164 | GNUNET_break (0); |
164 | return; | 165 | return; |
165 | } | 166 | } |
167 | nc = *uc; | ||
166 | amount = (int32_t) ntohl (msg->amount); | 168 | amount = (int32_t) ntohl (msg->amount); |
167 | res_delay = reservations_reserve (&msg->peer, amount); | 169 | res_delay = reservations_reserve (&msg->peer, amount); |
168 | if (res_delay.rel_value_us > 0) | 170 | if (res_delay.rel_value_us > 0) |
diff --git a/src/ats/plugin_ats_proportional.c b/src/ats/plugin_ats_proportional.c index 9ad00bbb3..7dae3c8be 100644 --- a/src/ats/plugin_ats_proportional.c +++ b/src/ats/plugin_ats_proportional.c | |||
@@ -215,7 +215,7 @@ is_bandwidth_available_in_network (struct Network *net, | |||
215 | unsigned int na; | 215 | unsigned int na; |
216 | uint32_t min_bw = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); | 216 | uint32_t min_bw = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__); |
217 | 217 | ||
218 | GNUNET_assert (net->active_addresses + extra >= 0); | 218 | GNUNET_assert (((int)net->active_addresses) + extra >= 0); |
219 | na = net->active_addresses + extra; | 219 | na = net->active_addresses + extra; |
220 | if (0 == na) | 220 | if (0 == na) |
221 | return GNUNET_YES; | 221 | return GNUNET_YES; |
diff --git a/src/transport/gnunet-service-transport_validation.c b/src/transport/gnunet-service-transport_validation.c index 8f563de02..2022a8c47 100644 --- a/src/transport/gnunet-service-transport_validation.c +++ b/src/transport/gnunet-service-transport_validation.c | |||
@@ -578,6 +578,7 @@ transmit_ping_if_allowed (void *cls, | |||
578 | ve->address->address, | 578 | ve->address->address, |
579 | ve->address->address_length); | 579 | ve->address->address_length); |
580 | papi = GST_plugins_find (ve->address->transport_name); | 580 | papi = GST_plugins_find (ve->address->transport_name); |
581 | GNUNET_assert (NULL != papi); | ||
581 | session = papi->get_session (papi->cls, | 582 | session = papi->get_session (papi->cls, |
582 | ve->address); | 583 | ve->address); |
583 | if (NULL == session) | 584 | if (NULL == session) |
diff --git a/src/transport/gnunet-transport.c b/src/transport/gnunet-transport.c index 8e8c173af..bf586b7f0 100644 --- a/src/transport/gnunet-transport.c +++ b/src/transport/gnunet-transport.c | |||
@@ -940,17 +940,6 @@ process_validation_cb (void *cls, | |||
940 | _("Monitor disconnected from transport service. Reconnecting.\n")); | 940 | _("Monitor disconnected from transport service. Reconnecting.\n")); |
941 | return; | 941 | return; |
942 | } | 942 | } |
943 | |||
944 | /* done */ | ||
945 | vic = NULL; | ||
946 | if (NULL != end) | ||
947 | GNUNET_SCHEDULER_cancel (end); | ||
948 | end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL); | ||
949 | return; | ||
950 | } | ||
951 | if (NULL == address) | ||
952 | { | ||
953 | /* invalid response */ | ||
954 | vic = NULL; | 943 | vic = NULL; |
955 | if (NULL != end) | 944 | if (NULL != end) |
956 | GNUNET_SCHEDULER_cancel (end); | 945 | GNUNET_SCHEDULER_cancel (end); |
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c index 167d1c490..313cbf7f0 100644 --- a/src/transport/plugin_transport_tcp.c +++ b/src/transport/plugin_transport_tcp.c | |||
@@ -1752,7 +1752,7 @@ tcp_plugin_get_session (void *cls, | |||
1752 | plugin->cur_connections++; | 1752 | plugin->cur_connections++; |
1753 | if (plugin->cur_connections == plugin->max_connections) | 1753 | if (plugin->cur_connections == plugin->max_connections) |
1754 | { | 1754 | { |
1755 | GNUNET_STATISTICS_update (session->plugin->env->stats, | 1755 | GNUNET_STATISTICS_update (plugin->env->stats, |
1756 | gettext_noop ("# TCP service suspended"), | 1756 | gettext_noop ("# TCP service suspended"), |
1757 | 1, | 1757 | 1, |
1758 | GNUNET_NO); | 1758 | GNUNET_NO); |
@@ -2330,7 +2330,7 @@ handle_tcp_welcome (void *cls, | |||
2330 | { | 2330 | { |
2331 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 2331 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
2332 | _("TCP connection limit reached, suspending server\n")); | 2332 | _("TCP connection limit reached, suspending server\n")); |
2333 | GNUNET_STATISTICS_update (session->plugin->env->stats, | 2333 | GNUNET_STATISTICS_update (plugin->env->stats, |
2334 | gettext_noop ("# TCP service suspended"), | 2334 | gettext_noop ("# TCP service suspended"), |
2335 | 1, | 2335 | 1, |
2336 | GNUNET_NO); | 2336 | GNUNET_NO); |
diff --git a/src/transport/plugin_transport_unix.c b/src/transport/plugin_transport_unix.c index ddb5f747c..1866c56a4 100644 --- a/src/transport/plugin_transport_unix.c +++ b/src/transport/plugin_transport_unix.c | |||
@@ -1383,6 +1383,7 @@ unix_transport_server_start (void *cls) | |||
1383 | if (NULL == plugin->unix_sock.desc) | 1383 | if (NULL == plugin->unix_sock.desc) |
1384 | { | 1384 | { |
1385 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); | 1385 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket"); |
1386 | GNUNET_free (un); | ||
1386 | return GNUNET_SYSERR; | 1387 | return GNUNET_SYSERR; |
1387 | } | 1388 | } |
1388 | if ('\0' != un->sun_path[0]) | 1389 | if ('\0' != un->sun_path[0]) |