gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r34972 - gnunet/src/ats


From: gnunet
Subject: [GNUnet-SVN] r34972 - gnunet/src/ats
Date: Fri, 23 Jan 2015 00:11:25 +0100

Author: grothoff
Date: 2015-01-23 00:11:25 +0100 (Fri, 23 Jan 2015)
New Revision: 34972

Modified:
   gnunet/src/ats/gnunet-service-ats_normalization.c
Log:
-use static where allowed

Modified: gnunet/src/ats/gnunet-service-ats_normalization.c
===================================================================
--- gnunet/src/ats/gnunet-service-ats_normalization.c   2015-01-22 23:08:42 UTC 
(rev 34971)
+++ gnunet/src/ats/gnunet-service-ats_normalization.c   2015-01-22 23:11:25 UTC 
(rev 34972)
@@ -145,7 +145,7 @@
   uint32_t max;
 };
 
-struct Property properties[GNUNET_ATS_QualityPropertiesCount];
+static struct Property properties[GNUNET_ATS_QualityPropertiesCount];
 
 
 /**
@@ -161,12 +161,12 @@
 /**
  * Callback to call on changing property values
  */
-GAS_Normalization_property_changed_cb prop_ch_cb;
+static GAS_Normalization_property_changed_cb prop_ch_cb;
 
 /**
  * Closure for callback to call on changing property values
  */
-void *prop_ch_cb_cls;
+static void *prop_ch_cb_cls;
 
 /**
  * Hashmap to store peer information for preference normalization
@@ -196,9 +196,6 @@
 
 static struct GNUNET_SCHEDULER_Task * aging_task;
 
-/**
- * Application Preference Normalization
- */
 
 /**
  * Update a peer
@@ -265,6 +262,7 @@
   }
 }
 
+
 /**
  * Recalculate preference for a specific ATS property
  *
@@ -273,7 +271,8 @@
  * @return the result
  */
 static void
-recalculate_relative_preferences (struct PreferenceClient *c, enum 
GNUNET_ATS_PreferenceKind kind)
+recalculate_relative_preferences (struct PreferenceClient *c,
+                                  enum GNUNET_ATS_PreferenceKind kind)
 {
   struct PreferencePeer *p_cur;
 
@@ -313,6 +312,7 @@
 
 }
 
+
 /**
  * Update the absolute preference value for a peer
  * @param c the client
@@ -322,8 +322,10 @@
  * @return the new relative preference value
  */
 static void
-update_abs_preference (struct PreferenceClient *c, struct PreferencePeer *p,
-    enum GNUNET_ATS_PreferenceKind kind, float score_abs)
+update_abs_preference (struct PreferenceClient *c,
+                       struct PreferencePeer *p,
+                       enum GNUNET_ATS_PreferenceKind kind,
+                       float score_abs)
 {
   double score = score_abs;
 
@@ -344,19 +346,27 @@
   }
 }
 
-static int update_iterator (void *cls,
-                           const struct GNUNET_PeerIdentity *key,
-                           void *value)
+
+static int
+update_iterator (void *cls,
+                 const struct GNUNET_PeerIdentity *key,
+                 void *value)
 {
   enum GNUNET_ATS_PreferenceKind *kind = cls;
-  update_relative_values_for_peer (key, (*kind), (struct PeerRelative *) 
value);
+  struct PeerRelative *pr = value;
+
+  update_relative_values_for_peer (key,
+                                   (*kind),
+                                   pr);
   return GNUNET_OK;
 }
 
+
 static void
 run_preference_update (struct PreferenceClient *c_cur,
-    struct PreferencePeer *p_cur,enum GNUNET_ATS_PreferenceKind kind,
-    float score_abs)
+                       struct PreferencePeer *p_cur,
+                       enum GNUNET_ATS_PreferenceKind kind,
+                       float score_abs)
 {
   double old_value;
 
@@ -370,6 +380,7 @@
   GNUNET_CONTAINER_multipeermap_iterate (preference_peers, &update_iterator, 
&kind);
 }
 
