diff options
author | Christian Grothoff <christian@grothoff.org> | 2015-11-07 00:06:26 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2015-11-07 00:06:26 +0000 |
commit | 3fd8c038f6b42cd13f20fa82ce2f130d258366c0 (patch) | |
tree | b3e06f7bffac941da29a4f2539e92b764573a7e8 /src/transport/test_transport_api_monitor_validation.c | |
parent | 49f07dd6fa3717c2035f616f973e4b67ac0b4f40 (diff) | |
download | gnunet-3fd8c038f6b42cd13f20fa82ce2f130d258366c0.tar.gz gnunet-3fd8c038f6b42cd13f20fa82ce2f130d258366c0.zip |
-some code cleanup (indentation, redundant branches, etc.)
Diffstat (limited to 'src/transport/test_transport_api_monitor_validation.c')
-rw-r--r-- | src/transport/test_transport_api_monitor_validation.c | 49 |
1 files changed, 29 insertions, 20 deletions
diff --git a/src/transport/test_transport_api_monitor_validation.c b/src/transport/test_transport_api_monitor_validation.c index 76fa66949..ac7a1805b 100644 --- a/src/transport/test_transport_api_monitor_validation.c +++ b/src/transport/test_transport_api_monitor_validation.c | |||
@@ -229,40 +229,45 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
229 | 229 | ||
230 | 230 | ||
231 | static size_t | 231 | static size_t |
232 | notify_ready (void *cls, size_t size, void *buf) | 232 | notify_ready (void *cls, |
233 | size_t size, | ||
234 | void *buf) | ||
233 | { | 235 | { |
234 | struct PeerContext *p = cls; | 236 | struct PeerContext *p = cls; |
235 | struct GNUNET_MessageHeader *hdr; | 237 | struct GNUNET_MessageHeader *hdr; |
236 | 238 | ||
237 | th = NULL; | 239 | th = NULL; |
238 | 240 | if (NULL == buf) | |
239 | if (buf == NULL) | ||
240 | { | 241 | { |
241 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 242 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
242 | "Timeout occurred while waiting for transmit_ready\n"); | 243 | "Timeout occurred while waiting for transmit_ready\n"); |
243 | if (NULL != die_task) | 244 | if (NULL != die_task) |
244 | GNUNET_SCHEDULER_cancel (die_task); | 245 | GNUNET_SCHEDULER_cancel (die_task); |
245 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL); | 246 | die_task = GNUNET_SCHEDULER_add_now (&end_badly, |
247 | NULL); | ||
246 | ok = 42; | 248 | ok = 42; |
247 | return 0; | 249 | return 0; |
248 | } | 250 | } |
249 | 251 | ||
250 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); | 252 | GNUNET_assert (size >= TEST_MESSAGE_SIZE); |
251 | if (buf != NULL) | 253 | memset (buf, '\0', TEST_MESSAGE_SIZE); |
254 | hdr = buf; | ||
255 | hdr->size = htons (TEST_MESSAGE_SIZE); | ||
256 | hdr->type = htons (TEST_MESSAGE_TYPE); | ||
257 | |||
252 | { | 258 | { |
253 | memset (buf, '\0', TEST_MESSAGE_SIZE); | 259 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); |
254 | hdr = buf; | 260 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
255 | hdr->size = htons (TEST_MESSAGE_SIZE); | 261 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", |
256 | hdr->type = htons (TEST_MESSAGE_TYPE); | 262 | p2->no, |
263 | ps, | ||
264 | ntohs (hdr->type), | ||
265 | ntohs (hdr->size), | ||
266 | p->no, | ||
267 | GNUNET_i2s (&p->id)); | ||
268 | GNUNET_free (ps); | ||
257 | } | 269 | } |
258 | 270 | ||
259 | char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id)); | ||
260 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
261 | "Peer %u (`%4s') sending message with type %u and size %u bytes to peer %u (`%4s')\n", | ||
262 | p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no, | ||
263 | GNUNET_i2s (&p->id)); | ||
264 | GNUNET_free (ps); | ||
265 | |||
266 | return TEST_MESSAGE_SIZE; | 271 | return TEST_MESSAGE_SIZE; |
267 | } | 272 | } |
268 | 273 | ||
@@ -290,9 +295,13 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
290 | static void | 295 | static void |
291 | done () | 296 | done () |
292 | { | 297 | { |
293 | if ((GNUNET_YES == p1_c) && (GNUNET_YES == p2_c) && p1_c_notify && p2_c_notify) | 298 | if ( (GNUNET_YES == p1_c) && |
299 | (GNUNET_YES == p2_c) && | ||
300 | p1_c_notify && | ||
301 | p2_c_notify) | ||
294 | { | 302 | { |
295 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Both peers state to be connected\n"); | 303 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
304 | "Both peers state to be connected\n"); | ||
296 | ok = 0; | 305 | ok = 0; |
297 | end(); | 306 | end(); |
298 | } | 307 | } |
@@ -403,7 +412,7 @@ monitor1_cb (void *cls, | |||
403 | 412 | ||
404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 413 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
405 | "Monitor 1: %s %s %s\n", | 414 | "Monitor 1: %s %s %s\n", |
406 | GNUNET_i2s (&address->peer), | 415 | GNUNET_i2s (&address->peer), |
407 | GNUNET_TRANSPORT_vs2s (state), | 416 | GNUNET_TRANSPORT_vs2s (state), |
408 | GNUNET_STRINGS_absolute_time_to_string(valid_until)); | 417 | GNUNET_STRINGS_absolute_time_to_string(valid_until)); |
409 | if (0 == memcmp (&address->peer, | 418 | if (0 == memcmp (&address->peer, |
@@ -427,7 +436,7 @@ monitor2_cb (void *cls, | |||
427 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
428 | "Monitor 2: %s %s %s\n", | 437 | "Monitor 2: %s %s %s\n", |
429 | GNUNET_i2s (&address->peer), | 438 | GNUNET_i2s (&address->peer), |
430 | GNUNET_TRANSPORT_vs2s(state), | 439 | GNUNET_TRANSPORT_vs2s(state), |
431 | GNUNET_STRINGS_absolute_time_to_string(valid_until)); | 440 | GNUNET_STRINGS_absolute_time_to_string(valid_until)); |
432 | if (0 == memcmp (&address->peer, | 441 | if (0 == memcmp (&address->peer, |
433 | &p1->id, | 442 | &p1->id, |