From 0baf3c103e55a8227de32a6d43afd749538bb1a5 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 4 Jan 2018 19:18:32 +0100 Subject: fix misc compiler warnings --- src/util/gnunet-config.c | 61 ++++++++++++++++++++++---------------- src/util/gnunet-ecc.c | 35 +++++++++++++++++----- src/util/gnunet-resolver.c | 30 +++++++++++++++---- src/util/gnunet-service-resolver.c | 10 +++++-- src/util/os_installation.c | 23 +++++++++----- src/util/os_priority.c | 1 + src/util/peer.c | 3 +- src/util/program.c | 1 + src/util/resolver_api.c | 15 ++++++++-- src/util/scheduler.c | 25 ++++++++++------ src/util/service.c | 4 ++- src/util/speedup.c | 1 + src/util/strings.c | 10 ++++--- 13 files changed, 153 insertions(+), 66 deletions(-) (limited to 'src/util') diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c index fb3b9ebf9..5f7d9fc0d 100644 --- a/src/util/gnunet-config.c +++ b/src/util/gnunet-config.c @@ -72,12 +72,17 @@ static int rewrite; * @param value value of the option */ static void -print_option (void *cls, const char *section, +print_option (void *cls, + const char *section, const char *option, const char *value) { + (void) cls; + (void) section; fprintf (stdout, - "%s = %s\n", option, value); + "%s = %s\n", + option, + value); } @@ -91,7 +96,10 @@ static void print_section_name (void *cls, const char *section) { - fprintf (stdout, "%s\n", section); + (void) cls; + fprintf (stdout, + "%s\n", + section); } @@ -112,6 +120,8 @@ run (void *cls, struct GNUNET_CONFIGURATION_Handle *out = NULL; struct GNUNET_CONFIGURATION_Handle *diff = NULL; + (void) cls; + (void) args; if (rewrite) { struct GNUNET_CONFIGURATION_Handle *def; @@ -221,36 +231,37 @@ run (void *cls, * @return 0 ok, 1 on error */ int -main (int argc, char *const *argv) +main (int argc, + char *const *argv) { struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_option_flag ('f', - "filename", - gettext_noop ("obtain option of value as a filename (with $-expansion)"), - &is_filename), + "filename", + gettext_noop ("obtain option of value as a filename (with $-expansion)"), + &is_filename), GNUNET_GETOPT_option_string ('s', - "section", - "SECTION", - gettext_noop ("name of the section to access"), - §ion), + "section", + "SECTION", + gettext_noop ("name of the section to access"), + §ion), GNUNET_GETOPT_option_string ('o', - "option", - "OPTION", - gettext_noop ("name of the option to access"), - &option), + "option", + "OPTION", + gettext_noop ("name of the option to access"), + &option), GNUNET_GETOPT_option_string ('V', - "value", - "VALUE", - gettext_noop ("value to set"), - &value), + "value", + "VALUE", + gettext_noop ("value to set"), + &value), GNUNET_GETOPT_option_flag ('S', - "list-sections", - gettext_noop ("print available configuration sections"), - &list_sections), + "list-sections", + gettext_noop ("print available configuration sections"), + &list_sections), GNUNET_GETOPT_option_flag ('w', - "rewrite", - gettext_noop ("write configuration file that only contains delta to defaults"), - &rewrite), + "rewrite", + gettext_noop ("write configuration file that only contains delta to defaults"), + &rewrite), GNUNET_GETOPT_OPTION_END }; if (GNUNET_OK != diff --git a/src/util/gnunet-ecc.c b/src/util/gnunet-ecc.c index 66a4bd3e9..59a100a8c 100644 --- a/src/util/gnunet-ecc.c +++ b/src/util/gnunet-ecc.c @@ -281,8 +281,10 @@ print_key (const char *filename) uint64_t fs; unsigned int total_hostkeys; unsigned int c; + ssize_t sret; - if (GNUNET_YES != GNUNET_DISK_file_test (filename)) + if (GNUNET_YES != + GNUNET_DISK_file_test (filename)) { fprintf (stderr, _("Hostkeys file `%s' not found\n"), @@ -291,7 +293,11 @@ print_key (const char *filename) } /* Check hostkey file size, read entire thing into memory */ - if (GNUNET_OK != GNUNET_DISK_file_size (filename, &fs, GNUNET_YES, GNUNET_YES)) + if (GNUNET_OK != + GNUNET_DISK_file_size (filename, + &fs, + GNUNET_YES, + GNUNET_YES)) fs = 0; if (0 == fs) { @@ -307,15 +313,22 @@ print_key (const char *filename) filename); return; } - fd = GNUNET_DISK_file_open (filename, GNUNET_DISK_OPEN_READ, - GNUNET_DISK_PERM_NONE); + fd = GNUNET_DISK_file_open (filename, + GNUNET_DISK_OPEN_READ, + GNUNET_DISK_PERM_NONE); if (NULL == fd) { - GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "open", filename); + GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, + "open", + filename); return; } hostkeys_data = GNUNET_malloc (fs); - if (fs != GNUNET_DISK_file_read (fd, hostkeys_data, fs)) + sret = GNUNET_DISK_file_read (fd, + hostkeys_data, + fs); + if ( (sret < 0) || + (fs != (size_t) sret) ) { fprintf (stderr, _("Could not read hostkey file: %s\n"), @@ -351,15 +364,21 @@ print_key (const char *filename) /** * Main function that will be run by the scheduler. * - * @param cls closure + * @param cls closure, NULL * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ static void -run (void *cls, char *const *args, const char *cfgfile, +run (void *cls, + char *const *args, + const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { + (void) cls; + (void) cfgfile; + (void) cfg; + if (print_examples_flag) { print_examples (); diff --git a/src/util/gnunet-resolver.c b/src/util/gnunet-resolver.c index 7ffafee32..4954e0398 100644 --- a/src/util/gnunet-resolver.c +++ b/src/util/gnunet-resolver.c @@ -46,9 +46,12 @@ static void print_hostname (void *cls, const char *hostname) { + (void) cls; if (NULL == hostname) return; - FPRINTF (stdout, "%s\n", hostname); + FPRINTF (stdout, + "%s\n", + hostname); } @@ -60,11 +63,17 @@ print_hostname (void *cls, * @param addrlen length of the address */ static void -print_sockaddr (void *cls, const struct sockaddr *addr, socklen_t addrlen) +print_sockaddr (void *cls, + const struct sockaddr *addr, + socklen_t addrlen) { + (void) cls; if (NULL == addr) return; - FPRINTF (stdout, "%s\n", GNUNET_a2s (addr, addrlen)); + FPRINTF (stdout, + "%s\n", + GNUNET_a2s (addr, + addrlen)); } @@ -77,7 +86,9 @@ print_sockaddr (void *cls, const struct sockaddr *addr, socklen_t addrlen) * @param cfg configuration */ static void -run (void *cls, char *const *args, const char *cfgfile, +run (void *cls, + char *const *args, + const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { const struct sockaddr *sa; @@ -85,11 +96,18 @@ run (void *cls, char *const *args, const char *cfgfile, struct sockaddr_in v4; struct sockaddr_in6 v6; - if (args[0] == NULL) + (void) cls; + (void) cfgfile; + (void) cfg; + if (NULL == args[0]) return; if (! reverse) { - GNUNET_RESOLVER_ip_get (args[0], AF_UNSPEC, GET_TIMEOUT, &print_sockaddr, NULL); + GNUNET_RESOLVER_ip_get (args[0], + AF_UNSPEC, + GET_TIMEOUT, + &print_sockaddr, + NULL); return; } diff --git a/src/util/gnunet-service-resolver.c b/src/util/gnunet-service-resolver.c index d26bdd212..ccb592349 100644 --- a/src/util/gnunet-service-resolver.c +++ b/src/util/gnunet-service-resolver.c @@ -582,7 +582,7 @@ get_ip_from_hostname (struct GNUNET_SERVICE_Client *client, /** * Verify well-formedness of GET-message. * - * @param cls closure + * @param cls closure, unused * @param get the actual message * @return #GNUNET_OK if @a get is well-formed */ @@ -594,6 +594,7 @@ check_get (void *cls, int direction; int af; + (void) cls; size = ntohs (get->header.size) - sizeof (*get); direction = ntohl (get->direction); if (GNUNET_NO == direction) @@ -688,7 +689,7 @@ handle_get (void *cls, /** * Callback called when a client connects to the service. * - * @param cls closure for the service + * @param cls closure for the service, unused * @param c the new client that connected to the service * @param mq the message queue used to send messages to the client * @return @a c @@ -698,6 +699,9 @@ connect_cb (void *cls, struct GNUNET_SERVICE_Client *c, struct GNUNET_MQ_Handle *mq) { + (void) cls; + (void) mq; + return c; } @@ -714,6 +718,8 @@ disconnect_cb (void *cls, struct GNUNET_SERVICE_Client *c, void *internal_cls) { + (void) cls; + GNUNET_assert (c == internal_cls); } diff --git a/src/util/os_installation.c b/src/util/os_installation.c index 1226c5966..2e35de681 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2006-2016 GNUnet e.V. + Copyright (C) 2006-2018 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -152,14 +152,21 @@ get_path_from_proc_exe () ssize_t size; char *lep; - GNUNET_snprintf (fn, sizeof (fn), "/proc/%u/exe", getpid ()); - size = readlink (fn, lnk, sizeof (lnk) - 1); + GNUNET_snprintf (fn, + sizeof (fn), + "/proc/%u/exe", + getpid ()); + size = readlink (fn, + lnk, + sizeof (lnk) - 1); if (size <= 0) { - LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "readlink", fn); + LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, + "readlink", + fn); return NULL; } - GNUNET_assert (size < sizeof (lnk)); + GNUNET_assert ( ((size_t) size) < sizeof (lnk)); lnk[size] = '\0'; while ((lnk[size] != '/') && (size > 0)) size--; @@ -167,12 +174,13 @@ get_path_from_proc_exe () "/%s/libexec/", current_pd->project_dirname); /* test for being in lib/gnunet/libexec/ or lib/MULTIARCH/gnunet/libexec */ - if ( (size > strlen (lep)) && + if ( (((size_t) size) > strlen (lep)) && (0 == strcmp (lep, &lnk[size - strlen (lep)])) ) size -= strlen (lep) - 1; GNUNET_free (lep); - if ((size < 4) || (lnk[size - 4] != '/')) + if ( (size < 4) || + (lnk[size - 4] != '/') ) { /* not installed in "/bin/" -- binary path probably useless */ return NULL; @@ -903,6 +911,7 @@ GNUNET_OS_check_helper_binary (const char *binary, if (check_suid) { #ifndef MINGW + (void) params; if ( (0 != (statbuf.st_mode & S_ISUID)) && (0 == statbuf.st_uid) ) { diff --git a/src/util/os_priority.c b/src/util/os_priority.c index 2c4f7ca09..98998b520 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c @@ -154,6 +154,7 @@ GNUNET_OS_install_parent_control_handler (void *cls) struct GNUNET_DISK_FileHandle *control_pipe; uint64_t pipe_fd; + (void) cls; if (NULL != pch) { /* already done, we've been called twice... */ diff --git a/src/util/peer.c b/src/util/peer.c index b637dc229..b1c65fbcf 100644 --- a/src/util/peer.c +++ b/src/util/peer.c @@ -201,7 +201,8 @@ GNUNET_PEER_change_rc (GNUNET_PEER_Id id, int delta) return; GNUNET_assert (id < size); GNUNET_assert (table[id]->rc > 0); - GNUNET_assert ((delta >= 0) || (table[id]->rc >= -delta)); + GNUNET_assert ( (delta >= 0) || + (table[id]->rc >= (unsigned int) (-delta)) ); table[id]->rc += delta; if (0 == table[id]->rc) { diff --git a/src/util/program.c b/src/util/program.c index 233792387..9e3037b8b 100644 --- a/src/util/program.c +++ b/src/util/program.c @@ -74,6 +74,7 @@ struct CommandContext static void shutdown_task (void *cls) { + (void) cls; GNUNET_SPEEDUP_stop_ (); } diff --git a/src/util/resolver_api.c b/src/util/resolver_api.c index 84f541ba0..bd46b4fbb 100644 --- a/src/util/resolver_api.c +++ b/src/util/resolver_api.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - Copyright (C) 2009-2016 GNUnet e.V. + Copyright (C) 2009-2018 GNUnet e.V. GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -214,7 +214,8 @@ check_config () for (unsigned int i = 0; NULL != loopback[i]; i++) - if (0 == strcasecmp (loopback[i], hostname)) + if (0 == strcasecmp (loopback[i], + hostname)) { GNUNET_free (hostname); return GNUNET_OK; @@ -285,6 +286,7 @@ GNUNET_RESOLVER_disconnect () static void shutdown_task (void *cls) { + (void) cls; s_task = NULL; GNUNET_RESOLVER_disconnect (); backoff = GNUNET_TIME_UNIT_MILLISECONDS; @@ -387,10 +389,12 @@ static void mq_error_handler (void *cls, enum GNUNET_MQ_Error error) { + (void) cls; GNUNET_MQ_destroy (mq); mq = NULL; LOG (GNUNET_ERROR_TYPE_DEBUG, - "MQ error, reconnecting\n"); + "MQ error %d, reconnecting\n", + error); reconnect (); } @@ -449,6 +453,9 @@ static int check_response (void *cls, const struct GNUNET_MessageHeader *msg) { + (void) cls; + (void) msg; + /* implemented in #handle_response() for now */ return GNUNET_OK; } @@ -470,6 +477,7 @@ handle_response (void *cls, uint16_t size; char *nret; + (void) cls; GNUNET_assert (NULL != rh); size = ntohs (msg->size); if (size == sizeof (struct GNUNET_MessageHeader)) @@ -743,6 +751,7 @@ reconnect_task (void *cls) GNUNET_MQ_handler_end () }; + (void) cls; r_task = NULL; if (NULL == req_head) return; /* no work pending */ diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 992f8fdff..7bd19df7a 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -847,16 +847,19 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, * @param et the event type to be set in each FdInfo after calling * @a driver_func on it, or -1 if no updating not desired. */ -void driver_add_multiple (struct GNUNET_SCHEDULER_Task *t, - enum GNUNET_SCHEDULER_EventType et) +static void +driver_add_multiple (struct GNUNET_SCHEDULER_Task *t, + enum GNUNET_SCHEDULER_EventType et) { struct GNUNET_SCHEDULER_FdInfo *fdi; int success = GNUNET_YES; - for (int i = 0; i != t->fds_len; ++i) + for (unsigned int i = 0; i != t->fds_len; ++i) { fdi = &t->fds[i]; - success = scheduler_driver->add (scheduler_driver->cls, t, fdi) && success; + success = scheduler_driver->add (scheduler_driver->cls, + t, + fdi) && success; if (et != -1) { fdi->et = et; @@ -870,12 +873,13 @@ void driver_add_multiple (struct GNUNET_SCHEDULER_Task *t, } -void +static void shutdown_cb (void *cls) { char c; const struct GNUNET_DISK_FileHandle *pr; + (void) cls; pr = GNUNET_DISK_pipe_handle (shutdown_pipe_handle, GNUNET_DISK_PIPE_END_READ); GNUNET_assert (! GNUNET_DISK_handle_invalid (pr)); @@ -975,6 +979,8 @@ init_backtrace (struct GNUNET_SCHEDULER_Task *t) backtrace_symbols (backtrace_array, t->num_backtrace_strings); dump_backtrace (t); +#else + (void) t; #endif } @@ -1664,14 +1670,15 @@ extract_handles (struct GNUNET_SCHEDULER_Task *t, // in fdset must be handled separately const struct GNUNET_NETWORK_Handle **nhandles; const struct GNUNET_DISK_FileHandle **fhandles; - unsigned int nhandles_len, fhandles_len; - int sock; + unsigned int nhandles_len; + unsigned int fhandles_len; + (void) t; nhandles = NULL; fhandles = NULL; nhandles_len = 0; fhandles_len = 0; - for (sock = 0; sock != fdset->nsds; ++sock) + for (int sock = 0; sock != fdset->nsds; ++sock) { if (GNUNET_YES == GNUNET_NETWORK_fdset_test_native (fdset, sock)) { @@ -1969,7 +1976,7 @@ GNUNET_SCHEDULER_run_from_driver (struct GNUNET_SCHEDULER_Handle *sh) // FIXME: do we have to remove FdInfos from fds if they are not ready? tc.fds_len = pos->fds_len; tc.fds = pos->fds; - for (int i = 0; i != pos->fds_len; ++i) + for (unsigned int i = 0; i != pos->fds_len; ++i) { struct GNUNET_SCHEDULER_FdInfo *fdi = &pos->fds[i]; if (0 != (GNUNET_SCHEDULER_ET_IN & fdi->et)) diff --git a/src/util/service.c b/src/util/service.c index b4eb33caa..1156093f4 100644 --- a/src/util/service.c +++ b/src/util/service.c @@ -1978,7 +1978,7 @@ do_send (void *cls) GNUNET_MQ_impl_send_in_flight (client->mq); } client->msg_pos += ret; - if (left > ret) + if (left > (size_t) ret) { GNUNET_assert (NULL == client->drop_task); client->send_task @@ -2007,6 +2007,7 @@ service_mq_send (struct GNUNET_MQ_Handle *mq, { struct GNUNET_SERVICE_Client *client = impl_state; + (void) mq; if (NULL != client->drop_task) return; /* we're going down right now, do not try to send */ GNUNET_assert (NULL == client->send_task); @@ -2036,6 +2037,7 @@ service_mq_cancel (struct GNUNET_MQ_Handle *mq, { struct GNUNET_SERVICE_Client *client = impl_state; + (void) mq; GNUNET_assert (0 == client->msg_pos); client->msg = NULL; GNUNET_SCHEDULER_cancel (client->send_task); diff --git a/src/util/speedup.c b/src/util/speedup.c index c6a4cf678..f5e81f16b 100644 --- a/src/util/speedup.c +++ b/src/util/speedup.c @@ -42,6 +42,7 @@ do_speedup (void *cls) { static long long current_offset; + (void) cls; speedup_task = NULL; current_offset += delta.rel_value_us; GNUNET_TIME_set_offset (current_offset); diff --git a/src/util/strings.c b/src/util/strings.c index f554a9e83..4cfcd63b3 100644 --- a/src/util/strings.c +++ b/src/util/strings.c @@ -1069,11 +1069,13 @@ GNUNET_STRINGS_string_to_data (const char *enc, size_t enclen, * (if they weren't NULL). */ int -GNUNET_STRINGS_parse_uri (const char *path, char **scheme_part, - const char **path_part) +GNUNET_STRINGS_parse_uri (const char *path, + char **scheme_part, + const char **path_part) { size_t len; - int i, end; + size_t i; + int end; int pp_state = 0; const char *post_scheme_part = NULL; len = strlen (path); @@ -1082,7 +1084,7 @@ GNUNET_STRINGS_parse_uri (const char *path, char **scheme_part, switch (pp_state) { case 0: - if (path[i] == ':' && i > 0) + if ( (path[i] == ':') && (i > 0) ) { pp_state += 1; continue; -- cgit v1.2.3