gnunet-svn
[Top][All Lists]
Advanced

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

[gnunet] branch master updated: TRANSPORT/CADET: Fix some warnings.


From: gnunet
Subject: [gnunet] branch master updated: TRANSPORT/CADET: Fix some warnings.
Date: Sat, 21 Oct 2023 09:57:16 +0200

This is an automated email from the git hooks/post-receive script.

martin-schanzenbach pushed a commit to branch master
in repository gnunet.

The following commit(s) were added to refs/heads/master by this push:
     new 8f8e9b1aa TRANSPORT/CADET: Fix some warnings.
8f8e9b1aa is described below

commit 8f8e9b1aad007e296afc6b4f813791234480aef4
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Sat Oct 21 09:56:42 2023 +0200

    TRANSPORT/CADET: Fix some warnings.
---
 src/service/cadet/gnunet-service-cadet_dht.c     |   2 +-
 src/service/transport/gnunet-service-transport.c | 157 ++++++++++++-----------
 2 files changed, 84 insertions(+), 75 deletions(-)

diff --git a/src/service/cadet/gnunet-service-cadet_dht.c 
b/src/service/cadet/gnunet-service-cadet_dht.c
index 215f6e184..ef5669344 100644
--- a/src/service/cadet/gnunet-service-cadet_dht.c
+++ b/src/service/cadet/gnunet-service-cadet_dht.c
@@ -120,7 +120,7 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute 
exp,
                     const void *data)
 {
   const struct GNUNET_MessageHeader *hello = data;
-  const struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg 
(hello);
+  struct GNUNET_HELLO_Builder *builder = GNUNET_HELLO_builder_from_msg (hello);
 
   GNUNET_assert (NULL != builder);
   (void) trunc_peer;
diff --git a/src/service/transport/gnunet-service-transport.c 
b/src/service/transport/gnunet-service-transport.c
index ec3019161..7f34483e3 100644
--- a/src/service/transport/gnunet-service-transport.c
+++ b/src/service/transport/gnunet-service-transport.c
@@ -187,20 +187,20 @@
  * the value chosen here might be too aggressively low!
  */
 #define DELAY_WARN_THRESHOLD \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
 
 /**
  * If a DVBox could not be forwarded after this number of
  * seconds we drop it.
  */
 #define DV_FORWARD_TIMEOUT \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 60)
 
 /**
  * Default value for how long we wait for reliability ack.
  */
 #define DEFAULT_ACK_WAIT_DURATION \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
 
 /**
  * We only consider queues as "quality" connections when
@@ -208,53 +208,53 @@
  * the latency of the queue is below this threshold.
  */
 #define DV_QUALITY_RTT_THRESHOLD \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1)
 
 /**
  * How long do we consider a DV path valid if we see no
  * further updates on it? Note: the value chosen here might be too low!
  */
 #define DV_PATH_VALIDITY_TIMEOUT \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
 
 /**
  * How long do we cache backchannel (struct Backtalker) information
  * after a backchannel goes inactive?
  */
 #define BACKCHANNEL_INACTIVITY_TIMEOUT \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 5)
 
 /**
  * How long before paths expire would we like to (re)discover DV paths? Should
  * be below #DV_PATH_VALIDITY_TIMEOUT.
  */
 #define DV_PATH_DISCOVERY_FREQUENCY \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
 
 /**
  * How long are ephemeral keys valid?
  */
 #define EPHEMERAL_VALIDITY \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
 
 /**
  * How long do we keep partially reassembled messages around before giving up?
  */
 #define REASSEMBLY_EXPIRATION \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 4)
 
 /**
  * What is the fastest rate at which we send challenges *if* we keep learning
  * an address (gossip, DHT, etc.)?
  */
 #define FAST_VALIDATION_CHALLENGE_FREQ \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 1)
 
 /**
  * What is the slowest rate at which we send challenges?
  */
 #define MAX_VALIDATION_CHALLENGE_FREQ \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_DAYS, 1)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_DAYS, 1)
 
 /**
  * How long until we forget about historic accumulators and thus
@@ -262,7 +262,7 @@
  * active connection experiences without an ACK.
  */
 #define ACK_CUMMULATOR_TIMEOUT \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
 
 /**
  * What is the non-randomized base frequency at which we
@@ -280,13 +280,13 @@
  * When do we forget an invalid address for sure?
  */
 #define MAX_ADDRESS_VALID_UNTIL \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MONTHS, 1)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MONTHS, 1)
 
 /**
  * How long do we consider an address valid if we just checked?
  */
 #define ADDRESS_VALIDATION_LIFETIME \
-  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
+        GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_HOURS, 4)
 
 /**
  * What is the maximum frequency at which we do address validation?
@@ -2377,11 +2377,26 @@ struct AddressListEntry
    */
   struct TransportClient *tc;
 
