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 /src/ats | |
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
Diffstat (limited to 'src/ats')
-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 |
5 files changed, 21 insertions, 18 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; |