Avoid dvision by zero
[oweals/gnunet.git] / src / multicast / test_multicast_2peers.c
index 058533e506db6d1d04fec007c0c07f65c6f855bf..325d814988c496ab6ee10e031bcf11f9f2640171 100644 (file)
@@ -2,20 +2,18 @@
  * This file is part of GNUnet
  * Copyright (C) 2013 GNUnet e.V.
  *
- * GNUnet is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published
- * by the Free Software Foundation; either version 3, or (at your
- * option) any later version.
+ * GNUnet is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published
+ * by the Free Software Foundation, either version 3 of the License,
+ * or (at your option) any later version.
  *
  * GNUnet is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
+ * Affero General Public License for more details.
  *
- * You should have received a copy of the GNU General Public License
- * along with GNUnet; see the file COPYING.  If not, write to the
- * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 /**
@@ -181,6 +179,7 @@ member_message (void *cls,
   GNUNET_SCHEDULER_shutdown ();
 }
 
+
 static void
 origin_join_request (void *cls,
                  const struct GNUNET_CRYPTO_EcdsaPublicKey *member_pub_key,
@@ -215,14 +214,18 @@ origin_join_request (void *cls,
   result = GNUNET_OK;
 }
 
+
 int
 origin_notify (void *cls,
                size_t *data_size,
                void *data)
 {
   char text[] = "pong";
+
   *data_size = strlen(text)+1;
-  memcpy(data, text, *data_size);
+  GNUNET_memcpy (data,
+                 text,
+                 *data_size);
 
   GNUNET_log (GNUNET_ERROR_TYPE_INFO, "origin sends (to all): %s\n", text);
 
@@ -246,6 +249,7 @@ origin_request (void *cls,
                                   NULL);
 }
 
+
 static void
 origin_message (void *cls,
                 const struct GNUNET_MULTICAST_MessageHeader *msg)
@@ -262,17 +266,18 @@ service_connect1 (void *cls,
 {
   member = ca_result;
 
-  if (NULL != member)
+  if (NULL == member)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connected to multicast service of member\n");
+    result = GNUNET_SYSERR;
+    GNUNET_SCHEDULER_shutdown ();
   }
   else
   {
-    result = GNUNET_SYSERR;
-    GNUNET_SCHEDULER_shutdown ();
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Connected to multicast service of member\n");
   }
 }
 
+
 static void
 multicast_da1 (void *cls,
                void * op_result)
@@ -359,9 +364,10 @@ peer_information_cb (void *cls,
                                           multicast_da1,     /* callback to be called when closing the
                                                                 opened service connection */
                                           NULL);                   /* closure for the above two callbacks */
-    }
+  }
 }
 
+
 /**
  * Test logic of peer "0" being origin starts here.
  *
@@ -495,7 +501,7 @@ main (int argc, char *argv[])
 
   result = GNUNET_SYSERR;
   ret = GNUNET_TESTBED_test_run
-      ("test-multicast-multipeer",  /* test case name */
+      ("test-multicast-2peers",  /* test case name */
        "test_multicast.conf", /* template configuration */
        NUM_PEERS,       /* number of peers to start */
        0LL, /* Event mask - set to 0 for no event notifications */
@@ -508,4 +514,5 @@ main (int argc, char *argv[])
   return 0;
 }
 
-/* end of test_multicast_multipeer.c */
+
+/* end of test_multicast_2peers.c */