gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r11677 - in gnunet/src: core datastore fs testing transport


From: gnunet
Subject: [GNUnet-SVN] r11677 - in gnunet/src: core datastore fs testing transport util
Date: Fri, 11 Jun 2010 23:57:37 +0200

Author: grothoff
Date: 2010-06-11 23:57:37 +0200 (Fri, 11 Jun 2010)
New Revision: 11677

Modified:
   gnunet/src/core/gnunet-service-core.c
   gnunet/src/datastore/datastore.h
   gnunet/src/fs/fs_download.c
   gnunet/src/fs/gnunet-service-fs.c
   gnunet/src/fs/test_gnunet_service_fs_migration.c
   gnunet/src/fs/test_gnunet_service_fs_migration_data.conf
   gnunet/src/testing/testing_group.c
   gnunet/src/transport/gnunet-service-transport.c
   gnunet/src/util/time.c
Log:
use constants instead of casting -1

Modified: gnunet/src/core/gnunet-service-core.c
===================================================================
--- gnunet/src/core/gnunet-service-core.c       2010-06-11 21:41:10 UTC (rev 
11676)
+++ gnunet/src/core/gnunet-service-core.c       2010-06-11 21:57:37 UTC (rev 
11677)
@@ -1029,7 +1029,7 @@
       if (old_preference > n->current_preference) 
        {
          /* overflow; cap at maximum value */
-         n->current_preference = (unsigned long long) -1;
+         n->current_preference = ULLONG_MAX;
        }
       update_preference_sum (n->current_preference - old_preference);
 #if DEBUG_CORE_QUOTA
@@ -1545,7 +1545,7 @@
   while (GNUNET_YES == discard_low_prio)
     {
       min = NULL;
-      min_prio = -1;
+      min_prio = UINT_MAX;
       discard_low_prio = GNUNET_NO;
       /* calculate number of bytes available for transmission at time "t" */
       avail = GNUNET_BANDWIDTH_tracker_get_available 
(&n->available_send_window);
@@ -2014,7 +2014,7 @@
              (unsigned int) ntohl (n->bw_in.value__),
              GNUNET_i2s (&n->peer));
 #endif
-  ph->iv_seed = htonl (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 
-1));
+  ph->iv_seed = htonl (GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK, 
UINT32_MAX));
   ph->sequence_number = htonl (++n->last_sequence_number_sent);
   ph->inbound_bw_limit = n->bw_in;
   ph->timestamp = GNUNET_TIME_absolute_hton (GNUNET_TIME_absolute_get ());
@@ -2122,10 +2122,10 @@
   n->set_key_retry_frequency = INITIAL_SET_KEY_RETRY_FREQUENCY;
   n->bw_in = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT;
   n->bw_out = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT;
-  n->bw_out_internal_limit = GNUNET_BANDWIDTH_value_init ((uint32_t) - 1);
+  n->bw_out_internal_limit = GNUNET_BANDWIDTH_value_init (UINT32_MAX);
   n->bw_out_external_limit = GNUNET_CONSTANTS_DEFAULT_BW_IN_OUT;
   n->ping_challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
-                                                (uint32_t) - 1);
+                                                UINT32_MAX);
   neighbour_quota_update (n, NULL);
   consider_free_neighbour (n);
   return n;
@@ -2186,7 +2186,7 @@
 #endif
   /* bound queue size */
   discard_expired_messages (n);
-  min_prio = (unsigned int) -1;
+  min_prio = UINT32_MAX;
   min_prio_entry = NULL;
   min_prio_prev = NULL;
   queue_size = 0;
@@ -3641,8 +3641,8 @@
   if (bandwidth_target_out_bps > need_per_second)
     distributable = bandwidth_target_out_bps - need_per_second;
   share = distributable * pref_rel;
-  if (share + need_per_peer > ( (uint32_t)-1))
-    q_in = GNUNET_BANDWIDTH_value_init ((uint32_t) -1);
+  if (share + need_per_peer > UINT32_MAX)
+    q_in = GNUNET_BANDWIDTH_value_init (UINT32_MAX);
   else
     q_in = GNUNET_BANDWIDTH_value_init (need_per_peer + (uint32_t) share);
   /* check if we want to disconnect for good due to inactivity */

