diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-07-02 16:02:28 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-07-02 16:02:28 +0000 |
commit | 29cf3c9a615e5af2192a10055988434bc5abbe41 (patch) | |
tree | 2d76fdd9b819124ad3d19e4f1b02cc8dce4a95d6 /src/dht | |
parent | 4864cd9ec24e9c45c64b7e3624eb3c65ac8f171f (diff) | |
download | gnunet-29cf3c9a615e5af2192a10055988434bc5abbe41.tar.gz gnunet-29cf3c9a615e5af2192a10055988434bc5abbe41.zip |
codesonar fixes, hopefully doesn't break anything
Diffstat (limited to 'src/dht')
-rw-r--r-- | src/dht/dht_api.c | 13 | ||||
-rw-r--r-- | src/dht/gnunet-service-dht.c | 13 |
2 files changed, 13 insertions, 13 deletions
diff --git a/src/dht/dht_api.c b/src/dht/dht_api.c index 7095eeb6d..a6fefd59a 100644 --- a/src/dht/dht_api.c +++ b/src/dht/dht_api.c | |||
@@ -348,12 +348,11 @@ finish (struct GNUNET_DHT_Handle *handle, int code) | |||
348 | { | 348 | { |
349 | struct PendingMessage *pos = handle->current; | 349 | struct PendingMessage *pos = handle->current; |
350 | GNUNET_HashCode uid_hash; | 350 | GNUNET_HashCode uid_hash; |
351 | hash_from_uid (pos->unique_id, &uid_hash); | ||
352 | #if DEBUG_DHT_API | 351 | #if DEBUG_DHT_API |
353 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s': Finish called!\n", "DHT API"); | 352 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "`%s': Finish called!\n", "DHT API"); |
354 | #endif | 353 | #endif |
355 | GNUNET_assert (pos != NULL); | 354 | GNUNET_assert (pos != NULL); |
356 | 355 | hash_from_uid (pos->unique_id, &uid_hash); | |
357 | if (pos->cont != NULL) | 356 | if (pos->cont != NULL) |
358 | { | 357 | { |
359 | if (code == GNUNET_SYSERR) | 358 | if (code == GNUNET_SYSERR) |
@@ -792,7 +791,6 @@ find_peer_reply_iterator (void *cls, const struct GNUNET_MessageHeader *reply) | |||
792 | { | 791 | { |
793 | struct GNUNET_DHT_FindPeerHandle *find_peer_handle = cls; | 792 | struct GNUNET_DHT_FindPeerHandle *find_peer_handle = cls; |
794 | struct GNUNET_MessageHeader *hello; | 793 | struct GNUNET_MessageHeader *hello; |
795 | size_t hello_size; | ||
796 | 794 | ||
797 | if (ntohs (reply->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT) | 795 | if (ntohs (reply->type) != GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT) |
798 | { | 796 | { |
@@ -804,7 +802,6 @@ find_peer_reply_iterator (void *cls, const struct GNUNET_MessageHeader *reply) | |||
804 | 802 | ||
805 | GNUNET_assert (ntohs (reply->size) >= | 803 | GNUNET_assert (ntohs (reply->size) >= |
806 | sizeof (struct GNUNET_MessageHeader)); | 804 | sizeof (struct GNUNET_MessageHeader)); |
807 | hello_size = ntohs(reply->size) - sizeof(struct GNUNET_MessageHeader); | ||
808 | hello = (struct GNUNET_MessageHeader *)&reply[1]; | 805 | hello = (struct GNUNET_MessageHeader *)&reply[1]; |
809 | 806 | ||
810 | if (ntohs(hello->type) != GNUNET_MESSAGE_TYPE_HELLO) | 807 | if (ntohs(hello->type) != GNUNET_MESSAGE_TYPE_HELLO) |
@@ -879,10 +876,6 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, | |||
879 | &uid_key, route_handle, | 876 | &uid_key, route_handle, |
880 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); | 877 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_MULTIPLE); |
881 | } | 878 | } |
882 | else | ||
883 | { | ||
884 | route_handle->uid = 0; | ||
885 | } | ||
886 | 879 | ||
887 | #if DEBUG_DHT_API | 880 | #if DEBUG_DHT_API |
888 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 881 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -909,7 +902,7 @@ GNUNET_DHT_route_start (struct GNUNET_DHT_Handle *handle, | |||
909 | handle->current = pending; | 902 | handle->current = pending; |
910 | process_pending_message (handle); | 903 | process_pending_message (handle); |
911 | } | 904 | } |
912 | else if ((handle->current != NULL) && (handle->retransmit_stage == DHT_RETRANSMITTING)) | 905 | else if (handle->retransmit_stage == DHT_RETRANSMITTING) |
913 | { | 906 | { |
914 | handle->retransmit_stage = DHT_RETRANSMITTING_MESSAGE_QUEUED; | 907 | handle->retransmit_stage = DHT_RETRANSMITTING_MESSAGE_QUEUED; |
915 | handle->retransmission_buffer = pending; | 908 | handle->retransmission_buffer = pending; |
@@ -1009,7 +1002,7 @@ GNUNET_DHT_route_stop (struct GNUNET_DHT_RouteHandle *route_handle, | |||
1009 | route_handle->dht_handle->current = pending; | 1002 | route_handle->dht_handle->current = pending; |
1010 | process_pending_message (route_handle->dht_handle); | 1003 | process_pending_message (route_handle->dht_handle); |
1011 | } | 1004 | } |
1012 | else if ((route_handle->dht_handle->current != NULL) && (route_handle->dht_handle->retransmit_stage == DHT_RETRANSMITTING)) | 1005 | else if (route_handle->dht_handle->retransmit_stage == DHT_RETRANSMITTING) |
1013 | { | 1006 | { |
1014 | route_handle->dht_handle->retransmit_stage = DHT_RETRANSMITTING_MESSAGE_QUEUED; | 1007 | route_handle->dht_handle->retransmit_stage = DHT_RETRANSMITTING_MESSAGE_QUEUED; |
1015 | route_handle->dht_handle->retransmission_buffer = pending; | 1008 | route_handle->dht_handle->retransmission_buffer = pending; |
diff --git a/src/dht/gnunet-service-dht.c b/src/dht/gnunet-service-dht.c index e64b9a1ea..a310cc944 100644 --- a/src/dht/gnunet-service-dht.c +++ b/src/dht/gnunet-service-dht.c | |||
@@ -42,7 +42,7 @@ | |||
42 | /** | 42 | /** |
43 | * Handle to the datacache service (for inserting/retrieving data) | 43 | * Handle to the datacache service (for inserting/retrieving data) |
44 | */ | 44 | */ |
45 | struct GNUNET_DATACACHE_Handle *datacache; | 45 | static struct GNUNET_DATACACHE_Handle *datacache; |
46 | 46 | ||
47 | /** | 47 | /** |
48 | * The main scheduler to use for the DHT service | 48 | * The main scheduler to use for the DHT service |
@@ -443,7 +443,12 @@ handle_dht_find_peer (void *cls, | |||
443 | /* Simplistic find_peer functionality, always return our hello */ | 443 | /* Simplistic find_peer functionality, always return our hello */ |
444 | hello_size = ntohs(my_hello->size); | 444 | hello_size = ntohs(my_hello->size); |
445 | tsize = hello_size + sizeof (struct GNUNET_MessageHeader); | 445 | tsize = hello_size + sizeof (struct GNUNET_MessageHeader); |
446 | // check tsize < MAX | 446 | |
447 | if (tsize >= GNUNET_SERVER_MAX_MESSAGE_SIZE) | ||
448 | { | ||
449 | GNUNET_break_op (0); | ||
450 | return; | ||
451 | } | ||
447 | find_peer_result = GNUNET_malloc (tsize); | 452 | find_peer_result = GNUNET_malloc (tsize); |
448 | find_peer_result->type = htons (GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT); | 453 | find_peer_result->type = htons (GNUNET_MESSAGE_TYPE_DHT_FIND_PEER_RESULT); |
449 | find_peer_result->size = htons (tsize); | 454 | find_peer_result->size = htons (tsize); |
@@ -604,7 +609,7 @@ handle_dht_start_message (void *cls, struct GNUNET_SERVER_Client *client, | |||
604 | * @param client the client we received this message from | 609 | * @param client the client we received this message from |
605 | * @param message the actual message received | 610 | * @param message the actual message received |
606 | * | 611 | * |
607 | * TODO: once message are remembered by unique id, add code to | 612 | * TODO: once messages are remembered by unique id, add code to |
608 | * forget them here | 613 | * forget them here |
609 | */ | 614 | */ |
610 | static void | 615 | static void |
@@ -800,6 +805,8 @@ void handle_core_connect (void *cls, | |||
800 | "%s Inserting data %s, type %d into datacache, return value was %d\n", my_short_id, GNUNET_h2s(&peer->hashPubKey), 130, ret); | 805 | "%s Inserting data %s, type %d into datacache, return value was %d\n", my_short_id, GNUNET_h2s(&peer->hashPubKey), 130, ret); |
801 | #endif | 806 | #endif |
802 | } | 807 | } |
808 | else | ||
809 | GNUNET_free(data); | ||
803 | } | 810 | } |
804 | 811 | ||
805 | /** | 812 | /** |