+  /**
+   * Store hello handle
+   */
+  struct GNUNET_PEERSTORE_StoreHelloContext *shc;
+
   /**
    * The actual address.
    */
   const char *address;
 
+  /**
+   * Signed address
+   */
+  void *signed_address;
+
+  /**
+   * Signed address length
+   */
+  size_t signed_address_len;
+
   /**
    * Current context for storing this address in the peerstore.
    */
@@ -5473,7 +5488,21 @@ peerstore_store_own_cb (void *cls, int success)
 static void
 shc_cont (void *cls, int success)
 {
-  GNUNET_free (cls);
+  struct AddressListEntry *ale = cls;
+  struct GNUNET_TIME_Absolute expiration;
+  expiration = GNUNET_TIME_relative_to_absolute (ale->expiration);
+  ale->sc = GNUNET_PEERSTORE_store (peerstore,
+                                    "transport",
+                                    &GST_my_identity,
+                                    GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY,
+                                    ale->signed_address,
+                                    ale->signed_address_len,
+                                    expiration,
+                                    GNUNET_PEERSTORE_STOREOPTION_MULTIPLE,
+                                    &peerstore_store_own_cb,
+                                    ale);
+  GNUNET_free (ale->signed_address);
+  GNUNET_free (ale);
 }
 
 
@@ -5486,75 +5515,54 @@ static void
 store_pi (void *cls)
 {
   struct AddressListEntry *ale = cls;
-  struct GNUNET_PEERSTORE_StoreHelloContext *shc;
-  void *addr;
-  size_t addr_len;
-  struct GNUNET_TIME_Absolute expiration;
-  enum GNUNET_GenericReturnValue add_result;
   struct GNUNET_MQ_Envelope *env;
   const struct GNUNET_MessageHeader *msg;
   const char *dash;
-  char *prefix = GNUNET_HELLO_address_to_prefix (ale->address);
   char *address_uri;
+  char *prefix = GNUNET_HELLO_address_to_prefix (ale->address);
 
   dash = strchr (ale->address, '-');
   dash++;
   GNUNET_asprintf (&address_uri,
-                     "%s://%s",
-                     prefix,
-                     dash);
+                   "%s://%s",
+                   prefix,
+                   dash);
+  GNUNET_free (prefix);
   ale->st = NULL;
-  expiration = GNUNET_TIME_relative_to_absolute (ale->expiration);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Storing our address `%s' in peerstore until %s!\n",
               ale->address,
-              GNUNET_STRINGS_absolute_time_to_string (expiration));
-  add_result = GNUNET_HELLO_builder_add_address (GST_my_hello,
-                                                 address_uri);
+              GNUNET_STRINGS_absolute_time_to_string (hello_mono_time));
+  if (GNUNET_OK != GNUNET_HELLO_builder_add_address (GST_my_hello,
+                                                     address_uri))
+  {
+    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
+                "Address `%s' invalid\n",
+                address_uri);
+    GNUNET_free (address_uri);
+    ale->st =
+      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &store_pi, ale);
+    return;
+  }
+  // FIXME hello_mono_time used here?? What about expiration in ale?
+  GNUNET_HELLO_sign_address (ale->address,
+                             ale->nt,
+                             hello_mono_time,
+                             GST_my_private_key,
+                             &ale->signed_address,
+                             &ale->signed_address_len);
+  GNUNET_free (address_uri);
   env = GNUNET_HELLO_builder_to_env (GST_my_hello,
                                      GST_my_private_key,
                                      GNUNET_TIME_UNIT_ZERO);
   msg = GNUNET_MQ_env_get_msg (env);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "store_pi 1\n");