Modified: gnunet/src/datastore/datastore.h
===================================================================
--- gnunet/src/datastore/datastore.h    2010-06-11 21:41:10 UTC (rev 11676)
+++ gnunet/src/datastore/datastore.h    2010-06-11 21:57:37 UTC (rev 11677)
@@ -27,7 +27,7 @@
 #ifndef DATASTORE_H
 #define DATASTORE_H
 
-#define DEBUG_DATASTORE GNUNET_NO
+#define DEBUG_DATASTORE GNUNET_YES
 
 #include "gnunet_util_lib.h"
 

Modified: gnunet/src/fs/fs_download.c
===================================================================
--- gnunet/src/fs/fs_download.c 2010-06-11 21:41:10 UTC (rev 11676)
+++ gnunet/src/fs/fs_download.c 2010-06-11 21:57:37 UTC (rev 11677)
@@ -1647,7 +1647,8 @@
   struct GNUNET_FS_ProgressInfo pi;
   struct GNUNET_FS_DownloadContext *dc;
 
-  if (sr->download != NULL)
+  if ( (sr != NULL) &&
+       (sr->download != NULL) )
     {
       GNUNET_break (0);
       return NULL;

Modified: gnunet/src/fs/gnunet-service-fs.c
===================================================================
--- gnunet/src/fs/gnunet-service-fs.c   2010-06-11 21:41:10 UTC (rev 11676)
+++ gnunet/src/fs/gnunet-service-fs.c   2010-06-11 21:57:37 UTC (rev 11677)
@@ -2150,7 +2150,7 @@
   pr->irc = GNUNET_CORE_peer_change_preference (sched, cfg,
                                                &psc.target,
                                                
GNUNET_CONSTANTS_SERVICE_TIMEOUT, 
-                                               GNUNET_BANDWIDTH_value_init 
((uint32_t) -1 /* no limit */), 
+                                               GNUNET_BANDWIDTH_value_init 
(UINT32_MAX),
                                                DBLOCK_SIZE * 2, 
                                                (uint64_t) cp->inc_preference,
                                                &target_reservation_cb,
@@ -2348,7 +2348,8 @@
       if (pr->cp != NULL)
        {
          GNUNET_PEER_change_rc (prq->sender->last_p2p_replies
-                                [prq->sender->last_p2p_replies_woff % 
P2P_SUCCESS_LIST_SIZE], -1);
+                                [prq->sender->last_p2p_replies_woff % 
P2P_SUCCESS_LIST_SIZE], 
+                                -1);
          GNUNET_PEER_change_rc (pr->cp->pid, 1);
          prq->sender->last_p2p_replies
            [(prq->sender->last_p2p_replies_woff++) % P2P_SUCCESS_LIST_SIZE]
@@ -2515,7 +2516,7 @@
       reply->cont = &transmit_reply_continuation;
       reply->cont_cls = pr;
       reply->msize = msize;
-      reply->priority = (uint32_t) -1; /* send replies first! */
+      reply->priority = UINT32_MAX; /* send replies first! */
       pm = (struct PutMessage*) &reply[1];
       pm->header.type = htons (GNUNET_MESSAGE_TYPE_FS_PUT);
       pm->header.size = htons (msize);

Modified: gnunet/src/fs/test_gnunet_service_fs_migration.c
===================================================================
--- gnunet/src/fs/test_gnunet_service_fs_migration.c    2010-06-11 21:41:10 UTC 
(rev 11676)
+++ gnunet/src/fs/test_gnunet_service_fs_migration.c    2010-06-11 21:57:37 UTC 
(rev 11677)
@@ -244,6 +244,7 @@
                    "WARNING",
 #endif
                    NULL);
+  system ("netstat -ntpl");
   GNUNET_PROGRAM_run ((sizeof (argvx) / sizeof (char *)) - 1,
                       argvx, "test-gnunet-service-fs-migration",
                      "nohelp", options, &run, NULL);

Modified: gnunet/src/fs/test_gnunet_service_fs_migration_data.conf
===================================================================
--- gnunet/src/fs/test_gnunet_service_fs_migration_data.conf    2010-06-11 
21:41:10 UTC (rev 11676)
+++ gnunet/src/fs/test_gnunet_service_fs_migration_data.conf    2010-06-11 
21:57:37 UTC (rev 11677)
@@ -12,12 +12,13 @@
 [transport]
 PORT = 43465
 PLUGINS = tcp
-#DEBUG = YES
+DEBUG = YES
 
 [arm]
 PORT = 43466
 HOSTNAME = localhost
 DEFAULTSERVICES = fs
+OPTIONS = -L DEBUG
 
 [datastore]
 #DEBUG = YES

Modified: gnunet/src/testing/testing_group.c
===================================================================
--- gnunet/src/testing/testing_group.c  2010-06-11 21:41:10 UTC (rev 11676)
+++ gnunet/src/testing/testing_group.c  2010-06-11 21:57:37 UTC (rev 11677)
@@ -726,7 +726,7 @@
         {
           probability = pg->peers[i].num_connections / 
(double)previous_total_connections;
           random = ((double) 
GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK,
-                                                      (uint64_t)-1LL)) / ( 
(double) (uint64_t) -1LL);
+                                                      UINT64_MAX)) / ( 
(double) UINT64_MAX);
 #if VERBOSE_TESTING
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       "Considering connecting peer %d to peer %d\n",
@@ -820,7 +820,7 @@
       for (j = 0; j < connsPerPeer / 2; j++)
         {
           random = ((double) 
GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK,
-                                                     (uint64_t)-1LL)) / ( 
(double) (uint64_t) -1LL);
+                                                     UINT64_MAX) / ( (double) 
UINT64_MAX));
           if (random < percentage)
             {
               /* Connect to uniformly selected random peer */
@@ -1035,7 +1035,7 @@
                   probability = 1.0 / (distance * distance);
                   /* Choose a random value between 0 and 1 */
                  random = ((double) 
GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK,
-                                                             (uint64_t)-1LL)) 
/ ( (double) (uint64_t) -1LL);
+                                                             UINT64_MAX)) / ( 
(double) UINT64_MAX);
                   /* If random < probability, then connect the two nodes */
                   if (random < probability)
                     smallWorldConnections += proc (pg, j, k);
