gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r36647 - gnunet/src/transport


From: gnunet
Subject: [GNUnet-SVN] r36647 - gnunet/src/transport
Date: Sat, 7 Nov 2015 01:06:27 +0100

Author: grothoff
Date: 2015-11-07 01:06:26 +0100 (Sat, 07 Nov 2015)
New Revision: 36647

Modified:
   gnunet/src/transport/plugin_transport_http_common.c
   gnunet/src/transport/test_quota_compliance.c
   gnunet/src/transport/test_transport_api_bidirectional_connect.c
   gnunet/src/transport/test_transport_api_blacklisting.c
   gnunet/src/transport/test_transport_api_manipulation_cfg.c
   gnunet/src/transport/test_transport_api_manipulation_recv_tcp.c
   gnunet/src/transport/test_transport_api_manipulation_send_tcp.c
   gnunet/src/transport/test_transport_api_monitor_peers.c
   gnunet/src/transport/test_transport_api_monitor_validation.c
   gnunet/src/transport/test_transport_api_restart_1peer.c
Log:
-some code cleanup (indentation, redundant branches, etc.)

Modified: gnunet/src/transport/plugin_transport_http_common.c
===================================================================
--- gnunet/src/transport/plugin_transport_http_common.c 2015-11-06 23:46:00 UTC 
(rev 36646)
+++ gnunet/src/transport/plugin_transport_http_common.c 2015-11-07 00:06:26 UTC 
(rev 36647)
@@ -567,7 +567,7 @@
     GNUNET_break(0);
     return NULL;
   }
-  if (0 >= addrlen)
+  if (0 == addrlen)
   {
     GNUNET_break(0);
     return NULL;
@@ -611,14 +611,14 @@
 
   GNUNET_assert(NULL != plugin);
   if (NULL == addr)
-    return NULL ;
+    return NULL;
   if (0 == addrlen)
-    return NULL ;
+    return NULL;
   if (addrlen != http_common_address_get_size (address))
-    return NULL ;
+    return NULL;
   addr_str = (char *) &address[1];
   if (addr_str[ntohl (address->urlen) - 1] != '\0')
-    return NULL ;
+    return NULL;
   GNUNET_asprintf (&res, "%s.%u.%s", plugin, ntohl (address->options),
       &address[1]);
   if (strlen (res) + 1 < 500)
@@ -629,7 +629,7 @@
   }
   GNUNET_break(0);
   GNUNET_free(res);
