From: Christian Grothoff Date: Thu, 27 Sep 2012 19:36:14 +0000 (+0000) Subject: -converting more places to use STRINGS_relative_time_to_string X-Git-Tag: initial-import-from-subversion-38251~11616 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9cefd9c5522797b132749ca7d99a930007d28347;p=oweals%2Fgnunet.git -converting more places to use STRINGS_relative_time_to_string --- diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index 21e86c770..c860a810c 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c @@ -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, diff --git a/src/datacache/perf_datacache.c b/src/datacache/perf_datacache.c index fd3891116..10289ec68 100644 --- a/src/datacache/perf_datacache.c +++ b/src/datacache/perf_datacache.c @@ -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", diff --git a/src/datacache/plugin_datacache_sqlite.c b/src/datacache/plugin_datacache_sqlite.c index 26792e1fb..b51423de2 100644 --- a/src/datacache/plugin_datacache_sqlite.c +++ b/src/datacache/plugin_datacache_sqlite.c @@ -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; diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index e85c3cae7..69d7b873e 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c @@ -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); diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c index 0b82b7d1f..04da6e930 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c @@ -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) diff --git a/src/nat/nat.c b/src/nat/nat.c index 80d0fc2bd..eeafc5b97 100644 --- a/src/nat/nat.c +++ b/src/nat/nat.c @@ -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; } diff --git a/src/util/bandwidth.c b/src/util/bandwidth.c index 9d679493a..60cb50529 100644 --- a/src/util/bandwidth.c +++ b/src/util/bandwidth.c @@ -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; } diff --git a/src/util/client.c b/src/util/client.c index 73cca2383..337eade0c 100644 --- a/src/util/client.c +++ b/src/util/client.c @@ -27,11 +27,8 @@ * 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); diff --git a/src/util/scheduler.c b/src/util/scheduler.c index abf351701..6231a1987 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -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; diff --git a/src/util/server.c b/src/util/server.c index 663661fea..7ecb98c64 100644 --- a/src/util/server.c +++ b/src/util/server.c @@ -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)); } diff --git a/src/util/test_crypto_ksk.c b/src/util/test_crypto_ksk.c index f0e4337ef..40bf435ef 100644 --- a/src/util/test_crypto_ksk.c +++ b/src/util/test_crypto_ksk.c @@ -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; } diff --git a/src/util/test_crypto_rsa.c b/src/util/test_crypto_rsa.c index 0113b7ad0..fcaf78612 100644 --- a/src/util/test_crypto_rsa.c +++ b/src/util/test_crypto_rsa.c @@ -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; }