@@ -1086,7 +1086,7 @@
            inner_count++)
         {
           temp_rand = ((double) 
GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK,
-                                                        (uint64_t)-1LL)) / ( 
(double) (uint64_t) -1LL);
+                                                        UINT64_MAX)) / ( 
(double) UINT64_MAX);
 #if VERBOSE_TESTING
           GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                       _("rand is %f probability is %f\n"), temp_rand,
@@ -2077,7 +2077,7 @@
   uint32_t second_pos;
   GNUNET_HashCode first_hash;
   random_number = ((double) 
GNUNET_CRYPTO_random_u64(GNUNET_CRYPTO_QUALITY_WEAK,
-                   (uint64_t)-1LL)) / ( (double) (uint64_t) -1LL);
+                                                    UINT64_MAX)) / ( (double) 
UINT64_MAX);
   if (random_number < random_ctx->percentage)
   {
     GNUNET_assert(GNUNET_OK == 
GNUNET_CONTAINER_multihashmap_put(random_ctx->first->connect_peers_working_set, 
key, value, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));

Modified: gnunet/src/transport/gnunet-service-transport.c
===================================================================
--- gnunet/src/transport/gnunet-service-transport.c     2010-06-11 21:41:10 UTC 
(rev 11676)
+++ gnunet/src/transport/gnunet-service-transport.c     2010-06-11 21:57:37 UTC 
(rev 11677)
@@ -3132,7 +3132,7 @@
   va = GNUNET_malloc (sizeof (struct ValidationEntry) + peer_address->addrlen);
   va->transport_name = GNUNET_strdup (tp->short_name);
   va->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
-                                            (unsigned int) -1);
+                                            UINT_MAX);
   va->send_time = GNUNET_TIME_absolute_get();
   va->session = peer_address->session;
   if (peer_address->addr != NULL)
@@ -3690,7 +3690,7 @@
   chvc->ve_count++;
   va->transport_name = GNUNET_strdup (tname);
   va->challenge = GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_WEAK,
