-converting more places to use STRINGS_relative_time_to_string
authorChristian Grothoff <christian@grothoff.org>
Thu, 27 Sep 2012 19:36:14 +0000 (19:36 +0000)
committerChristian Grothoff <christian@grothoff.org>
Thu, 27 Sep 2012 19:36:14 +0000 (19:36 +0000)
12 files changed:
src/arm/gnunet-service-arm.c
src/datacache/perf_datacache.c
src/datacache/plugin_datacache_sqlite.c
src/hostlist/hostlist-client.c
src/hostlist/hostlist-server.c
src/nat/nat.c
src/util/bandwidth.c
src/util/client.c
src/util/scheduler.c
src/util/server.c
src/util/test_crypto_ksk.c
src/util/test_crypto_rsa.c

index 21e86c7707140242957189a3d0732eddff34b336..c860a810ccc3bb0e5b894c80c0727980ca503ea8 100644 (file)
@@ -903,8 +903,9 @@ delayed_restart_task (void *cls,
   }
   if (lowestRestartDelay.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will restart process in %llums\n",
-               (unsigned long long) lowestRestartDelay.rel_value);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+               "Will restart process in %s\n",
+               GNUNET_STRINGS_relative_time_to_string (lowestRestartDelay, GNUNET_YES));
     child_restart_task =
       GNUNET_SCHEDULER_add_delayed_with_priority (lowestRestartDelay,
                                                  GNUNET_SCHEDULER_PRIORITY_IDLE, 
index fd3891116d79e659e24b77ec8a21420766de7944..10289ec68bbdd693b1d3b16608b62acb05cd7f98 100644 (file)
@@ -88,9 +88,8 @@ run (void *cls, char *const *args, const char *cfgfile,
     k = n;
   }
   FPRINTF (stderr, "%s",  "\n");
-  FPRINTF (stdout, "Stored %u items in %llums\n", ITERATIONS,
-           (unsigned long long)
-           GNUNET_TIME_absolute_get_duration (start).rel_value);
+  FPRINTF (stdout, "Stored %u items in %s\n", ITERATIONS,
+          GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES));
   GNUNET_snprintf (gstr, sizeof (gstr), "DATACACHE-%s", plugin_name);
   GAUGER (gstr, "Time to PUT item in datacache",
           GNUNET_TIME_absolute_get_duration (start).rel_value / ITERATIONS,
@@ -107,10 +106,9 @@ run (void *cls, char *const *args, const char *cfgfile,
   }
   FPRINTF (stderr, "%s",  "\n");
   FPRINTF (stdout,
-           "Found %u/%u items in %llums (%u were deleted during storage processing)\n",
+           "Found %u/%u items in %s (%u were deleted during storage processing)\n",
            found, ITERATIONS,
-           (unsigned long long)
-           GNUNET_TIME_absolute_get_duration (start).rel_value,
+           GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES),
            ITERATIONS - found);
   if (found > 0)
     GAUGER (gstr, "Time to GET item from datacache",
index 26792e1fbef7b0d314823aa1a513205f82ce833e..b51423de22b2628782f414e1bf38d341e858c461 100644 (file)
@@ -107,10 +107,10 @@ sqlite_plugin_put (void *cls, const struct GNUNET_HashCode * key, size_t size,
   int64_t dval;
 
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Processing `%s' of %u bytes with key `%4s' and expiration %llums\n",
+       "Processing `%s' of %u bytes with key `%4s' and expiration %s\n",
        "PUT", (unsigned int) size, GNUNET_h2s (key),
        (unsigned long long)
-       GNUNET_TIME_absolute_get_remaining (discard_time).rel_value);
+       GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_remaining (discard_time), GNUNET_YES));
   dval = (int64_t) discard_time.abs_value;
   if (dval < 0)
     dval = INT64_MAX;
index e85c3cae7a4dca6fdaa3877002b36b70740287e7..69d7b873e8f706a2faf1b90eee59216f27da10c5 100644 (file)
@@ -370,10 +370,8 @@ get_bootstrap_server ()
       GNUNET_CONFIGURATION_get_value_string (cfg, "HOSTLIST", "SERVERS",
                                              &servers))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _
-                ("No `%s' specified in `%s' configuration, will not bootstrap.\n"),
-                "SERVERS", "HOSTLIST");
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+                              "hostlist", "SERVERS");
     return NULL;
   }
 
@@ -391,10 +389,8 @@ get_bootstrap_server ()
   }
   if (urls == 0)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _
-                ("No `%s' specified in `%s' configuration, will not bootstrap.\n"),
-                "SERVERS", "HOSTLIST");
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+                              "hostlist", "SERVERS");
     GNUNET_free (servers);
     return NULL;
   }
@@ -499,10 +495,10 @@ checked_add (uint64_t val1, uint64_t val2)
   temp = val1 + val2;
   if (temp < val1)
     return maxv;
