diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-03-18 11:49:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-03-18 11:49:52 +0000 |
commit | ef4bd8de47b45e808d29a8f5ee3d1c4f15c96353 (patch) | |
tree | b496042c0e2a73378cc4e73beb71299bfd32b350 | |
parent | 3ed1a0a351ef02182504649afcb18d51277e6da5 (diff) |
-fix uninitialized sendto
-rw-r--r-- | src/consensus/consensus.h | 23 | ||||
-rw-r--r-- | src/consensus/consensus_api.c | 11 | ||||
-rw-r--r-- | src/consensus/gnunet-service-consensus.c | 6 |
3 files changed, 19 insertions, 21 deletions
diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h index 8436364b65..2c68849b98 100644 --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -37,9 +37,9 @@ struct GNUNET_CONSENSUS_JoinMessage */ struct GNUNET_MessageHeader header; - struct GNUNET_HashCode session_id; + uint32_t num_peers GNUNET_PACKED; - uint16_t num_peers; + struct GNUNET_HashCode session_id; /* GNUNET_PeerIdentity[num_peers] */ }; @@ -52,15 +52,16 @@ struct GNUNET_CONSENSUS_ConcludeMessage */ struct GNUNET_MessageHeader header; + /** - * Timeout for conclude + * Minimum group size required for a consensus group. */ - struct GNUNET_TIME_RelativeNBO timeout; + uint32_t min_group_size GNUNET_PACKED; /** - * Minimum group size required for a consensus group. + * Timeout for conclude */ - uint32_t min_group_size; + struct GNUNET_TIME_RelativeNBO timeout; }; @@ -71,11 +72,11 @@ struct GNUNET_CONSENSUS_ConcludeDoneMessage */ struct GNUNET_MessageHeader header; - uint32_t group_id; + uint32_t group_id GNUNET_PACKED; - uint32_t num_elements; + uint32_t num_elements GNUNET_PACKED; - uint16_t num_peers; + uint32_t num_peers GNUNET_PACKED; /** PeerIdentity[num_peers] */ }; @@ -97,7 +98,7 @@ struct GNUNET_CONSENSUS_ElementMessage /** * Type: GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_NEW_ELEMENT */ - uint16_t element_type; + uint16_t element_type GNUNET_PACKED; /* FIXME: alignment? */ /* rest: element data */ }; @@ -112,7 +113,7 @@ struct GNUNET_CONSENSUS_AckMessage /** * Do we want to keep and propagate the element? */ - uint8_t keep; + uint8_t keep; /* FIXME: alignment!? */ /* FIXME: add message hash? */ }; diff --git a/src/consensus/consensus_api.c b/src/consensus/consensus_api.c index 450d7b02c2..19bf81c862 100644 --- a/src/consensus/consensus_api.c +++ b/src/consensus/consensus_api.c @@ -366,14 +366,11 @@ transmit_join (void *cls, size_t size, void *buf) msg->header.type = htons (GNUNET_MESSAGE_TYPE_CONSENSUS_CLIENT_JOIN); msg->header.size = htons (msize); msg->session_id = consensus->session_id; - msg->num_peers = htons (consensus->num_peers); - if (0 != msg->num_peers) - memcpy(&msg[1], - consensus->peers, - consensus->num_peers * sizeof (struct GNUNET_PeerIdentity)); - + msg->num_peers = htonl (consensus->num_peers); + memcpy(&msg[1], + consensus->peers, + consensus->num_peers * sizeof (struct GNUNET_PeerIdentity)); send_next (consensus); - GNUNET_CLIENT_receive (consensus->client, &message_handler, consensus, GNUNET_TIME_UNIT_FOREVER_REL); diff --git a/src/consensus/gnunet-service-consensus.c b/src/consensus/gnunet-service-consensus.c index 2f59b86bcb..494271e45f 100644 --- a/src/consensus/gnunet-service-consensus.c +++ b/src/consensus/gnunet-service-consensus.c @@ -1405,15 +1405,15 @@ initialize_session_info (struct ConsensusSession *session) static void initialize_session_peer_list (struct ConsensusSession *session) { - int local_peer_in_list; - int listed_peers; + unsigned int local_peer_in_list; + uint32_t listed_peers; const struct GNUNET_PeerIdentity *msg_peers; unsigned int i; GNUNET_assert (NULL != session->join_msg); /* peers in the join message, may or may not include the local peer */ - listed_peers = ntohs (session->join_msg->num_peers); + listed_peers = ntohl (session->join_msg->num_peers); session->num_peers = listed_peers; |