-                                            (unsigned int) -1);
+                                            UINT_MAX);
   va->send_time = GNUNET_TIME_absolute_get();
   va->addr = (const void*) &va[1];
   memcpy (&va[1], addr, addrlen);

Modified: gnunet/src/util/time.c
===================================================================
--- gnunet/src/util/time.c      2010-06-11 21:41:10 UTC (rev 11676)
+++ gnunet/src/util/time.c      2010-06-11 21:57:37 UTC (rev 11677)
@@ -84,7 +84,7 @@
 struct GNUNET_TIME_Relative
 GNUNET_TIME_relative_get_forever ()
 {
-  static struct GNUNET_TIME_Relative forever = { (uint64_t) - 1LL };
+  static struct GNUNET_TIME_Relative forever = { UINT64_MAX };
   return forever;
 }
 
@@ -94,7 +94,7 @@
 struct GNUNET_TIME_Absolute
 GNUNET_TIME_absolute_get_forever ()
 {
-  static struct GNUNET_TIME_Absolute forever = { (uint64_t) - 1LL };
+  static struct GNUNET_TIME_Absolute forever = { UINT64_MAX };
   return forever;
 }
 
@@ -108,7 +108,7 @@
 GNUNET_TIME_relative_to_absolute (struct GNUNET_TIME_Relative rel)
 {
   struct GNUNET_TIME_Absolute ret;
-  if (rel.value == (uint64_t) - 1LL)
+  if (rel.value == UINT64_MAX)
     return GNUNET_TIME_absolute_get_forever ();
   struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
   if (rel.value + now.value < rel.value)
@@ -196,7 +196,7 @@
 GNUNET_TIME_absolute_get_remaining (struct GNUNET_TIME_Absolute future)
 {
   struct GNUNET_TIME_Relative ret;
-  if (future.value == (uint64_t) - 1LL)
+  if (future.value == UINT64_MAX)
     return GNUNET_TIME_relative_get_forever ();
   struct GNUNET_TIME_Absolute now = GNUNET_TIME_absolute_get ();
   if (now.value > future.value)
@@ -217,7 +217,7 @@
                                      struct GNUNET_TIME_Absolute end)
 {
   struct GNUNET_TIME_Relative ret;
-  if (end.value == (uint64_t) - 1LL)
+  if (end.value == UINT64_MAX)
     return GNUNET_TIME_relative_get_forever ();
   if (end.value < start.value)
     return GNUNET_TIME_relative_get_zero ();
@@ -238,7 +238,7 @@
   struct GNUNET_TIME_Relative ret;
 
   now = GNUNET_TIME_absolute_get ();
-  GNUNET_assert (hence.value != (uint64_t) - 1LL);
+  GNUNET_assert (hence.value != UINT64_MAX);
   if (hence.value > now.value)
     return GNUNET_TIME_relative_get_zero ();
   ret.value = now.value - hence.value;
@@ -258,8 +258,8 @@
 {
   struct GNUNET_TIME_Absolute ret;
 
-  if ((start.value == (uint64_t) - 1LL) ||
-      (duration.value == (uint64_t) - 1LL))
+  if ((start.value == UINT64_MAX) ||
+      (duration.value == UINT64_MAX))
     return GNUNET_TIME_absolute_get_forever ();
   if (start.value + duration.value < start.value)
     {
@@ -382,7 +382,7 @@
 {
   struct GNUNET_TIME_Relative ret;
 
-  if ((a1.value == (uint64_t) - 1LL) || (a2.value == (uint64_t) - 1LL))
+  if ((a1.value == UINT64_MAX) || (a2.value == UINT64_MAX))
     return GNUNET_TIME_relative_get_forever ();
   if (a1.value + a2.value < a1.value)
     {
@@ -409,7 +409,7 @@
 
   if (a2.value >= a1.value)
     return GNUNET_TIME_relative_get_zero ();
-  if (a1.value == (uint64_t) - 1LL) 
+  if (a1.value == UINT64_MAX) 
     return GNUNET_TIME_relative_get_forever ();
   ret.value = a1.value - a2.value;
   return ret;




reply via email to

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