-  else
-    return temp;
+  return temp;
 }
 
+
 /**
  * Subtract val2 from val1 with underflow check
  * @param val1 value 1
@@ -514,10 +510,10 @@ checked_sub (uint64_t val1, uint64_t val2)
 {
   if (val1 <= val2)
     return 0;
-  else
-    return (val1 - val2);
+  return (val1 - val2);
 }
 
+
 /**
  * Method to check if  a URI is in hostlist linked list
  * @param uri uri to check
@@ -647,6 +643,7 @@ update_hostlist ()
     stat_use_bootstrap = GNUNET_YES;
 }
 
+
 /**
  * Clean up the state from the task that downloaded the
  * hostlist and schedule the next task.
@@ -998,6 +995,7 @@ task_download_dispatcher (void *cls,
   }
 }
 
+
 /**
  * Task that checks if we should try to download a hostlist.
  * If so, we initiate the download, otherwise we schedule
@@ -1042,10 +1040,9 @@ task_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     once = 1;
   }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              _
-              ("Have %u/%u connections.  Will consider downloading hostlist in %llums\n"),
+              _("Have %u/%u connections.  Will consider downloading hostlist in %s\n"),
               stat_connection_count, MIN_CONNECTIONS,
-              (unsigned long long) delay.rel_value);
+              GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
   ti_check_download = GNUNET_SCHEDULER_add_delayed (delay, &task_check, NULL);
 }
 
@@ -1081,12 +1078,11 @@ task_hostlist_saving (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   ti_saving_task = GNUNET_SCHEDULER_NO_TASK;
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
     return;
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Scheduled saving of hostlists\n"));
   save_hostlist_file (GNUNET_NO);
 
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              _("Hostlists will be saved to file again in %llums\n"),
-              (unsigned long long) SAVING_INTERVALL.rel_value);
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Hostlists will be saved to file again in %s\n",
+             GNUNET_STRINGS_relative_time_to_string(SAVING_INTERVALL, GNUNET_YES));
   ti_saving_task =
       GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving,
                                     NULL);
@@ -1214,7 +1210,6 @@ handler_advertisement (void *cls, const struct GNUNET_PeerIdentity *peer,
 }
 
 
-
 /**
  * Continuation called by the statistics code once
  * we go the stat.  Initiates hostlist download scheduling.
@@ -1238,13 +1233,14 @@ static int
 process_stat (void *cls, const char *subsystem, const char *name,
               uint64_t value, int is_persistent)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-              _("Initial time between hostlist downloads is %llums\n"),
-              (unsigned long long) value);
   hostlist_delay.rel_value = value;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+              "Initial time between hostlist downloads is %s\n",
+              GNUNET_STRINGS_relative_time_to_string (hostlist_delay, GNUNET_YES));
   return GNUNET_OK;
 }
 
+
 /**
  * Method to load persistent hostlist file during hostlist client startup
  */
@@ -1268,10 +1264,8 @@ load_hostlist_file ()
       GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE",
                                                &filename))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _
-                ("No `%s' specified in `%s' configuration, cannot load hostlists from file.\n"),
-                "HOSTLISTFILE", "HOSTLIST");
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+                              "hostlist", "HOSTLISTFILE");
     return;
   }
 
@@ -1280,7 +1274,7 @@ load_hostlist_file ()
   if (GNUNET_NO == GNUNET_DISK_file_test (filename))
   {
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                _("Hostlist file `%s' is not existing\n"), filename);
+                _("Hostlist file `%s' does not exist\n"), filename);
     GNUNET_free (filename);
     return;
   }
@@ -1357,10 +1351,8 @@ save_hostlist_file (int shutdown)
       GNUNET_CONFIGURATION_get_value_filename (cfg, "HOSTLIST", "HOSTLISTFILE",
                                                &filename))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
-                _
-                ("No `%s' specified in `%s' configuration, cannot save hostlists to file.\n"),
-                "HOSTLISTFILE", "HOSTLIST");
+    GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+                              "hostlist", "HOSTLISTFILE");
     return;
   }
   if (GNUNET_SYSERR == GNUNET_DISK_directory_create_for_file (filename))
@@ -1423,6 +1415,7 @@ save_hostlist_file (int shutdown)
   GNUNET_free (filename);
 }
 
+
 /**
  * Start downloading hostlists from hostlist servers as necessary.
  */
@@ -1469,9 +1462,9 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c,
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 _("Learning is enabled on this peer\n"));
     load_hostlist_file ();
-    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
-                _("Hostlists will be saved to file again in  %llums\n"),
-                (unsigned long long) SAVING_INTERVALL.rel_value);
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                "Hostlists will be saved to file again in %s\n",
+               GNUNET_STRINGS_relative_time_to_string (SAVING_INTERVALL, GNUNET_YES));
     ti_saving_task =
         GNUNET_SCHEDULER_add_delayed (SAVING_INTERVALL, &task_hostlist_saving,
                                       NULL);