-  return NULL ;
+  return NULL;
 }
 
 /**
@@ -772,7 +772,7 @@
     GNUNET_break (0);
     return NULL;
   }
-  if (0 >= addrlen)
+  if (0 == addrlen)
   {
     GNUNET_break (0);
     return NULL;
@@ -868,7 +868,7 @@
 
   if (NULL == a1)
     return GNUNET_SYSERR;
-  if (0 >= addrlen1)
+  if (0 == addrlen1)
     return GNUNET_SYSERR;
   if (a1[addrlen1 - 1] != '\0')
     return GNUNET_SYSERR;
@@ -875,7 +875,7 @@
 
   if (NULL == a2)
     return GNUNET_SYSERR;
-  if (0 >= addrlen2)
+  if (0 == addrlen2)
     return GNUNET_SYSERR;
   if (a2[addrlen2 - 1] != '\0')
     return GNUNET_SYSERR;

Modified: gnunet/src/transport/test_quota_compliance.c
===================================================================
--- gnunet/src/transport/test_quota_compliance.c        2015-11-06 23:46:00 UTC 
(rev 36646)
+++ gnunet/src/transport/test_quota_compliance.c        2015-11-07 00:06:26 UTC 
(rev 36647)
@@ -209,23 +209,29 @@
 
 
 static void
-notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
+notify_receive (void *cls,
+                const struct GNUNET_PeerIdentity *peer,
                 const struct GNUNET_MessageHeader *message)
 {
   const struct TestMessage *hdr;
+  struct PeerContext *p = cls;
 
   hdr = (const struct TestMessage *) message;
   if (MTYPE != ntohs (message->type))
     return;
 
-  struct PeerContext *p = cls;
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+  {
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Peer %u (`%s') got message %u of size %u from peer (`%s')\n",
-              p->no, ps, ntohl (hdr->num), ntohs (message->size),
-              GNUNET_i2s (peer));
-  GNUNET_free (ps);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Peer %u (`%s') got message %u of size %u from peer (`%s')\n",
+                p->no,
+                ps,
+                ntohl (hdr->num),
+                ntohs (message->size),
+                GNUNET_i2s (peer));
+    GNUNET_free (ps);
+  }
 }
 
 
@@ -315,8 +321,10 @@
 
   struct PeerContext *p = cls;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') connected to us!\n",
-              p->no, GNUNET_i2s (peer));
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Peer %u (`%4s') connected to us!\n",
+              p->no,
+              GNUNET_i2s (peer));
 }
 
 
@@ -325,7 +333,9 @@
 {
   struct PeerContext *p = cls;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%4s') disconnected!\n", 
p->no,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Peer %u (`%4s') disconnected!\n",
+              p->no,
               GNUNET_i2s (peer));
   if (th != NULL)
     GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);

Modified: gnunet/src/transport/test_transport_api_bidirectional_connect.c
===================================================================
--- gnunet/src/transport/test_transport_api_bidirectional_connect.c     
2015-11-06 23:46:00 UTC (rev 36646)
+++ gnunet/src/transport/test_transport_api_bidirectional_connect.c     
2015-11-07 00:06:26 UTC (rev 36647)
@@ -185,20 +185,24 @@
   }
 
   GNUNET_assert (size >= 256);
+  hdr = buf;
+  hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
+  hdr->type = htons (MTYPE);
 
-  if (buf != NULL)
   {
-    hdr = buf;
-    hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
-    hdr->type = htons (MTYPE);
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peer %u (`%4s') sending message with type %u and size %u 
bytes to peer %u (`%4s')\n",
+                p2->no,
+                ps,
+                ntohs (hdr->type),
+                ntohs (hdr->size),
+                p->no,
+                GNUNET_i2s (&p->id));
+    GNUNET_free (ps);
   }
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peer %u (`%4s') sending message with type %u and size %u bytes 
to peer %u (`%4s')\n",
-              p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
-              GNUNET_i2s (&p->id));
-  GNUNET_free (ps);
   return sizeof (struct GNUNET_MessageHeader);
 }
 
@@ -229,7 +233,6 @@
   static int c;
 
   c++;
-  GNUNET_assert (NULL != cls);
   struct PeerContext *p = cls;
   struct PeerContext *t = NULL;
 
@@ -239,12 +242,17 @@
     t = p2;
   GNUNET_assert (t != NULL);
 
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+  {
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps,
-              t->no, GNUNET_i2s (peer));
-  GNUNET_free (ps);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Peer %u (`%4s'): peer %u (`%s') connected to me!\n",
+                p->no,
+                ps,
+                t->no,
+                GNUNET_i2s (peer));
+    GNUNET_free (ps);
+  }
 }
 
 
@@ -252,14 +260,17 @@
 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *p = cls;
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Peer %u (`%4s'): peer (`%s') disconnected from me!\n",
-              p->no, ps,
-              GNUNET_i2s (peer));
-  GNUNET_free (ps);
+  {
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
 
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Peer %u (`%4s'): peer (`%s') disconnected from me!\n",
+                p->no,
+                ps,
+                GNUNET_i2s (peer));
+    GNUNET_free (ps);
+  }
   if (NULL != send_task)
   {
     GNUNET_SCHEDULER_cancel(send_task);
@@ -277,7 +288,8 @@
 static void
 testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
 {
-       static int connected = GNUNET_NO;
+  static int connected = GNUNET_NO;
+
   if ((cls == cc1) && (NULL != cc2))
   {
     GNUNET_TRANSPORT_TESTING_connect_peers_cancel (tth, cc2);
@@ -290,14 +302,23 @@
   cc2 = NULL;
 
   if (connected > 0)
-       return;
-  connected  ++;
-  char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
+    return;
+  connected++;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u 
(%s)\n",
-              p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
-  GNUNET_free (p1_c);
-  send_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, 
&sendtask, NULL);
+  {
+    char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peers connected: %u (%s) <-> %u (%s)\n",
+                p1->no,
+                p1_c,
+                p2->no,
+                GNUNET_i2s (&p2->id));
+    GNUNET_free (p1_c);
+  }
+  send_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS,
+                                            &sendtask,
+                                            NULL);
 }
 
 

Modified: gnunet/src/transport/test_transport_api_blacklisting.c
===================================================================
--- gnunet/src/transport/test_transport_api_blacklisting.c      2015-11-06 
23:46:00 UTC (rev 36646)
+++ gnunet/src/transport/test_transport_api_blacklisting.c      2015-11-07 
00:06:26 UTC (rev 36647)
@@ -236,24 +236,28 @@
   }
 
   GNUNET_assert (size >= TEST_MESSAGE_SIZE);
+  hdr = buf;
+  hdr->size = htons (TEST_MESSAGE_SIZE);
+  hdr->type = htons (TEST_MESSAGE_TYPE);
 
-  if (buf != NULL)
   {
-    hdr = buf;
-    hdr->size = htons (TEST_MESSAGE_SIZE);
-    hdr->type = htons (TEST_MESSAGE_TYPE);
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
+
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                "Peer %u (`%4s') sending message with type %u and size %u 
bytes to peer %u (`%4s')\n",
+                p2->no,
+                ps,
+                ntohs (hdr->type),
+                ntohs (hdr->size),
+                p->no,
+                GNUNET_i2s (&p->id));
+    GNUNET_free (ps);
   }
 
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
-  GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-              "Peer %u (`%4s') sending message with type %u and size %u bytes 
to peer %u (`%4s')\n",
-              p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
-              GNUNET_i2s (&p->id));
-  GNUNET_free (ps);
-
   return TEST_MESSAGE_SIZE;
 }
 
+
 static void
 sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -291,12 +295,17 @@
     t = p2;
   GNUNET_assert (t != NULL);
 
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+  {
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps,
-              t->no, GNUNET_i2s (peer));
-  GNUNET_free (ps);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peer %u (`%4s'): peer %u (`%s') connected to me!\n",
+                p->no,
+                ps,
+                t->no,
+                GNUNET_i2s (peer));
+    GNUNET_free (ps);
+  }
 }
 
 

Modified: gnunet/src/transport/test_transport_api_manipulation_cfg.c
===================================================================
--- gnunet/src/transport/test_transport_api_manipulation_cfg.c  2015-11-06 
23:46:00 UTC (rev 36646)
+++ gnunet/src/transport/test_transport_api_manipulation_cfg.c  2015-11-07 
00:06:26 UTC (rev 36647)
@@ -107,6 +107,7 @@
   GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
 }
 
+
 static void
 end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -180,26 +181,31 @@
   }
 
   GNUNET_assert (size >= TEST_MESSAGE_SIZE);
-  if (buf != NULL)
+  memset (buf, '\0', TEST_MESSAGE_SIZE);
+  hdr = buf;
+  hdr->size = htons (TEST_MESSAGE_SIZE);
+  hdr->type = htons (TEST_REQUEST_MESSAGE_TYPE);
+
   {
-    memset (buf, '\0', TEST_MESSAGE_SIZE);
-    hdr = buf;
-    hdr->size = htons (TEST_MESSAGE_SIZE);
-    hdr->type = htons (TEST_REQUEST_MESSAGE_TYPE);
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id));
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Sending request message from peer %u (`%4s') with type %u and 
size %u bytes to peer %u (`%4s')\n",
+                p1->no, ps,
+                ntohs (hdr->type),
+                ntohs (hdr->size),
+                p->no,
+                GNUNET_i2s (&p->id));
+    GNUNET_free (ps);
   }
 
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Sending request message from peer %u (`%4s') with type %u and 
size %u bytes to peer %u (`%4s')\n",
-              p1->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
-              GNUNET_i2s (&p->id));
-  GNUNET_free (ps);
   return TEST_MESSAGE_SIZE;
 }
 
 
 static void
-sendtask_request_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext 
*tc)
+sendtask_request_task (void *cls,
+                       const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   send_task = NULL;
 
@@ -240,42 +246,55 @@
   }
 
   GNUNET_assert (size >= TEST_MESSAGE_SIZE);
-  if (buf != NULL)
+  memset (buf, '\0', TEST_MESSAGE_SIZE);
+  hdr = buf;
+  hdr->size = htons (TEST_MESSAGE_SIZE);
+  hdr->type = htons (TEST_RESPONSE_MESSAGE_TYPE);
+
   {
-    memset (buf, '\0', TEST_MESSAGE_SIZE);
-    hdr = buf;
-    hdr->size = htons (TEST_MESSAGE_SIZE);
-    hdr->type = htons (TEST_RESPONSE_MESSAGE_TYPE);
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Sending response message from peer %u (`%4s') with type %u 
and size %u bytes to peer %u (`%4s')\n",
+                p1->no,
+                ps,
+                ntohs (hdr->type),
+                ntohs (hdr->size),
+                p->no,
+                GNUNET_i2s (&p->id));
+    GNUNET_free (ps);
   }
 
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p1->id));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Sending response message from peer %u (`%4s') with type %u and 
size %u bytes to peer %u (`%4s')\n",
-              p1->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
-              GNUNET_i2s (&p->id));
-  GNUNET_free (ps);
-
   return TEST_MESSAGE_SIZE;
 }
 
+
 static void
-sendtask_response_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext 
*tc)
+sendtask_response_task (void *cls,
+                        const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   send_task = NULL;
 
   if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
     return;
-  char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id));
+  {
+    char *receiver_s = GNUNET_strdup (GNUNET_i2s (&p1->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n",
-              p2->no, GNUNET_i2s (&p2->id), p1->no, receiver_s);
-  GNUNET_free (receiver_s);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Sending message from peer %u (`%4s') -> peer %u (`%s') !\n",
+                p2->no,
+                GNUNET_i2s (&p2->id),
+                p1->no,
+                receiver_s);
+    GNUNET_free (receiver_s);
+  }
 
   s_sending = GNUNET_YES;
-       start_response = GNUNET_TIME_absolute_get();
-  th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 
TEST_MESSAGE_SIZE,
-                                               TIMEOUT_TRANSMIT, 
&notify_response_ready,
+  start_response = GNUNET_TIME_absolute_get();
+  th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th,
+                                               &p1->id,
+                                               TEST_MESSAGE_SIZE,
+                                               TIMEOUT_TRANSMIT,
+                                               &notify_response_ready,
                                                p1);
 }
 

Modified: gnunet/src/transport/test_transport_api_manipulation_recv_tcp.c
===================================================================
--- gnunet/src/transport/test_transport_api_manipulation_recv_tcp.c     
2015-11-06 23:46:00 UTC (rev 36646)
+++ gnunet/src/transport/test_transport_api_manipulation_recv_tcp.c     
2015-11-07 00:06:26 UTC (rev 36647)
@@ -264,27 +264,32 @@
   }
 
   GNUNET_assert (size >= TEST_MESSAGE_SIZE);
-  if (buf != NULL)
+  memset (buf, '\0', TEST_MESSAGE_SIZE);
+  hdr = buf;
+  hdr->size = htons (TEST_MESSAGE_SIZE);
+  hdr->type = htons (TEST_MESSAGE_TYPE);
+
   {
-    memset (buf, '\0', TEST_MESSAGE_SIZE);
-    hdr = buf;
-    hdr->size = htons (TEST_MESSAGE_SIZE);
-    hdr->type = htons (TEST_MESSAGE_TYPE);
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peer %u (`%4s') sending message with type %u and size %u 
bytes to peer %u (`%4s')\n",
+                p2->no,
+                ps,
+                ntohs (hdr->type),
+                ntohs (hdr->size),
+                p->no,
+                GNUNET_i2s (&p->id));
+    GNUNET_free (ps);
   }
 
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peer %u (`%4s') sending message with type %u and size %u bytes 
to peer %u (`%4s')\n",
-              p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
-              GNUNET_i2s (&p->id));
-  GNUNET_free (ps);
-
   return TEST_MESSAGE_SIZE;
 }
 
 
 static void
-sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+sendtask (void *cls,
+          const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
   send_task = NULL;
 
@@ -300,22 +305,26 @@
 
   if (0 == messages_recv)
   {
-       start_normal = GNUNET_TIME_absolute_get();
+    start_normal = GNUNET_TIME_absolute_get();
   }
   if (1 == messages_recv)
   {
-               start_delayed = GNUNET_TIME_absolute_get();
+    start_delayed = GNUNET_TIME_absolute_get();
   }
 
   s_sending = GNUNET_YES;
-  th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 
TEST_MESSAGE_SIZE,
-                                               TIMEOUT_TRANSMIT, &notify_ready,
+  th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th,
+                                               &p1->id,
+                                               TEST_MESSAGE_SIZE,
+                                               TIMEOUT_TRANSMIT,
+                                               &notify_ready,
                                                p1);
 }
 
 
 static void
-notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
+notify_connect (void *cls,
+                const struct GNUNET_PeerIdentity *peer)
 {
   static int c;
 
@@ -329,43 +338,64 @@
     t = p2;
   GNUNET_assert (t != NULL);
 
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+  {
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps,
-              t->no, GNUNET_i2s (peer));
-  GNUNET_free (ps);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peer %u (`%4s'): peer %u (`%s') connected to me!\n",
+                p->no,
+                ps,
+                t->no,
+                GNUNET_i2s (peer));
+    GNUNET_free (ps);
+  }
 }
 
 
 static void
-notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
+notify_disconnect (void *cls,
+                   const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *p = cls;
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, 
ps,
-              GNUNET_i2s (peer));
+  {
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
 
-  GNUNET_free (ps);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peer %u (`%4s'): peer (`%s') disconnected from me!\n",
+                p->no,
+                ps,
+                GNUNET_i2s (peer));
+    GNUNET_free (ps);
+  }
 
   if (th != NULL)
+  {
     GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
-  th = NULL;
+    th = NULL;
+  }
 }
 
 
 static void
-testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
+testing_connect_cb (struct PeerContext *p1,
+                    struct PeerContext *p2,
+                    void *cls)
 {
   cc = NULL;
-  char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peers connected: %u (%s) <-> %u 
(%s)\n",
-              p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
-  GNUNET_free (p1_c);
+  {
+    char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
 
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peers connected: %u (%s) <-> %u (%s)\n",
+                p1->no,
+                p1_c,
+                p2->no,
+                GNUNET_i2s (&p2->id));
+    GNUNET_free (p1_c);
+  }
+
   s_connected = GNUNET_YES;
   send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
 }
@@ -377,7 +407,9 @@
   static int started;
   started++;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Peer %u (`%s') started\n",
+              p->no,
               GNUNET_i2s (&p->id));
 
   if (started != 2)
@@ -384,14 +416,22 @@
     return;
   else
     s_started = GNUNET_YES;
-  char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
+  {
+    char *sender_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
-              p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id));
-  GNUNET_free (sender_c);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n",
+                p1->no,
+                sender_c,
+                p2->no,
+                GNUNET_i2s (&p2->id));
+    GNUNET_free (sender_c);
+  }
 
-  cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, 
&testing_connect_cb,
+  cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth,
+                                               p1,
+                                               p2,
+                                               &testing_connect_cb,
                                                NULL);
 
 }

Modified: gnunet/src/transport/test_transport_api_manipulation_send_tcp.c
===================================================================
--- gnunet/src/transport/test_transport_api_manipulation_send_tcp.c     
2015-11-06 23:46:00 UTC (rev 36646)
+++ gnunet/src/transport/test_transport_api_manipulation_send_tcp.c     
2015-11-07 00:06:26 UTC (rev 36647)
@@ -85,6 +85,7 @@
 static struct GNUNET_TIME_Absolute start_delayed;
 static struct GNUNET_TIME_Relative dur_delayed;
 
+
 static void
 end ()
 {
@@ -104,6 +105,7 @@
   GNUNET_TRANSPORT_TESTING_stop_peer (tth, p2);
 }
 
+
 static void
 end_badly (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
@@ -160,6 +162,7 @@
 static void
 sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc);
 
+
 static void
 notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer,
                 const struct GNUNET_MessageHeader *message)
@@ -173,13 +176,19 @@
     t = p2;
   GNUNET_assert (t != NULL);
 
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+  {
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peer %u (`%4s') received message of type %d and size %u size 
from peer %u (`%4s')!\n",
-              p->no, ps, ntohs (message->type), ntohs (message->size), t->no,
-              GNUNET_i2s (&t->id));
-  GNUNET_free (ps);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peer %u (`%4s') received message of type %d and size %u size 
from peer %u (`%4s')!\n",
+                p->no,
+                ps,
+                ntohs (message->type),
+                ntohs (message->size),
+                t->no,
+                GNUNET_i2s (&t->id));
+    GNUNET_free (ps);
+  }
 
   if ((TEST_MESSAGE_TYPE == ntohs (message->type)) &&
       (TEST_MESSAGE_SIZE == ntohs (message->size)))
@@ -252,21 +261,24 @@
   }
 
   GNUNET_assert (size >= TEST_MESSAGE_SIZE);
-  if (buf != NULL)
+  memset (buf, '\0', TEST_MESSAGE_SIZE);
+  hdr = buf;
+  hdr->size = htons (TEST_MESSAGE_SIZE);
+  hdr->type = htons (TEST_MESSAGE_TYPE);
+
   {
-    memset (buf, '\0', TEST_MESSAGE_SIZE);
-    hdr = buf;
-    hdr->size = htons (TEST_MESSAGE_SIZE);
-    hdr->type = htons (TEST_MESSAGE_TYPE);
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peer %u (`%4s') sending message with type %u and size %u 
bytes to peer %u (`%4s')\n",
+                p2->no,
+                ps,
+                ntohs (hdr->type),
+                ntohs (hdr->size),
+                p->no,
+                GNUNET_i2s (&p->id));
+    GNUNET_free (ps);
   }
 
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peer %u (`%4s') sending message with type %u and size %u bytes 
to peer %u (`%4s')\n",
-              p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
-              GNUNET_i2s (&p->id));
-  GNUNET_free (ps);
-
   return TEST_MESSAGE_SIZE;
 }
 
@@ -291,7 +303,6 @@
               receiver_s);
   GNUNET_free (receiver_s);
 
-
   if (0 == messages_recv)
   {
     start_normal = GNUNET_TIME_absolute_get ();
@@ -325,11 +336,10 @@
 notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
   static int c;
-
-  c++;
   struct PeerContext *p = cls;
   struct PeerContext *t = NULL;
 
+  c++;
   if (0 == memcmp (peer, &p1->id, sizeof (struct GNUNET_PeerIdentity)))
     t = p1;
   if (0 == memcmp (peer, &p2->id, sizeof (struct GNUNET_PeerIdentity)))
@@ -336,12 +346,17 @@
     t = p2;
   GNUNET_assert (t != NULL);
 
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
+  {
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peer %u (`%4s'): peer %u (`%s') connected to me!\n", p->no, ps,
-              t->no, GNUNET_i2s (peer));
-  GNUNET_free (ps);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peer %u (`%4s'): peer %u (`%s') connected to me!\n",
+                p->no,
+                ps,
+                t->no,
+                GNUNET_i2s (peer));
+    GNUNET_free (ps);
+  }
 }
 
 
@@ -349,17 +364,23 @@
 notify_disconnect (void *cls, const struct GNUNET_PeerIdentity *peer)
 {
   struct PeerContext *p = cls;
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peer %u (`%4s'): peer (`%s') disconnected from me!\n", p->no, 
ps,
-              GNUNET_i2s (peer));
+  {
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p->id));
 
-  GNUNET_free (ps);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peer %u (`%4s'): peer (`%s') disconnected from me!\n",
+                p->no,
+                ps,
+                GNUNET_i2s (peer));
+    GNUNET_free (ps);
+  }
 
   if (th != NULL)
+  {
     GNUNET_TRANSPORT_notify_transmit_ready_cancel (th);
-  th = NULL;
+    th = NULL;
+  }
 }
 
 
@@ -367,13 +388,19 @@
 testing_connect_cb (struct PeerContext *p1, struct PeerContext *p2, void *cls)
 {
   cc = NULL;
-  char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peers connected: %u (%s) <-> %u (%s)\n",
-              p1->no, p1_c, p2->no, GNUNET_i2s (&p2->id));
-  GNUNET_free (p1_c);
+  {
+    char *p1_c = GNUNET_strdup (GNUNET_i2s (&p1->id));
 
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peers connected: %u (%s) <-> %u (%s)\n",
+                p1->no,
+                p1_c,
+                p2->no,
+                GNUNET_i2s (&p2->id));
+    GNUNET_free (p1_c);
+  }
+
   s_connected = GNUNET_YES;
   send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL);
 }
@@ -385,7 +412,9 @@
   static int started;
   started++;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %u (`%s') started\n", p->no,
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Peer %u (`%s') started\n",
+              p->no,
               GNUNET_i2s (&p->id));
 
   if (started != 2)

Modified: gnunet/src/transport/test_transport_api_monitor_peers.c
===================================================================
--- gnunet/src/transport/test_transport_api_monitor_peers.c     2015-11-06 
23:46:00 UTC (rev 36646)
+++ gnunet/src/transport/test_transport_api_monitor_peers.c     2015-11-07 
00:06:26 UTC (rev 36647)
@@ -237,21 +237,25 @@
   }
 
   GNUNET_assert (size >= TEST_MESSAGE_SIZE);
-  if (buf != NULL)
+  memset (buf, '\0', TEST_MESSAGE_SIZE);
+  hdr = buf;
+  hdr->size = htons (TEST_MESSAGE_SIZE);
+  hdr->type = htons (TEST_MESSAGE_TYPE);
+
   {
-    memset (buf, '\0', TEST_MESSAGE_SIZE);
-    hdr = buf;
-    hdr->size = htons (TEST_MESSAGE_SIZE);
-    hdr->type = htons (TEST_MESSAGE_TYPE);
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
+
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Peer %u (`%4s') sending message with type %u and size %u 
bytes to peer %u (`%4s')\n",
+                p2->no,
+                ps,
+                ntohs (hdr->type),
+                ntohs (hdr->size),
+                p->no,
+                GNUNET_i2s (&p->id));
+    GNUNET_free (ps);
   }
 
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Peer %u (`%4s') sending message with type %u and size %u bytes 
to peer %u (`%4s')\n",
-              p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
-              GNUNET_i2s (&p->id));
-  GNUNET_free (ps);
-
   return TEST_MESSAGE_SIZE;
 }
 

Modified: gnunet/src/transport/test_transport_api_monitor_validation.c
===================================================================
--- gnunet/src/transport/test_transport_api_monitor_validation.c        
2015-11-06 23:46:00 UTC (rev 36646)
+++ gnunet/src/transport/test_transport_api_monitor_validation.c        
2015-11-07 00:06:26 UTC (rev 36647)
@@ -229,40 +229,45 @@
 
 
 static size_t
-notify_ready (void *cls, size_t size, void *buf)
+notify_ready (void *cls,
+              size_t size,
+              void *buf)
 {
   struct PeerContext *p = cls;
   struct GNUNET_MessageHeader *hdr;
 
   th = NULL;
-
-  if (buf == NULL)
+  if (NULL == buf)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Timeout occurred while waiting for transmit_ready\n");
     if (NULL != die_task)
       GNUNET_SCHEDULER_cancel (die_task);
-    die_task = GNUNET_SCHEDULER_add_now (&end_badly, NULL);
+    die_task = GNUNET_SCHEDULER_add_now (&end_badly,
+                                         NULL);
     ok = 42;
     return 0;
   }
 
   GNUNET_assert (size >= TEST_MESSAGE_SIZE);
-  if (buf != NULL)
+  memset (buf, '\0', TEST_MESSAGE_SIZE);
+  hdr = buf;
+  hdr->size = htons (TEST_MESSAGE_SIZE);
+  hdr->type = htons (TEST_MESSAGE_TYPE);
+
   {
-    memset (buf, '\0', TEST_MESSAGE_SIZE);
-    hdr = buf;
-    hdr->size = htons (TEST_MESSAGE_SIZE);
-    hdr->type = htons (TEST_MESSAGE_TYPE);
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Peer %u (`%4s') sending message with type %u and size %u 
bytes to peer %u (`%4s')\n",
+                p2->no,
+                ps,
+                ntohs (hdr->type),
+                ntohs (hdr->size),
+                p->no,
+                GNUNET_i2s (&p->id));
+    GNUNET_free (ps);
   }
 
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              "Peer %u (`%4s') sending message with type %u and size %u bytes 
to peer %u (`%4s')\n",
-              p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
-              GNUNET_i2s (&p->id));
-  GNUNET_free (ps);
-
   return TEST_MESSAGE_SIZE;
 }
 
@@ -290,9 +295,13 @@
 static void
 done ()
 {
-  if ((GNUNET_YES == p1_c) && (GNUNET_YES == p2_c) && p1_c_notify && 
p2_c_notify)
+  if ( (GNUNET_YES == p1_c) &&
+       (GNUNET_YES == p2_c) &&
+       p1_c_notify &&
+       p2_c_notify)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Both peers state to be connected\n");
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Both peers state to be connected\n");
     ok = 0;
     end();
   }
@@ -403,7 +412,7 @@
 
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Monitor 1: %s %s %s\n",
-             GNUNET_i2s (&address->peer), 
+             GNUNET_i2s (&address->peer),
              GNUNET_TRANSPORT_vs2s (state),
              GNUNET_STRINGS_absolute_time_to_string(valid_until));
   if (0 == memcmp (&address->peer,
@@ -427,7 +436,7 @@
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Monitor 2: %s %s %s\n",
              GNUNET_i2s (&address->peer),
-             GNUNET_TRANSPORT_vs2s(state), 
+             GNUNET_TRANSPORT_vs2s(state),
              GNUNET_STRINGS_absolute_time_to_string(valid_until));
   if (0 == memcmp (&address->peer,
                   &p1->id,

Modified: gnunet/src/transport/test_transport_api_restart_1peer.c
===================================================================
--- gnunet/src/transport/test_transport_api_restart_1peer.c     2015-11-06 
23:46:00 UTC (rev 36646)
+++ gnunet/src/transport/test_transport_api_restart_1peer.c     2015-11-07 
00:06:26 UTC (rev 36647)
@@ -225,7 +225,7 @@
 
   th = NULL;
 
-  if (buf == NULL)
+  if (NULL == buf)
   {
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                 "Timeout occurred while waiting for transmit_ready\n");
@@ -237,20 +237,23 @@
   }
 
   GNUNET_assert (size >= 256);
+  hdr = buf;
+  hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
+  hdr->type = htons (MTYPE);
 
-  if (buf != NULL)
   {
-    hdr = buf;
-    hdr->size = htons (sizeof (struct GNUNET_MessageHeader));
-    hdr->type = htons (MTYPE);
+    char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
+
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Peer %u (`%4s') sending message with type %u and size %u 
bytes to peer %u (`%4s')\n",
+                p2->no,
+                ps,
+                ntohs (hdr->type),
+                ntohs (hdr->size),
+                p->no,
+                GNUNET_i2s (&p->id));
+    GNUNET_free (ps);
   }
-  char *ps = GNUNET_strdup (GNUNET_i2s (&p2->id));
-
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "Peer %u (`%4s') sending message with type %u and size %u bytes 
to peer %u (`%4s')\n",
-              p2->no, ps, ntohs (hdr->type), ntohs (hdr->size), p->no,
-              GNUNET_i2s (&p->id));
-  GNUNET_free (ps);
   return sizeof (struct GNUNET_MessageHeader);
 }
 
@@ -269,14 +272,18 @@
               p2->no, GNUNET_i2s (&p2->id), p1->no, receiver_s);
   GNUNET_free (receiver_s);
 
-  th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th, &p1->id, 256,
-                                               TIMEOUT_TRANSMIT, &notify_ready,
+  th = GNUNET_TRANSPORT_notify_transmit_ready (p2->th,
+                                               &p1->id,
+                                               256,
+                                               TIMEOUT_TRANSMIT,
+                                               &notify_ready,
                                                p1);
 }
 
 
 static void
-notify_connect (void *cls, const struct GNUNET_PeerIdentity *peer)
+notify_connect (void *cls,
+                const struct GNUNET_PeerIdentity *peer)
 {
   static int c;
 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]