+
 /**
  * Reduce absolute preferences since they got old
  *
@@ -440,6 +451,7 @@
 
 }
 
+
 /**
  * Normalize an updated preference value
  *
@@ -450,9 +462,9 @@
  */
 void
 GAS_normalization_normalize_preference (void *client,
-    const struct GNUNET_PeerIdentity *peer,
-    enum GNUNET_ATS_PreferenceKind kind,
-    float score_abs)
+                                        const struct GNUNET_PeerIdentity *peer,
+                                        enum GNUNET_ATS_PreferenceKind kind,
+                                        float score_abs)
 {
   struct PreferenceClient *c_cur;
   struct PreferencePeer *p_cur;
@@ -548,6 +560,7 @@
 
 }
 
+
 /**
  * Get the normalized preference values for a specific peer or
  * the default values if
@@ -570,6 +583,7 @@
   return rp->f_rel;
 }
 
+
 /**
  * Get the normalized preference values for a specific client and peer
  *
@@ -606,6 +620,7 @@
   return p_cur->f_rel[pref];
 }
 
+
 /**
  * Get the normalized properties values for a specific peer or
  * the default values if
@@ -632,16 +647,16 @@
   return norm_values;
 }
 
+
 /**
  * Normalize a specific ATS type with the values in queue
  * @param address the address
  * @param atsi the ats information
  * @return the new average or GNUNET_ATS_VALUE_UNDEFINED
  */
-
-uint32_t
+static uint32_t
 property_average (struct ATS_Address *address,
-    const struct GNUNET_ATS_Information *atsi)
+                  const struct GNUNET_ATS_Information *atsi)
 {
   struct GAS_NormalizationInfo *ni;
   uint32_t current_type;
@@ -701,6 +716,7 @@
   return res;
 }
 
+
 struct FindMinMaxCtx
 {
   struct Property *p;
@@ -708,6 +724,7 @@
   uint32_t max;
 };
 
+
 static int
 find_min_max_it (void *cls, const struct GNUNET_PeerIdentity *h, void *k)
 {
@@ -723,6 +740,7 @@
   return GNUNET_OK;
 }
 
+
 static int
 normalize_address (void *cls, const struct GNUNET_PeerIdentity *h, void *k)
 {
@@ -758,6 +776,7 @@
   return GNUNET_OK;
 }
 
+
 /**
  * Normalize avg_value to a range of values between [1.0, 2.0]
  * based on min max values currently known.
@@ -826,6 +845,7 @@
   }
 }
 
+
 /**
  * Update and normalize atsi performance information
  *
@@ -835,10 +855,10 @@
  * @param atsi_count the number of atsi information in the array
  */
 void
-GAS_normalization_normalize_property (
-    struct GNUNET_CONTAINER_MultiPeerMap *addresses,
-    struct ATS_Address *address, const struct GNUNET_ATS_Information *atsi,
-    uint32_t atsi_count)
+GAS_normalization_normalize_property (struct GNUNET_CONTAINER_MultiPeerMap 
*addresses,
+                                      struct ATS_Address *address,
+                                      const struct GNUNET_ATS_Information 
*atsi,
+                                      uint32_t atsi_count)
 {
   struct Property *cur_prop;
   int c1;
@@ -847,11 +867,13 @@
   uint32_t current_val;
   unsigned int existing_properties[] = GNUNET_ATS_QualityProperties;
 
-  GNUNET_assert(NULL != address);
-  GNUNET_assert(NULL != atsi);
+  GNUNET_assert (NULL != address);
+  GNUNET_assert (NULL != atsi);
 
-  LOG(GNUNET_ERROR_TYPE_DEBUG, "Updating %u elements for peer `%s'\n",
-      atsi_count, GNUNET_i2s (&address->peer));
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Updating %u elements for peer `%s'\n",
+       atsi_count,
+       GNUNET_i2s (&address->peer));
 
   for (c1 = 0; c1 < atsi_count; c1++)
   {
@@ -883,6 +905,7 @@
   }
 }
 
+
 static void
 free_client (struct PreferenceClient *pc)
 {
@@ -898,12 +921,12 @@
   GNUNET_free(pc);
 }
 
+
 /**
  * A performance client disconnected
  *
  * @param client the client
  */
-
 void
 GAS_normalization_preference_client_disconnect (void *client)
 {
@@ -922,6 +945,7 @@
   free_client (c_cur);
 }
 
+
 /**
  * Start the normalization component
  *
@@ -963,6 +987,7 @@
   return;
 }
 
+
 /**
  * Free a peer
  *
@@ -983,6 +1008,7 @@
   return GNUNET_OK;
 }
 
+
 /**
  * Stop the normalization component and free all items
  */




reply via email to

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