index 0b82b7d1f7c2381abc12c2098083c7feaea2dbdb..04da6e930c05a8639439ec2a3fe7e3b3dee43e29 100644 (file)
@@ -180,7 +180,7 @@ host_processor (void *cls, const struct GNUNET_PeerIdentity *peer,
   {
     GNUNET_assert (NULL == peer);
     pitr = NULL;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 _("Error in communication with PEERINFO service: %s\n"),
                 err_msg);
     return;
@@ -270,7 +270,7 @@ access_handler_callback (void *cls, struct MHD_Connection *connection,
   if (NULL == *con_cls)
   {
     (*con_cls) = &dummy;
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Sending 100 CONTINUE reply\n"));
+    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending 100 CONTINUE reply\n");
     return MHD_YES;             /* send 100 continue */
   }
   if (0 != *upload_data_size)
@@ -421,7 +421,7 @@ process_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Peerinfo is notifying us to rebuild our hostlist\n");
   if (NULL != err_msg)
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 _("Error in communication with PEERINFO service: %s\n"),
                err_msg);
   if (NULL != pitr)
index 80d0fc2bd456d75a6d4e624af24edb9459fd45be..eeafc5b97f9a71ef7252d66d8c48fe820021afae 100644 (file)
@@ -1107,9 +1107,9 @@ GNUNET_NAT_register (const struct GNUNET_CONFIGURATION_Handle *cfg, int is_tcp,
   if ((h->internal_address != NULL) &&
       (inet_pton (AF_INET, h->internal_address, &in_addr) != 1))
   {
-    LOG (GNUNET_ERROR_TYPE_WARNING, "nat",
-         _("Malformed %s `%s' given in configuration!\n"), "INTERNAL_ADDRESS",
-         h->internal_address);
+    GNUNET_log_config_invalid (GNUNET_ERROR_TYPE_WARNING, 
+                              "nat", "INTERNAL_ADDRESS",
+                              _("malformed"));
     GNUNET_free (h->internal_address);
     h->internal_address = NULL;
   }
index 9d679493ae05fd6274c88c1a6c34b614bfccd04c..60cb50529f316d7a3dfcf085b286025cb6cb5fbb 100644 (file)
@@ -24,8 +24,7 @@
  * @author Christian Grothoff
  */
 #include "platform.h"
-#include "gnunet_bandwidth_lib.h"
-#include "gnunet_server_lib.h"
+#include "gnunet_util_lib.h"
 
 
 #define LOG(kind,...) GNUNET_log_from (kind, "util-bandwidth", __VA_ARGS__)
@@ -83,9 +82,9 @@ GNUNET_BANDWIDTH_value_get_available_until (struct GNUNET_BANDWIDTH_Value32NBO
 
   b = ntohl (bps.value__);
   LOG (GNUNET_ERROR_TYPE_DEBUG,
-       "Bandwidth has %llu bytes available until deadline in %llums\n",
+       "Bandwidth has %llu bytes available until deadline in %s\n",
        (unsigned long long) ((b * deadline.rel_value + 500LL) / 1000LL),
-       deadline.rel_value);
+       GNUNET_STRINGS_relative_time_to_string (deadline, GNUNET_YES));
   return (b * deadline.rel_value + 500LL) / 1000LL;
 }
 
index 73cca2383c197a1843f09b7a3cccea91bd39f81b..337eade0cc945639820f5a40b8e082906e6ec236 100644 (file)
  * connections between clients and service providers.
  */
 #include "platform.h"
-#include "gnunet_common.h"
-#include "gnunet_client_lib.h"
 #include "gnunet_protocols.h"
-#include "gnunet_server_lib.h"
-#include "gnunet_scheduler_lib.h"
+#include "gnunet_util_lib.h"
 
 
 /**
@@ -955,9 +952,9 @@ client_delayed_retry (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                                   (th->client->back_off, 2),
                                   GNUNET_TIME_UNIT_SECONDS);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Transmission failed %u times, trying again in %llums.\n",
+         "Transmission failed %u times, trying again in %s.\n",
          MAX_ATTEMPTS - th->attempts_left,
-         (unsigned long long) delay.rel_value);
+         GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
     th->reconnect_task =
         GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th);
     return;
@@ -1028,9 +1025,9 @@ client_notify (void *cls, size_t size, void *buf)
                                   (client->back_off, 2),
                                   GNUNET_TIME_UNIT_SECONDS);
     LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Transmission failed %u times, trying again in %llums.\n",
+         "Transmission failed %u times, trying again in %s.\n",
          MAX_ATTEMPTS - th->attempts_left,
-         (unsigned long long) delay.rel_value);
+         GNUNET_STRINGS_relative_time_to_string (delay, GNUNET_YES));
     client->th = th;
     th->reconnect_task =
         GNUNET_SCHEDULER_add_delayed (delay, &client_delayed_retry, th);
index abf3517010ba386b27b15b30a5787bda985a88b2..6231a198753efe280b689c330c6e91797a0d15f3 100644 (file)
@@ -577,10 +577,10 @@ run_ready (struct GNUNET_NETWORK_FDSet *rs, struct GNUNET_NETWORK_FDSet *ws)
     if (GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value >
         DELAY_THRESHOLD.rel_value)
     {
-      LOG (GNUNET_ERROR_TYPE_ERROR, "Task %llu took %llums to be scheduled\n",
-           pos->id,
-           (unsigned long long)
-           GNUNET_TIME_absolute_get_duration (pos->start_time).rel_value);
+      LOG (GNUNET_ERROR_TYPE_DEBUG, 
+          "Task %llu took %s to be scheduled\n",
+           (unsigned long long) pos->id,
+           GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (pos->start_time), GNUNET_YES));
     }
 #endif
     tc.reason = pos->reason;
index 663661fea06f77a693203f179a9ed92265a30b17..7ecb98c64559eed7defd45da3711dc2b7203a0d0 100644 (file)
@@ -832,11 +832,9 @@ warn_no_receive_done (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                                     &warn_no_receive_done, client);
   if (0 == (GNUNET_SCHEDULER_REASON_SHUTDOWN & tc->reason))
     LOG (GNUNET_ERROR_TYPE_WARNING,
-         _
-         ("Processing code for message of type %u did not call GNUNET_SERVER_receive_done after %llums\n"),
+         _("Processing code for message of type %u did not call `GNUNET_SERVER_receive_done' after %s\n"),
          (unsigned int) client->warn_type,
-         (unsigned long long)
-         GNUNET_TIME_absolute_get_duration (client->warn_start).rel_value);
+         GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (client->warn_start), GNUNET_YES));
 }
 
 
index f0e4337ef6fb5d34c752f41d8c0de3d07a6e7950..40bf435efa07772324306f768207d3b93e3f7234 100644 (file)
@@ -167,9 +167,10 @@ testEncryptDecrypt (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey)
       continue;
     }
   }
-  printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", ITER,
-          (unsigned long long)
-          GNUNET_TIME_absolute_get_duration (start).rel_value, ok);
+  printf ("%d RSA encrypt/decrypt operations %s (%d failures)\n", 
+         ITER,
+         GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES), 
+         ok);
   if (ok == 0)
     return GNUNET_OK;
   else
@@ -217,9 +218,9 @@ testSignVerify (struct GNUNET_CRYPTO_RsaPrivateKey *hostkey)
       continue;
     }
   }
-  printf ("%d RSA sign/verify operations %llums\n", ITER,
-          (unsigned long long)
-          GNUNET_TIME_absolute_get_duration (start).rel_value);
+  printf ("%d RSA sign/verify operations %s\n", 
+         ITER,
+         GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES));
   return ok;
 }
 
index 0113b7ad06dd06ebba09ca60b60202abe6e80a97..fcaf78612ec1938282889f94341174ca0bb31c63 100644 (file)
@@ -81,9 +81,10 @@ testEncryptDecrypt ()
       continue;
     }
   }
-  printf ("%d RSA encrypt/decrypt operations %llums (%d failures)\n", ITER,
-          (unsigned long long)
-          GNUNET_TIME_absolute_get_duration (start).rel_value, ok);
+  printf ("%d RSA encrypt/decrypt operations %s (%d failures)\n", 
+         ITER,
+          GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES), 
+         ok);
   if (ok == 0)
     return GNUNET_OK;
   return GNUNET_SYSERR;
@@ -169,9 +170,10 @@ testEncryptDecryptSK ()
       continue;
     }
   }
-  printf ("%d RSA encrypt/decrypt SK operations %llums (%d failures)\n", ITER,
-          (unsigned long long)
-          GNUNET_TIME_absolute_get_duration (start).rel_value, ok);
+  printf ("%d RSA encrypt/decrypt SK operations %s (%d failures)\n", 
+         ITER,
+          GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES), 
+         ok);
   if (ok != 0)
     return GNUNET_SYSERR;
   return GNUNET_OK;
@@ -220,9 +222,8 @@ testSignVerify ()
       continue;
     }
   }
-  printf ("%d RSA sign/verify operations %llums\n", ITER,
-          (unsigned long long)
-          GNUNET_TIME_absolute_get_duration (start).rel_value);
+  printf ("%d RSA sign/verify operations %s\n", ITER,
+          GNUNET_STRINGS_relative_time_to_string (GNUNET_TIME_absolute_get_duration (start), GNUNET_YES));
   return ok;
 }