commit 7cc7bd2a04ad11b29e574bd3196d336d6cd97e08
parent 36e3661bf28bef5ed2a39a9c53e58c2aee98c285
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date: Sun, 24 Aug 2025 11:46:30 +0200
- uncrustify
Diffstat:
9 files changed, 273 insertions(+), 234 deletions(-)
diff --git a/contrib/conf/uncrustify_precommit b/contrib/conf/uncrustify_precommit
@@ -33,7 +33,9 @@ then
echo " Uncrustify your code in your next commit. "
echo " See https://docs.gnunet.org/latest/developers/style.html#coding-style "
echo "================================================================"
- exit 1
+ echo "Example:"
+ echo "$ uncrustify --replace -c uncrustify.cfg ${crustified}"
+ exit $RET
fi
# Make sure we have no stupid spelling error
diff --git a/src/include/gnunet_pils_service.h b/src/include/gnunet_pils_service.h
@@ -121,7 +121,6 @@ GNUNET_PILS_connect (const struct GNUNET_CONFIGURATION_Handle *cfg,
void *cls);
-
/**
* @brief Disconnect from the PILS service
*
@@ -191,9 +190,8 @@ GNUNET_PILS_kem_decaps (struct GNUNET_PILS_Handle *handle,
*/
void
GNUNET_PILS_feed_addresses (struct GNUNET_PILS_Handle *handle,
- const struct GNUNET_HELLO_Builder *addresses_builder);
-
-
+ const struct GNUNET_HELLO_Builder *addresses_builder
+ );
/**
@@ -204,7 +202,7 @@ GNUNET_PILS_feed_addresses (struct GNUNET_PILS_Handle *handle,
*/
void
GNUNET_HELLO_builder_hash_addresses (const struct GNUNET_HELLO_Builder *builder,
- struct GNUNET_HashCode *address_hash);
+ struct GNUNET_HashCode *address_hash);
/**
* Generate the peer id from the addresses hash and the initial secret key.
@@ -235,6 +233,7 @@ GNUNET_PILS_sign_hello (struct GNUNET_PILS_Handle *handle,
struct GNUNET_TIME_Absolute et,
GNUNET_PILS_SignResultCallback cb,
void *cb_cls);
+
/**
* Cancel request
*
diff --git a/src/lib/hello/hello-uri.c b/src/lib/hello/hello-uri.c
@@ -1342,7 +1342,7 @@ GNUNET_HELLO_builder_address_list_cmp (const struct GNUNET_HELLO_Builder *
found = true;
break;
}
- if (!found)
+ if (! found)
return GNUNET_NO;
found = false;
}
diff --git a/src/service/core/gnunet-service-core_kx.c b/src/service/core/gnunet-service-core_kx.c
@@ -2703,6 +2703,7 @@ send_initiator_hello (struct GSC_KeyExchangeInfo *kx)
kx);
}
+
static void
check_rekey (struct GSC_KeyExchangeInfo *kx)
{
@@ -2731,6 +2732,7 @@ check_rekey (struct GSC_KeyExchangeInfo *kx)
}
}
+
/**
* Encrypt and transmit payload
* @param kx key exchange info
diff --git a/src/service/core/test_core_plugin_underlay_dummy.c b/src/service/core/test_core_plugin_underlay_dummy.c
@@ -46,7 +46,8 @@
* @brief Generic logging shortcut
*/
#define LOG(kind, ...) \
- GNUNET_log_from_nocheck (kind, "core-plugin-underlay-dummy", __VA_ARGS__)
+ GNUNET_log_from_nocheck (kind, "core-plugin-underlay-dummy", __VA_ARGS__ \
+ )
struct GNUNET_UNDERLAY_DUMMY_Message
@@ -55,7 +56,7 @@ struct GNUNET_UNDERLAY_DUMMY_Message
// The following will be used for debugging
uint64_t id; // id of the message
uint64_t batch; // first batch of that peer (for this test 0 or 1)
- //uint64_t peer; // number of sending peer (for this test 0 or 1)
+ // uint64_t peer; // number of sending peer (for this test 0 or 1)
};
@@ -111,8 +112,8 @@ struct UnderlayDummyState
struct Channel *channels_head;
struct Channel *channels_tail;
- //struct Channel **channels;
- //uint32_t channels_len;
+ // struct Channel **channels;
+ // uint32_t channels_len;
};
@@ -170,9 +171,9 @@ handle_test (void *cls, const struct GNUNET_UNDERLAY_DUMMY_Message *msg)
struct Channel *channel = cls;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received message (%" PRIu64 ", %" PRIu64 ") - going to call handlers\n",
- GNUNET_ntohll (msg->id),
- GNUNET_ntohll (msg->batch));
+ "Received message (%" PRIu64 ", %" PRIu64 ") - going to call handlers\n",
+ GNUNET_ntohll (msg->id),
+ GNUNET_ntohll (msg->batch));
for (uint32_t i = 0; i < channel->uds->recv_handlers_len; i++)
{
// FIXME: set cls per handler
@@ -187,7 +188,8 @@ handle_test (void *cls, const struct GNUNET_UNDERLAY_DUMMY_Message *msg)
static void
-*notify_connect_cb (
+*
+notify_connect_cb (
void *cls,
uint32_t num_addresses,
const char *addresses[static num_addresses],
@@ -206,7 +208,7 @@ static void
GNUNET_CONTAINER_DLL_insert (uds->channels_head,
uds->channels_tail,
channel);
- //GNUNET_array_append (uds->channels,
+ // GNUNET_array_append (uds->channels,
// uds->channels_len,
// channel);
@@ -222,14 +224,14 @@ static void
}
////if ((uds->num_channels_target == uds->channels_len) &&
- //if ((1 == uds->channels_len) &&
+ // if ((1 == uds->channels_len) &&
// (GNUNET_NO == uds->finished))
- //{
+ // {
// LOG (GNUNET_ERROR_TYPE_DEBUG, "(post connect_cb _async_finish)\n");
// GNUNET_TESTING_async_finish (&uds->ac);
// uds->finished = GNUNET_YES;
- //}
- //LOG (GNUNET_ERROR_TYPE_DEBUG,
+ // }
+ // LOG (GNUNET_ERROR_TYPE_DEBUG,
// "(post connect_cb - %u of 1)\n",
// uds->channels_len);
return channel;
@@ -241,41 +243,41 @@ notify_disconnect_cb (
void *cls,
void *handler_cls)
{
- //struct UnderlayDummyState *uds = cls;
- //struct Channel *channel = handler_cls;
- //uint32_t i_target = 0;
+ // struct UnderlayDummyState *uds = cls;
+ // struct Channel *channel = handler_cls;
+ // uint32_t i_target = 0;
//
- //LOG (GNUNET_ERROR_TYPE_DEBUG, "from notify_disconnect_cb()\n");
- //if (NULL == channel)
- //{
+ // LOG (GNUNET_ERROR_TYPE_DEBUG, "from notify_disconnect_cb()\n");
+ // if (NULL == channel)
+ // {
// LOG (GNUNET_ERROR_TYPE_WARNING,
// "notify_disconnect_cb() was called on a unknown channel\n");
// GNUNET_assert (0);
// return;
- //}
+ // }
///**
// * Remove the closed channel:
// * 1. find the (index of the) closed channel
// * 2. copy all following channel one to the front
// */
- //for (uint32_t i = 0; i < uds->channels_len; i++)
- //{
+ // for (uint32_t i = 0; i < uds->channels_len; i++)
+ // {
// if (channel == uds->channels[i])
// {
// //uds->channels[i] = NULL; // XXX
// i_target = i;
// break;
// }
- //}
+ // }
////for (uint32_t i = i_target; i < (uds->channels_len - 1); i++)
////{
//// GNUNET_memcpy ();
////}
- //GNUNET_memcpy (&uds->channels[i_target],
+ // GNUNET_memcpy (&uds->channels[i_target],
// &uds->channels[i_target+1],
// (uds->channels_len - i_target - 1) * sizeof (struct Channel *));
- //GNUNET_array_grow (uds->channels, uds->channels_len, uds->channels_len-1);
- //GNUNET_free (channel);
+ // GNUNET_array_grow (uds->channels, uds->channels_len, uds->channels_len-1);
+ // GNUNET_free (channel);
}
@@ -284,7 +286,7 @@ address_change_cb (void *cls,
uint32_t num_addresses,
const char *addresses[static num_addresses])
{
- //struct UnderlayDummyState *uds = cls;
+ // struct UnderlayDummyState *uds = cls;
(void) cls;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Our set of addresses changed\n");
@@ -296,15 +298,15 @@ exec_connect_run (void *cls,
struct GNUNET_TESTING_Interpreter *is)
{
struct UnderlayDummyState *uds = cls;
- struct GNUNET_MQ_MessageHandler handlers[] =
- {
- GNUNET_MQ_hd_fixed_size (test, MTYPE, struct GNUNET_UNDERLAY_DUMMY_Message, NULL),
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_hd_fixed_size (test, MTYPE, struct GNUNET_UNDERLAY_DUMMY_Message,
+ NULL),
GNUNET_MQ_handler_end ()
};
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "(%s) Going to connect to underlay dummy\n",
- uds->node_id);
+ "(%s) Going to connect to underlay dummy\n",
+ uds->node_id);
uds->h = GNUNET_CORE_UNDERLAY_DUMMY_connect (NULL, // cfg
handlers,
@@ -333,7 +335,7 @@ GNUNET_CORE_cmd_connect (
const char *label,
enum GNUNET_OS_ProcessStatusType expected_type,
unsigned long int expected_exit_code,
- const char* node_id)
+ const char*node_id)
{
struct UnderlayDummyState *uds;
@@ -345,15 +347,15 @@ GNUNET_CORE_cmd_connect (
uds->connect_cbs =
GNUNET_new_array (uds->connect_cbs_len,
struct UnderlayDummy_ConnectCb);
- //uds->channels = GNUNET_new_array (0, struct Channel *);
+ // uds->channels = GNUNET_new_array (0, struct Channel *);
uds->finished = GNUNET_NO;
return GNUNET_TESTING_command_new_ac (
- uds, // state
- label,
- &exec_connect_run,
- &exec_connect_cleanup,
- &connect_traits,
- &uds->ac);
+ uds, // state
+ label,
+ &exec_connect_run,
+ &exec_connect_cleanup,
+ &connect_traits,
+ &uds->ac);
}
@@ -362,7 +364,7 @@ handle_msg_test (void *cls,
struct Channel *channel,
const struct GNUNET_UNDERLAY_DUMMY_Message *msg)
{
- //struct ChannelCount *channel_count = cls;
+ // struct ChannelCount *channel_count = cls;
struct UnderlayDummyRecvState *udrs = cls;
struct ChannelCount *channel_count;
uint32_t channel_i;
@@ -370,7 +372,8 @@ handle_msg_test (void *cls,
uint64_t num_messages_target;
enum GNUNET_GenericReturnValue ret;
- LOG (GNUNET_ERROR_TYPE_DEBUG, "received test message %" PRIu64 " (%" PRIu64 ")\n",
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "received test message %" PRIu64 " (%" PRIu64
+ ")\n",
GNUNET_ntohll (msg->id),
GNUNET_ntohll (msg->batch));
@@ -401,14 +404,15 @@ handle_msg_test (void *cls,
num_messages_received = channel_count->num_messages_received;
num_messages_target = channel_count->udrs->num_messages_target;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received %" PRIu64 " messages (of %" PRIu64 " on channel %u)\n",
- num_messages_received,
- num_messages_target,
- channel_i);
- if (num_messages_target > num_messages_received) return;
+ "Received %" PRIu64 " messages (of %" PRIu64 " on channel %u)\n",
+ num_messages_received,
+ num_messages_target,
+ channel_i);
+ if (num_messages_target > num_messages_received)
+ return;
if (num_messages_target < num_messages_received)
GNUNET_assert (0);
- //if (num_messages_target == num_messages_received)
+ // if (num_messages_target == num_messages_received)
// GNUNET_TESTING_async_finish (&udrs->ac);
ret = GNUNET_YES;
for (uint32_t i = 0; i < udrs->num_channels; i++)
@@ -417,7 +421,8 @@ handle_msg_test (void *cls,
if (channel_count->num_messages_received != udrs->num_messages_target)
ret = GNUNET_NO;
}
- if (GNUNET_YES == ret) GNUNET_TESTING_async_finish (&udrs->ac);
+ if (GNUNET_YES == ret)
+ GNUNET_TESTING_async_finish (&udrs->ac);
}
@@ -431,9 +436,11 @@ exec_recv_run (void *cls,
if (GNUNET_OK != GNUNET_CORE_get_trait_connect (
// TODO make the "connect" an input to the command
GNUNET_TESTING_interpreter_lookup_command (is, "connect"),
- (const void**) &uds)) {
+ (const void**) &uds))
+ {
GNUNET_assert (0);
- };
+ }
+ ;
// FIXME: set cls per handler
GNUNET_array_append (uds->recv_handlers,
uds->recv_handlers_len,
@@ -463,16 +470,17 @@ GNUNET_CORE_cmd_recv (
udrs = GNUNET_new (struct UnderlayDummyRecvState);
udrs->num_channels = 1; // previously came from an argument to _cmd_recv()
- udrs->channel_count = GNUNET_new_array (udrs->num_channels, struct ChannelCount);
+ udrs->channel_count = GNUNET_new_array (udrs->num_channels, struct
+ ChannelCount);
udrs->num_messages_target = num_messages;
LOG (GNUNET_ERROR_TYPE_DEBUG, "(Setting up _cmd_recv)\n");
return GNUNET_TESTING_command_new_ac (
- udrs, // state
- label,
- &exec_recv_run,
- &exec_recv_cleanup,
- NULL,
- &udrs->ac);
+ udrs, // state
+ label,
+ &exec_recv_run,
+ &exec_recv_cleanup,
+ NULL,
+ &udrs->ac);
}
@@ -486,21 +494,23 @@ exec_send_run (void *cls,
struct GNUNET_UNDERLAY_DUMMY_Message *msg;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "exec_send_run()\n");
+ "exec_send_run()\n");
// TODO make the "connect" label an input to the command
if (GNUNET_OK != GNUNET_CORE_get_trait_connect (
GNUNET_TESTING_interpreter_lookup_command (is, "connect"),
- (const void**) &uds)) {
+ (const void**) &uds))
+ {
GNUNET_assert (0);
- };
+ }
+ ;
- //GNUNET_assert (NULL != uds->channels);
- //LOG (GNUNET_ERROR_TYPE_DEBUG, "uds->channels_len: %u\n", uds->channels_len);
+ // GNUNET_assert (NULL != uds->channels);
+ // LOG (GNUNET_ERROR_TYPE_DEBUG, "uds->channels_len: %u\n", uds->channels_len);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Going to send %" PRIu64 " messages\n",
- udss->num_messages);
+ "Going to send %" PRIu64 " messages\n",
+ udss->num_messages);
/* For now send on all available channels as we don't know at this stage
* which is an usable channel - this should be fine as the unusable channel
* will (probably) be discovered and cleaned up in the process. */
@@ -510,18 +520,20 @@ exec_send_run (void *cls,
{
for (uint64_t i = 0; i < udss->num_messages; i++)
{
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to send message %" PRIu64 " (channel %" PRIu64 ")\n", i, i);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to send message %" PRIu64
+ " (channel %" PRIu64 ")\n", i, i);
env = GNUNET_MQ_msg (msg, MTYPE); // usually we wanted to keep the
// envelopes to potentially cancel the
// message
msg->id = GNUNET_htonll (i);
msg->batch = GNUNET_htonll (i);
GNUNET_MQ_send (c_iter->mq, env);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Sent message %" PRIu64 " (channel %" PRIu64 ")\n", i, i);
+ LOG (GNUNET_ERROR_TYPE_DEBUG, "Sent message %" PRIu64 " (channel %" PRIu64
+ ")\n", i, i);
}
}
- //for (uint32_t i = 0; i < uds->channels_len; i++)
- //{
+ // for (uint32_t i = 0; i < uds->channels_len; i++)
+ // {
// for (uint64_t ii = 0; ii < udss->num_messages; ii++)
// {
// LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to send message %" PRIu64 " (channel %" PRIu32 ")\n", ii, i);
@@ -533,7 +545,7 @@ exec_send_run (void *cls,
// GNUNET_MQ_send (uds->channels[i]->mq, env);
// LOG (GNUNET_ERROR_TYPE_DEBUG, "Sent message %" PRIu64 " (channel %" PRIu32 ")\n", ii, i);
// }
- //}
+ // }
LOG (GNUNET_ERROR_TYPE_DEBUG, "Sent messages\n");
}
@@ -541,7 +553,7 @@ exec_send_run (void *cls,
static void
exec_send_cleanup (void *cls)
{
- //struct UnderlayDummyState *uds = cls;
+ // struct UnderlayDummyState *uds = cls;
(void) cls;
}
@@ -560,11 +572,11 @@ GNUNET_CORE_cmd_send (
udss->num_messages = num_messages;
LOG (GNUNET_ERROR_TYPE_DEBUG, "(Setting up _cmd_send)\n");
return GNUNET_TESTING_command_new (
- udss, // state
- label,
- &exec_send_run,
- &exec_send_cleanup,
- NULL);
+ udss, // state
+ label,
+ &exec_send_run,
+ &exec_send_cleanup,
+ NULL);
}
@@ -573,38 +585,38 @@ GNUNET_TESTING_MAKE_PLUGIN (
underlay_dummy,
/* connect to underlay dummy 'service' (start it)
* and set up basic callbacks */
- GNUNET_CORE_cmd_connect ("connect",
- GNUNET_OS_PROCESS_EXITED,
- 0,
- my_node_id),
- /* Set up receiving of messages -
- * register a callback with the connect cmd that
- * finishes this command after the specified
- * number of messages were received */
- GNUNET_TESTING_cmd_make_unblocking (
- GNUNET_CORE_cmd_recv ("recv",
- GNUNET_OS_PROCESS_EXITED,
- 0,
- NUM_MESSAGES)),
- /* Send specified number of messages */
- GNUNET_TESTING_cmd_make_unblocking (
- GNUNET_CORE_cmd_send ("send",
+ GNUNET_CORE_cmd_connect ("connect",
GNUNET_OS_PROCESS_EXITED,
0,
- NUM_MESSAGES)),
- /* Wait until recv is finished */
- GNUNET_TESTING_cmd_finish ("recv-finished",
- "recv",
- GNUNET_TIME_relative_multiply (
- GNUNET_TIME_UNIT_SECONDS, 60)),
- GNUNET_TESTING_cmd_end ()
-)
+ my_node_id),
+ /* Set up receiving of messages -
+ * register a callback with the connect cmd that
+ * finishes this command after the specified
+ * number of messages were received */
+ GNUNET_TESTING_cmd_make_unblocking (
+ GNUNET_CORE_cmd_recv ("recv",
+ GNUNET_OS_PROCESS_EXITED,
+ 0,
+ NUM_MESSAGES)),
+ /* Send specified number of messages */
+ GNUNET_TESTING_cmd_make_unblocking (
+ GNUNET_CORE_cmd_send ("send",
+ GNUNET_OS_PROCESS_EXITED,
+ 0,
+ NUM_MESSAGES)),
+ /* Wait until recv is finished */
+ GNUNET_TESTING_cmd_finish ("recv-finished",
+ "recv",
+ GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_SECONDS, 60)),
+ GNUNET_TESTING_cmd_end ()
+ )
// testing_core_cmd_connecting_peers.c takes as inspiration
// FIXME: likely not ideally placed here, move to its own file
GNUNET_CORE_SIMPLE_DUMMY_UNDERLAY_TRAITS (
- GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT, GNUNET_CORE)
+ GNUNET_TESTING_MAKE_IMPL_SIMPLE_TRAIT, GNUNET_CORE)
/* end of src/service/core/test_core_plugin_underlay_dummy.c */
diff --git a/src/service/core/test_core_underlay_dummy.c b/src/service/core/test_core_underlay_dummy.c
@@ -82,7 +82,7 @@ struct Connection
/* Context to the 'peer' to which the connection belongs */
struct DummyContext *dc;
- /* counter of replies/highest index */
+ /* counter of replies/highest index */
uint32_t result_replies;
};
@@ -180,13 +180,13 @@ print_connections (struct DummyContext *dc)
uint32_t count = 0;
for (struct Connection *c_iter = dc->conn_head;
- NULL != c_iter;
- c_iter = c_iter->next)
+ NULL != c_iter;
+ c_iter = c_iter->next)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- " %" PRIu32 ": %s\n",
- count,
- c_iter->address);
+ " %" PRIu32 ": %s\n",
+ count,
+ c_iter->address);
count++;
}
}
@@ -206,7 +206,8 @@ print_connections (struct DummyContext *dc)
* @return The returned value overwrites the cls set in the handlers for this
* mq. If NULL, the cls from the original handlers array is used.
*/
-static void *notify_connect_cb (
+static void *
+notify_connect_cb (
void *cls,
uint32_t num_addresses,
const char *addresses[static num_addresses],
@@ -221,18 +222,18 @@ static void *notify_connect_cb (
if (0 == num_addresses)
{
- LOG (GNUNET_ERROR_TYPE_INFO,
- "(%u) Got notified about successful connection to peer with %u address\n",
- dc == &dc0 ? 0 : 1,
- num_addresses);
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "(%u) Got notified about successful connection to peer with %u address\n",
+ dc == &dc0 ? 0 : 1,
+ num_addresses);
}
else
{
- LOG (GNUNET_ERROR_TYPE_INFO,
- "(%u) Got notified about successful connection to peer with %u address: `%s'\n",
- dc == &dc0 ? 0 : 1,
- num_addresses,
- addresses[num_addresses - 1]);
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "(%u) Got notified about successful connection to peer with %u address: `%s'\n",
+ dc == &dc0 ? 0 : 1,
+ num_addresses,
+ addresses[num_addresses - 1]);
}
/* Note test result */
if (GNUNET_NO == result_connect_cb_0)
@@ -240,14 +241,14 @@ static void *notify_connect_cb (
result_connect_cb_0 = GNUNET_YES;
}
else if (GNUNET_YES == result_connect_cb_0 &&
- GNUNET_NO == result_connect_cb_1)
+ GNUNET_NO == result_connect_cb_1)
{
result_connect_cb_1 = GNUNET_YES;
}
/* If we knew whether this connection is the one that's used to send/recv, we
* could close it right now: */
- //if ()
- //{
+ // if ()
+ // {
// /* Don't accept further connections */
// struct DestroyMQTask *destroy_mq_task;
// destroy_mq_task = GNUNET_new (struct DestroyMQTask);
@@ -259,7 +260,7 @@ static void *notify_connect_cb (
// dc->destroy_mq_task_tail,
// destroy_mq_task);
// return NULL;
- //}
+ // }
connection = GNUNET_new (struct Connection);
connection->mq = mq;
connection->address = GNUNET_strdup (addresses[0]);
@@ -271,17 +272,17 @@ static void *notify_connect_cb (
connection);
dc->num_open_connections++;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "(%u) Current connections:\n",
- dc == &dc0 ? 0 : 1);
- print_connections(dc);
+ "(%u) Current connections:\n",
+ dc == &dc0 ? 0 : 1);
+ print_connections (dc);
// FIXME get it in sync: number of messages sent (per connection) vs. number
// of messages received (per peer)
if (NUMBER_SENDING_PEERS == 1 &&
&dc1 == dc)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "(%u) Not going to send messages - only one peer is supposed to\n",
- dc == &dc0 ? 0 : 1);
+ "(%u) Not going to send messages - only one peer is supposed to\n",
+ dc == &dc0 ? 0 : 1);
return connection;
}
for (uint64_t i = 0; i < NUMBER_MESSAGES; i++)
@@ -294,16 +295,17 @@ static void *notify_connect_cb (
msg->batch = GNUNET_htonll (dc->num_open_connections - 1);
msg->peer = GNUNET_htonll (&dc0 == dc ? 0 : 1);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "(%u) Going to send message %" PRIu64 " through message queue %" PRIu32 "\n",
- &dc0 == dc ? 0 : 1,
- i,
- dc->num_open_connections - 1);
+ "(%u) Going to send message %" PRIu64 " through message queue %" PRIu32
+ "\n",
+ &dc0 == dc ? 0 : 1,
+ i,
+ dc->num_open_connections - 1);
GNUNET_MQ_send (mq, env);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "(%u) Sent message %" PRIu64 " through message queue %" PRIu32 "\n",
- &dc0 == dc ? 0 : 1,
- i,
- dc->num_open_connections - 1);
+ "(%u) Sent message %" PRIu64 " through message queue %" PRIu32 "\n",
+ &dc0 == dc ? 0 : 1,
+ i,
+ dc->num_open_connections - 1);
}
return connection;
@@ -319,12 +321,12 @@ notify_disconnect_cb (
struct DummyContext *dc = cls;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "(%u) Connection disconnected.\n",
- &dc0 == dc ? 0 : 1);
+ "(%u) Connection disconnected.\n",
+ &dc0 == dc ? 0 : 1);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "(%u) Adding result replies: %" PRIu32 ".\n",
- &dc0 == dc ? 0 : 1,
- connection->result_replies);
+ "(%u) Adding result replies: %" PRIu32 ".\n",
+ &dc0 == dc ? 0 : 1,
+ connection->result_replies);
if (&dc0 == dc)
result_replies_0 = result_replies_0 + connection->result_replies;
else if (&dc1 == dc)
@@ -337,15 +339,16 @@ notify_disconnect_cb (
GNUNET_free (connection->address);
GNUNET_free (connection);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "(%u) Connections:\n",
- &dc0 == dc ? 0 : 1);
+ "(%u) Connections:\n",
+ &dc0 == dc ? 0 : 1);
print_connections (dc);
// TODO cancel test
if ((NUMBER_MESSAGES * NUMBER_CONNECTIONS == result_replies_0) &&
(NUMBER_MESSAGES * NUMBER_CONNECTIONS == result_replies_1))
{
LOG (GNUNET_ERROR_TYPE_DEBUG, "Test finished early, shutting down\n");
- if (NULL != timeout_task) GNUNET_SCHEDULER_cancel (timeout_task);
+ if (NULL != timeout_task)
+ GNUNET_SCHEDULER_cancel (timeout_task);
timeout_task = NULL;
GNUNET_SCHEDULER_shutdown ();
}
@@ -370,27 +373,29 @@ address_change_cb (void *cls,
result_address_callback = GNUNET_YES;
LOG (GNUNET_ERROR_TYPE_INFO,
- "(%u) Got informed of address change\n",
- dc == &dc0 ? 0 : 1);
+ "(%u) Got informed of address change\n",
+ dc == &dc0 ? 0 : 1);
LOG (GNUNET_ERROR_TYPE_INFO,
- "%" PRIu32 " new addresses:\n",
- num_addresses);
+ "%" PRIu32 " new addresses:\n",
+ num_addresses);
for (uint32_t i = 0; i < num_addresses; i++)
{
LOG (GNUNET_ERROR_TYPE_INFO,
- " %" PRIu32 ": %s\n",
- i,
- addresses[i]);
+ " %" PRIu32 ": %s\n",
+ i,
+ addresses[i]);
}
if (&dc0 == dc)
{
/* We cannot know which peer has which socket - try both */
GNUNET_CORE_UNDERLAY_DUMMY_connect_to_peer (dc->h,
- SOCK_NAME_BASE "0" SOCK_EXTENSION,
+ SOCK_NAME_BASE "0"
+ SOCK_EXTENSION,
GNUNET_MQ_PRIO_BEST_EFFORT,
GNUNET_BANDWIDTH_VALUE_MAX);
GNUNET_CORE_UNDERLAY_DUMMY_connect_to_peer (dc->h,
- SOCK_NAME_BASE "1" SOCK_EXTENSION,
+ SOCK_NAME_BASE "1"
+ SOCK_EXTENSION,
GNUNET_MQ_PRIO_BEST_EFFORT,
GNUNET_BANDWIDTH_VALUE_MAX);
}
@@ -399,11 +404,13 @@ address_change_cb (void *cls,
{
/* We cannot know which peer has which socket - try both */
GNUNET_CORE_UNDERLAY_DUMMY_connect_to_peer (dc->h,
- SOCK_NAME_BASE "0" SOCK_EXTENSION,
+ SOCK_NAME_BASE "0"
+ SOCK_EXTENSION,
GNUNET_MQ_PRIO_BEST_EFFORT,
GNUNET_BANDWIDTH_VALUE_MAX);
GNUNET_CORE_UNDERLAY_DUMMY_connect_to_peer (dc->h,
- SOCK_NAME_BASE "1" SOCK_EXTENSION,
+ SOCK_NAME_BASE "1"
+ SOCK_EXTENSION,
GNUNET_MQ_PRIO_BEST_EFFORT,
GNUNET_BANDWIDTH_VALUE_MAX);
}
@@ -457,7 +464,7 @@ do_shutdown (void *cls)
GNUNET_SCHEDULER_cancel (dmt_iter->destroy_mq_task);
do_destroy_mq (dmt_iter);
}
- LOG(GNUNET_ERROR_TYPE_INFO, "Disconnected from underlay dummy\n");
+ LOG (GNUNET_ERROR_TYPE_INFO, "Disconnected from underlay dummy\n");
LOG (GNUNET_ERROR_TYPE_DEBUG, "counted %u replies for peer 0\n",
result_replies_0);
LOG (GNUNET_ERROR_TYPE_DEBUG, "counted %u replies for peer 1\n",
@@ -475,7 +482,7 @@ do_timeout (void *cls)
{
timeout_task = NULL;
- LOG(GNUNET_ERROR_TYPE_INFO, "Disconnecting from underlay dummy\n");
+ LOG (GNUNET_ERROR_TYPE_INFO, "Disconnecting from underlay dummy\n");
GNUNET_SCHEDULER_shutdown ();
}
@@ -496,7 +503,7 @@ handle_test (void *cls, const struct GNUNET_UNDERLAY_DUMMY_Message *msg)
GNUNET_assert (NULL != cls);
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "received test message %" PRIu64 " (%" PRIu64 ", %" PRIu64 ")\n",
+ "received test message %" PRIu64 " (%" PRIu64 ", %" PRIu64 ")\n",
GNUNET_ntohll (msg->id),
GNUNET_ntohll (msg->batch),
GNUNET_ntohll (msg->peer));
@@ -529,32 +536,33 @@ handle_test (void *cls, const struct GNUNET_UNDERLAY_DUMMY_Message *msg)
*
* @param cls Closure - unused
*/
-static void run_test (void *cls)
+static void
+run_test (void *cls)
{
- struct GNUNET_MQ_MessageHandler handlers[] =
- {
- GNUNET_MQ_hd_fixed_size (test, MTYPE, struct GNUNET_UNDERLAY_DUMMY_Message, NULL),
+ struct GNUNET_MQ_MessageHandler handlers[] = {
+ GNUNET_MQ_hd_fixed_size (test, MTYPE, struct GNUNET_UNDERLAY_DUMMY_Message,
+ NULL),
GNUNET_MQ_handler_end ()
};
GNUNET_log_setup ("test-core-underlay-dummy", "DEBUG", NULL);
dc0.num_open_connections = 0;
dc1.num_open_connections = 0;
- LOG(GNUNET_ERROR_TYPE_INFO, "Connecting to underlay dummy\n");
- dc0.h = GNUNET_CORE_UNDERLAY_DUMMY_connect (NULL, //cfg
+ LOG (GNUNET_ERROR_TYPE_INFO, "Connecting to underlay dummy\n");
+ dc0.h = GNUNET_CORE_UNDERLAY_DUMMY_connect (NULL, // cfg
handlers,
&dc0, // cls
notify_connect_cb,
notify_disconnect_cb, // nd
address_change_cb);
- LOG(GNUNET_ERROR_TYPE_INFO, "(0) Connected to underlay dummy\n");
- dc1.h = GNUNET_CORE_UNDERLAY_DUMMY_connect (NULL, //cfg
+ LOG (GNUNET_ERROR_TYPE_INFO, "(0) Connected to underlay dummy\n");
+ dc1.h = GNUNET_CORE_UNDERLAY_DUMMY_connect (NULL, // cfg
handlers,
&dc1, // cls
notify_connect_cb,
notify_disconnect_cb, // nd
address_change_cb);
- LOG(GNUNET_ERROR_TYPE_INFO, "(1) Connected to underlay dummy 2\n");
+ LOG (GNUNET_ERROR_TYPE_INFO, "(1) Connected to underlay dummy 2\n");
GNUNET_SCHEDULER_add_shutdown (do_shutdown, NULL);
timeout_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
do_timeout,
@@ -570,33 +578,37 @@ static void run_test (void *cls)
*
* @return Indicate success or failure
*/
-int main (void)
+int
+main (void)
{
GNUNET_SCHEDULER_run (run_test, NULL);
- if (GNUNET_YES != result_address_callback) return -1;
- if (GNUNET_YES != result_connect_cb_0) return -1;
- if (GNUNET_YES != result_connect_cb_1) return -1;
+ if (GNUNET_YES != result_address_callback)
+ return -1;
+ if (GNUNET_YES != result_connect_cb_0)
+ return -1;
+ if (GNUNET_YES != result_connect_cb_1)
+ return -1;
if ((NUMBER_SENDING_PEERS > 1) &&
(NUMBER_MESSAGES * NUMBER_CONNECTIONS != result_replies_0))
{
- LOG(GNUNET_ERROR_TYPE_ERROR,
- "Peer 0 received %u of %u messages\n",
- result_replies_0,
- NUMBER_MESSAGES * NUMBER_CONNECTIONS);
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Peer 0 received %u of %u messages\n",
+ result_replies_0,
+ NUMBER_MESSAGES * NUMBER_CONNECTIONS);
// XXX:
- LOG(GNUNET_ERROR_TYPE_ERROR,
- "Peer 1 received %u of %u messages\n",
- result_replies_1,
- NUMBER_MESSAGES * NUMBER_CONNECTIONS);
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Peer 1 received %u of %u messages\n",
+ result_replies_1,
+ NUMBER_MESSAGES * NUMBER_CONNECTIONS);
return -1;
}
if (NUMBER_MESSAGES * NUMBER_CONNECTIONS != result_replies_1)
{
- LOG(GNUNET_ERROR_TYPE_ERROR,
- "Peer 1 received %u of %u messages\n",
- result_replies_1,
- NUMBER_MESSAGES * NUMBER_CONNECTIONS);
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ "Peer 1 received %u of %u messages\n",
+ result_replies_1,
+ NUMBER_MESSAGES * NUMBER_CONNECTIONS);
return -1;
}
return 0;
diff --git a/src/service/core/testing_core_cmd_recv.c b/src/service/core/testing_core_cmd_recv.c
@@ -35,7 +35,7 @@
* @brief Generic logging shortcut
*/
#define LOG(kind, ...) \
- GNUNET_log_from (kind, "testing-core-recv", __VA_ARGS__)
+ GNUNET_log_from (kind, "testing-core-recv", __VA_ARGS__)
struct RecvState;
@@ -87,24 +87,24 @@ remove_recv_handler (struct GNUNET_TESTING_CORE_ConnectState *connect_state)
// FIXME this is the dirty solution. The attempt below did for whatever
// reason not work.
connect_state->recv_handlers[i] = NULL;
- //LOG (GNUNET_ERROR_TYPE_DEBUG,
+ // LOG (GNUNET_ERROR_TYPE_DEBUG,
// "recv handlers[0]: %p, handle_msg_test: %p, (%lu)\n",
// connect_state->recv_handlers[0],
// &handle_msg_test,
// sizeof (&handle_msg_test));
- //LOG (GNUNET_ERROR_TYPE_DEBUG,
+ // LOG (GNUNET_ERROR_TYPE_DEBUG,
// "recv handlers: %p, %" PRIu64 "\n",
// connect_state->recv_handlers,
// connect_state->recv_handlers_len);
- //GNUNET_memcpy (&connect_state->recv_handlers[i],
+ // GNUNET_memcpy (&connect_state->recv_handlers[i],
// &connect_state->recv_handlers[i+1],
// (connect_state->connect_cbs_len - i - 1) *
// sizeof (handle_msg_test));
- //LOG (GNUNET_ERROR_TYPE_DEBUG,
+ // LOG (GNUNET_ERROR_TYPE_DEBUG,
// "recv handlers: %p, %" PRIu64 "\n",
// connect_state->recv_handlers,
// connect_state->recv_handlers_len);
- //GNUNET_array_grow (connect_state->recv_handlers,
+ // GNUNET_array_grow (connect_state->recv_handlers,
// connect_state->recv_handlers_len,
// connect_state->recv_handlers_len - 1);
}
@@ -117,7 +117,7 @@ handle_msg_test (void *cls,
struct GNUNET_TESTING_CORE_Channel *channel,
const struct GNUNET_TESTING_CORE_Message *msg)
{
- //struct ChannelCount *channel_count = cls;
+ // struct ChannelCount *channel_count = cls;
struct RecvState *rs = cls;
struct ChannelCount *channel_count;
uint32_t channel_i;
@@ -125,7 +125,8 @@ handle_msg_test (void *cls,
uint64_t num_messages_target;
enum GNUNET_GenericReturnValue ret;
- LOG (GNUNET_ERROR_TYPE_INFO, "received test message %" PRIu64 " (%" PRIu64 ") %s\n",
+ LOG (GNUNET_ERROR_TYPE_INFO, "received test message %" PRIu64 " (%" PRIu64
+ ") %s\n",
GNUNET_ntohll (msg->id),
GNUNET_ntohll (msg->batch),
msg->node_id);
@@ -174,13 +175,16 @@ handle_msg_test (void *cls,
num_messages_received = channel_count->num_messages_received;
num_messages_target = channel_count->rs->num_messages_target;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Received %" PRIu64 " messages (of %" PRIu64 " on channel %" PRIu32 ")\n",
- num_messages_received,
- num_messages_target,
- channel_i);
- if (num_messages_target > num_messages_received) return;
- if (num_messages_target < num_messages_received) GNUNET_assert (0);
- //if (num_messages_target == num_messages_received)
+ "Received %" PRIu64 " messages (of %" PRIu64 " on channel %" PRIu32
+ ")\n",
+ num_messages_received,
+ num_messages_target,
+ channel_i);
+ if (num_messages_target > num_messages_received)
+ return;
+ if (num_messages_target < num_messages_received)
+ GNUNET_assert (0);
+ // if (num_messages_target == num_messages_received)
// GNUNET_TESTING_async_finish (&rs->ac);
ret = GNUNET_YES;
for (uint32_t i = 0; i < rs->num_channels; i++)
@@ -191,7 +195,8 @@ handle_msg_test (void *cls,
}
if (GNUNET_YES == ret)
{
- LOG (GNUNET_ERROR_TYPE_INFO, "Received all expected messages on all channels\n");
+ LOG (GNUNET_ERROR_TYPE_INFO,
+ "Received all expected messages on all channels\n");
remove_recv_handler (rs->connect_state);
// TODO do we want to keep track of this task?
/* If we finish this task, this ARM will shut down this peer, taking with
@@ -223,27 +228,30 @@ exec_recv_run (void *cls,
if (GNUNET_OK != GNUNET_CORE_TESTING_get_trait_connect (
// TODO make the "connect" an input to the command
GNUNET_TESTING_interpreter_lookup_command (is, "connect"),
- &connect_state)) {
+ &connect_state))
+ {
GNUNET_assert (0);
- };
+ }
+ ;
rs->connect_state = connect_state;
// FIXME: set cls per handler
GNUNET_array_append (connect_state->recv_handlers,
connect_state->recv_handlers_len,
&handle_msg_test);
// FIXME is the following ok?
- ((struct GNUNET_TESTING_CORE_ConnectState *)connect_state)->recv_handlers_cls = rs;
+ ((struct GNUNET_TESTING_CORE_ConnectState *) connect_state)->recv_handlers_cls
+ = rs;
}
static void
exec_recv_cleanup (void *cls)
{
- //struct RecvState *rs = cls;
+ // struct RecvState *rs = cls;
// TODO
- //GNUNET_free (rs->channel_count);
- //GNUNET_free (rs);
+ // GNUNET_free (rs->channel_count);
+ // GNUNET_free (rs);
}
@@ -261,12 +269,12 @@ GNUNET_TESTING_CORE_cmd_recv (
rs->num_messages_target = num_messages;
LOG (GNUNET_ERROR_TYPE_DEBUG, "(Setting up _cmd_recv)\n");
return GNUNET_TESTING_command_new_ac (
- rs, // state
- label,
- &exec_recv_run,
- &exec_recv_cleanup,
- NULL, // traits
- &rs->ac); // FIXME
+ rs, // state
+ label,
+ &exec_recv_run,
+ &exec_recv_cleanup,
+ NULL, // traits
+ &rs->ac); // FIXME
}
diff --git a/src/service/core/testing_core_cmd_send.c b/src/service/core/testing_core_cmd_send.c
@@ -35,7 +35,7 @@
* @brief Generic logging shortcut
*/
#define LOG(kind, ...) \
- GNUNET_log_from (kind, "testing-core-send", __VA_ARGS__)
+ GNUNET_log_from (kind, "testing-core-send", __VA_ARGS__)
static void *
@@ -67,14 +67,14 @@ cleanup_callbacks (struct SendState *send_state)
/* remove the callback */
GNUNET_memcpy (connect_cb_iter,
connect_cb_iter + 1,
- (connect_state->connect_cbs_len - i - 1) *
- sizeof (struct GNUNET_TESTING_CORE_ConnectCb));
+ (connect_state->connect_cbs_len - i - 1)
+ * sizeof (struct GNUNET_TESTING_CORE_ConnectCb));
GNUNET_array_grow (connect_state->connect_cbs,
connect_state->connect_cbs_len,
connect_state->connect_cbs_len - 1);
- //FIXME the following seems to be a double free, but I currently don't
- //know where the other free should be
- //GNUNET_free (connect_cb_iter);
+ // FIXME the following seems to be a double free, but I currently don't
+ // know where the other free should be
+ // GNUNET_free (connect_cb_iter);
}
}
}
@@ -91,8 +91,8 @@ send_messages (struct SendState *send_state)
uint64_t channel_index = 0;
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Going to send %" PRIu64 " messages\n",
- send_state->num_messages);
+ "Going to send %" PRIu64 " messages\n",
+ send_state->num_messages);
GNUNET_assert (NULL != connect_state->channels_head);
/* For now send on all available channels as we don't know at this stage
* which is an usable channel - this should be fine as the unusable channel
@@ -104,7 +104,8 @@ send_messages (struct SendState *send_state)
for (uint64_t i = 0; i < send_state->num_messages; i++)
{
LOG (GNUNET_ERROR_TYPE_DEBUG,
- "Going to send message (type %u) %" PRIu64 ", %s (channel %" PRIu64 ") to %s\n",
+ "Going to send message (type %u) %" PRIu64 ", %s (channel %" PRIu64
+ ") to %s\n",
MTYPE,
i,
connect_state->node_id,
@@ -156,9 +157,11 @@ exec_send_run (void *cls,
// TODO make the "connect" label an input to the command
if (GNUNET_OK != GNUNET_CORE_TESTING_get_trait_connect (
GNUNET_TESTING_interpreter_lookup_command (is, "connect"),
- &connect_state)) {
+ &connect_state))
+ {
GNUNET_assert (0);
- };
+ }
+ ;
send_state->connect_state = connect_state;
LOG (GNUNET_ERROR_TYPE_DEBUG, "Going to (register to) send messages\n");
@@ -175,7 +178,8 @@ exec_send_run (void *cls,
// FIXME is the following ok?
struct GNUNET_TESTING_CORE_ConnectCb *connect_cb_struct =
GNUNET_new (struct GNUNET_TESTING_CORE_ConnectCb);
- LOG (GNUNET_ERROR_TYPE_DEBUG, "Registering our connect callback with the connect callbacks\n");
+ LOG (GNUNET_ERROR_TYPE_DEBUG,
+ "Registering our connect callback with the connect callbacks\n");
connect_cb_struct->callback = connect_cb;
connect_cb_struct->cls = send_state;
GNUNET_array_append (connect_state->connect_cbs,
@@ -208,11 +212,11 @@ GNUNET_TESTING_CORE_cmd_send (
send_state->await_new_connection = await_new_connection;
LOG (GNUNET_ERROR_TYPE_DEBUG, "(Setting up _cmd_send)\n");
return GNUNET_TESTING_command_new (
- send_state, // state
- label,
- &exec_send_run,
- &exec_send_cleanup,
- NULL);
+ send_state, // state
+ label,
+ &exec_send_run,
+ &exec_send_cleanup,
+ NULL);
}
diff --git a/src/service/pils/pils_api.c b/src/service/pils/pils_api.c
@@ -229,7 +229,7 @@ handle_sign_result (void *cls, const struct SignResultMessage *msg)
{
LOG (GNUNET_ERROR_TYPE_WARNING,
"Didn't find the operation corresponding to id %u\n",
- ntohl(msg->rid));
+ ntohl (msg->rid));
return;
}
if (NULL != op->sign_cb)