-  if (GNUNET_YES == add_result)
-    shc = GNUNET_PEERSTORE_hello_add (peerstore,
-                                      msg,
-                                      shc_cont,
-                                      shc);
-  else if (GNUNET_SYSERR == add_result)
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                "Error adding address to peerstore hello!\n");
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-              "store_pi 2\n");
-  GNUNET_HELLO_sign_address (ale->address,
-                             ale->nt,
-                             hello_mono_time,
-                             GST_my_private_key,
-                             &addr,
-                             &addr_len);
-  ale->sc = GNUNET_PEERSTORE_store (peerstore,
-                                    "transport",
-                                    &GST_my_identity,
-                                    GNUNET_PEERSTORE_TRANSPORT_HELLO_KEY,
-                                    addr,
-                                    addr_len,
-                                    expiration,
-                                    GNUNET_PEERSTORE_STOREOPTION_MULTIPLE,
-                                    &peerstore_store_own_cb,
-                                    ale);
-  GNUNET_free (addr);
+  ale->shc = GNUNET_PEERSTORE_hello_add (peerstore,
+                                         msg,
+                                         shc_cont,
+                                         ale);
   GNUNET_free (env);
-  GNUNET_free (prefix);
-  GNUNET_free (address_uri);
-  if (NULL == ale->sc)
-  {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                "Failed to store our address `%s' with peerstore\n",
-                ale->address);
-    ale->st =
-      GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, &store_pi, ale);
-  }
 }
 
 
@@ -8640,7 +8648,6 @@ handle_hello_for_incoming (void *cls,
                            const struct GNUNET_MessageHeader *hello,
                            const char *emsg)
 {
-  struct IncomingRequest *ir = cls;
   struct GNUNET_HELLO_Builder *builder;
 
   if (NULL != emsg)
@@ -8879,7 +8886,8 @@ handle_validation_response (
   struct Queue *q;
   struct Neighbour *n;
   struct VirtualLink *vl;
-  const struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get_monotonic 
(GST_cfg);
+  const struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get_monotonic (
+    GST_cfg);
 
   /* check this is one of our challenges */
   (void) GNUNET_CONTAINER_multipeermap_get_multiple (validation_map,
@@ -9681,7 +9689,8 @@ update_pm_next_attempt (struct PendingMessage *pm,
     }
     else
     {
-      double factor = (root->frag_count - 1) / root->frag_count;
+      double factor = ((double) root->frag_count - 1)
+                      / (double) root->frag_count;
       struct GNUNET_TIME_Relative s1;
       struct GNUNET_TIME_Relative s2;
       struct GNUNET_TIME_Relative plus_mean =
@@ -10179,9 +10188,10 @@ transmit_on_queue (void *cls)
         root = root->frag_parent;
 
       root->frag_count++;
-      wait_multiplier =  (unsigned int) ceil (root->bytes_msg
-                                              / (root->frag_off
-                                                 / root->frag_count)) * 4;
+      wait_multiplier =  (unsigned int) ceil ((double) root->bytes_msg
+                                              / ((double) root->frag_off
+                                                 / (double) root->frag_count))
+                        * 4;
     }
     else
     {
@@ -10345,7 +10355,7 @@ handle_send_message_ack (void *cls,
     // Update: Maybe QueueEntry was accidentally freed during freeing 
PendingMessage.
     /* this should never happen */
     GNUNET_break (0);
-    //GNUNET_SERVICE_client_drop (tc->client);
+    // GNUNET_SERVICE_client_drop (tc->client);
     GNUNET_SERVICE_client_continue (tc->client);
     return;
   }
@@ -11223,7 +11233,7 @@ handle_suggest_cancel (void *cls, const struct 
ExpressPreferenceMessage *msg)
 
 static void
 hello_for_client_cb (void *cls,
-                       const char *uri)
+                     const char *uri)
 {
   const struct GNUNET_PeerIdentity *peer = cls;
   int pfx_len;
@@ -11263,7 +11273,6 @@ handle_hello_for_client (void *cls,
                          const char *emsg)
 {
   (void) cls;
-  const char *val;
   struct GNUNET_HELLO_Builder *builder;
 
   if (NULL != emsg)

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

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