summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2015-02-13 00:11:53 +0000
committerChristian Grothoff <christian@grothoff.org>2015-02-13 00:11:53 +0000
commit3e693f3ceb1b3425b17900423628aecb609f2433 (patch)
tree2dd5d5694771de9458eb8c394ce704dea1d0c87e /src
parentc1fa22fd40d14035c8d323cb4ae8724970850e73 (diff)
-fixing misc minor bugs and style issues (unchecked return values, memory leaks, dead code
Diffstat (limited to 'src')
-rw-r--r--src/ats/ats_api_scheduling.c8
-rw-r--r--src/ats/gnunet-service-ats_addresses.c15
-rw-r--r--src/ats/gnunet-service-ats_performance.c6
-rw-r--r--src/ats/gnunet-service-ats_reservations.c8
-rw-r--r--src/ats/plugin_ats_proportional.c2
-rw-r--r--src/transport/gnunet-service-transport_validation.c1
-rw-r--r--src/transport/gnunet-transport.c11
-rw-r--r--src/transport/plugin_transport_tcp.c4
-rw-r--r--src/transport/plugin_transport_unix.c1
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,
if (NULL == sh->mq)
return; /* disconnected, skip for now */
- namelen = (NULL == ar->address->transport_name)
- ? 0
- : strlen (ar->address->transport_name) + 1;
+ namelen = strlen (ar->address->transport_name) + 1;
msize = ar->address->address_length + namelen;
ev = GNUNET_MQ_msg_extra (m, msize, GNUNET_MESSAGE_TYPE_ATS_ADDRESS_ADD);
m->peer = ar->address->peer;
@@ -671,9 +669,7 @@ GNUNET_ATS_address_add (struct GNUNET_ATS_SchedulingHandle *sh,
GNUNET_break (0);
return NULL;
}
- namelen = (NULL == address->transport_name)
- ? 0
- : strlen (address->transport_name) + 1;
+ namelen = strlen (address->transport_name) + 1;
msize = address->address_length + namelen;
if ((msize + sizeof (struct AddressUpdateMessage) >= GNUNET_SERVER_MAX_MESSAGE_SIZE) ||
(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 ()
static void
free_address (struct ATS_Address *addr)
{
- GNUNET_CONTAINER_multipeermap_remove (GSA_addresses,
- &addr->peer,
- addr);
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CONTAINER_multipeermap_remove (GSA_addresses,
+ &addr->peer,
+ addr));
update_addresses_stat ();
GAS_plugin_delete_address (addr);
GAS_performance_notify_all_clients (&addr->peer,
@@ -551,6 +552,7 @@ transmit_req_addr (struct AddressIteration *ai,
char *addrp;
size_t plugin_name_length;
size_t msize;
+ struct GNUNET_SERVER_NotificationContext **uc;
struct GNUNET_SERVER_NotificationContext *nc;
if (NULL != plugin_name)
@@ -587,13 +589,14 @@ transmit_req_addr (struct AddressIteration *ai,
memcpy (addrp, plugin_addr, plugin_addr_len);
if (NULL != plugin_name)
strcpy (&addrp[plugin_addr_len], plugin_name);
- nc = *GNUNET_SERVER_client_get_user_context (ai->client,
- struct GNUNET_SERVER_NotificationContext *);
- if (NULL == nc)
+ uc = GNUNET_SERVER_client_get_user_context (ai->client,
+ struct GNUNET_SERVER_NotificationContext *);
+ if (NULL == uc)
{
GNUNET_break (0);
return;
}
+ nc = *uc;
GNUNET_SERVER_notification_context_unicast (nc,
ai->client,
&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,
plugin_addr_len +
plugin_name_length;
char buf[msize] GNUNET_ALIGN;
+ struct GNUNET_SERVER_NotificationContext **uc;
struct GNUNET_SERVER_NotificationContext *nc;
char *addrp;
@@ -108,13 +109,14 @@ notify_client (struct GNUNET_SERVER_Client *client,
}
else
{
- nc = *GNUNET_SERVER_client_get_user_context (client,
+ uc = GNUNET_SERVER_client_get_user_context (client,
struct GNUNET_SERVER_NotificationContext *);
- if (NULL == nc)
+ if (NULL == uc)
{
GNUNET_break (0);
return;
}
+ nc = *uc;
GNUNET_SERVER_notification_context_unicast (nc,
client,
&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,
struct ReservationResultMessage result;
int32_t amount;
struct GNUNET_TIME_Relative res_delay;
+ struct GNUNET_SERVER_NotificationContext **uc;
struct GNUNET_SERVER_NotificationContext *nc;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Received RESERVATION_REQUEST message\n");
- nc = *GNUNET_SERVER_client_get_user_context (client,
- struct GNUNET_SERVER_NotificationContext *);
- if (NULL == nc)
+ uc = GNUNET_SERVER_client_get_user_context (client,
+ struct GNUNET_SERVER_NotificationContext *);
+ if (NULL == uc)
{
GNUNET_break (0);
return;
}
+ nc = *uc;
amount = (int32_t) ntohl (msg->amount);
res_delay = reservations_reserve (&msg->peer, amount);
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,
unsigned int na;
uint32_t min_bw = ntohl (GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT.value__);
- GNUNET_assert (net->active_addresses + extra >= 0);
+ GNUNET_assert (((int)net->active_addresses) + extra >= 0);
na = net->active_addresses + extra;
if (0 == na)
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,
ve->address->address,
ve->address->address_length);
papi = GST_plugins_find (ve->address->transport_name);
+ GNUNET_assert (NULL != papi);
session = papi->get_session (papi->cls,
ve->address);
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,
_("Monitor disconnected from transport service. Reconnecting.\n"));
return;
}
-
- /* done */
- vic = NULL;
- if (NULL != end)
- GNUNET_SCHEDULER_cancel (end);
- end = GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
- return;
- }
- if (NULL == address)
- {
- /* invalid response */
vic = NULL;
if (NULL != end)
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,
plugin->cur_connections++;
if (plugin->cur_connections == plugin->max_connections)
{
- GNUNET_STATISTICS_update (session->plugin->env->stats,
+ GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# TCP service suspended"),
1,
GNUNET_NO);
@@ -2330,7 +2330,7 @@ handle_tcp_welcome (void *cls,
{
GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
_("TCP connection limit reached, suspending server\n"));
- GNUNET_STATISTICS_update (session->plugin->env->stats,
+ GNUNET_STATISTICS_update (plugin->env->stats,
gettext_noop ("# TCP service suspended"),
1,
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)
if (NULL == plugin->unix_sock.desc)
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "socket");
+ GNUNET_free (un);
return GNUNET_SYSERR;
}
if ('\0' != un->sun_path[0])