From 07019e218c1c10cf22d942b462b96dbd1944450f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 4 Jan 2018 17:50:50 +0100 Subject: fix more warnings --- src/util/disk.c | 27 +++++++++++++--- src/util/getopt_helpers.c | 79 +++++++++++++++++++++++++++++------------------ src/util/scheduler.c | 14 ++++----- 3 files changed, 78 insertions(+), 42 deletions(-) (limited to 'src/util') diff --git a/src/util/disk.c b/src/util/disk.c index d536ec897..8fd689070 100644 --- a/src/util/disk.c +++ b/src/util/disk.c @@ -1324,6 +1324,7 @@ static int remove_helper (void *unused, const char *fn) { + (void) unused; (void) GNUNET_DISK_directory_remove (fn); return GNUNET_OK; } @@ -1396,6 +1397,7 @@ GNUNET_DISK_file_copy (const char *src, uint64_t pos; uint64_t size; size_t len; + ssize_t sret; struct GNUNET_DISK_FileHandle *in; struct GNUNET_DISK_FileHandle *out; @@ -1425,9 +1427,17 @@ GNUNET_DISK_file_copy (const char *src, len = COPY_BLK_SIZE; if (len > size - pos) len = size - pos; - if (len != GNUNET_DISK_file_read (in, buf, len)) + sret = GNUNET_DISK_file_read (in, + buf, + len); + if ( (sret < 0) || + (len != (size_t) sret) ) goto FAIL; - if (len != GNUNET_DISK_file_write (out, buf, len)) + sret = GNUNET_DISK_file_write (out, + buf, + len); + if ( (sret < 0) || + (len != (size_t) sret) ) goto FAIL; pos += len; } @@ -1457,7 +1467,8 @@ GNUNET_DISK_filename_canonicalize (char *fn) { c = *idx; - if (c == '/' || c == '\\' || c == ':' || c == '*' || c == '?' || c == '"' || + if (c == '/' || c == '\\' || c == ':' || + c == '*' || c == '?' || c == '"' || c == '<' || c == '>' || c == '|') { *idx = '_'; @@ -2236,18 +2247,24 @@ create_selectable_pipe (PHANDLE read_pipe_ptr, PHANDLE write_pipe_ptr, * @return handle to the new pipe, NULL on error */ struct GNUNET_DISK_PipeHandle * -GNUNET_DISK_pipe (int blocking_read, int blocking_write, int inherit_read, int inherit_write) +GNUNET_DISK_pipe (int blocking_read, + int blocking_write, + int inherit_read, + int inherit_write) { #ifndef MINGW int fd[2]; int ret; int eno; + (void) inherit_read; + (void) inherit_write; ret = pipe (fd); if (ret == -1) { eno = errno; - LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "pipe"); + LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, + "pipe"); errno = eno; return NULL; } diff --git a/src/util/getopt_helpers.c b/src/util/getopt_helpers.c index c3d0e4c7c..c836c9055 100644 --- a/src/util/getopt_helpers.c +++ b/src/util/getopt_helpers.c @@ -46,6 +46,8 @@ print_version (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, { const char *version = scls; + (void) option; + (void) value; printf ("%s v%s\n", ctx->binaryName, version); @@ -104,6 +106,8 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, const struct GNUNET_GETOPT_CommandLineOption *opt; const struct GNUNET_OS_ProjectData *pd; + (void) option; + (void) value; if (NULL != about) { printf ("%s\n%s\n", ctx->binaryOptions, gettext (about)); @@ -112,7 +116,7 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, } i = 0; opt = ctx->allOptions; - while (opt[i].description != NULL) + while (NULL != opt[i].description) { if (opt[i].shortName == '\0') printf (" "); @@ -120,7 +124,7 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, printf (" -%c, ", opt[i].shortName); printf ("--%s", opt[i].name); slen = 8 + strlen (opt[i].name); - if (opt[i].argumentHelp != NULL) + if (NULL != opt[i].argumentHelp) { printf ("=%s", opt[i].argumentHelp); slen += 1 + strlen (opt[i].argumentHelp); @@ -144,7 +148,7 @@ format_help (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, OUTER: while (ml - p > 78 - slen) { - for (j = p + 78 - slen; j > p; j--) + for (j = p + 78 - slen; j > (int) p; j--) { if (isspace ((unsigned char) trans[j])) { @@ -227,6 +231,9 @@ increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, { unsigned int *val = scls; + (void) ctx; + (void) option; + (void) value; (*val)++; return GNUNET_OK; } @@ -243,9 +250,9 @@ increment_value (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, */ struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_increment_uint (char shortName, - const char *name, - const char *description, - unsigned int *val) + const char *name, + const char *description, + unsigned int *val) { struct GNUNET_GETOPT_CommandLineOption clo = { .shortName = shortName, @@ -302,6 +309,9 @@ set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, { int *val = scls; + (void) ctx; + (void) option; + (void) value; *val = 1; return GNUNET_OK; } @@ -319,9 +329,9 @@ set_one (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, */ struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_flag (char shortName, - const char *name, - const char *description, - int *val) + const char *name, + const char *description, + int *val) { struct GNUNET_GETOPT_CommandLineOption clo = { .shortName = shortName, @@ -357,6 +367,8 @@ set_string (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, { char **val = scls; + (void) ctx; + (void) option; GNUNET_assert (NULL != value); GNUNET_free_non_null (*val); *val = GNUNET_strdup (value); @@ -436,6 +448,8 @@ set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, { char **val = scls; + (void) ctx; + (void) option; GNUNET_assert (NULL != value); GNUNET_free_non_null (*val); *val = GNUNET_STRINGS_filename_expand (value); @@ -454,10 +468,10 @@ set_filename (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, */ struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_filename (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - char **str) + const char *name, + const char *argumentHelp, + const char *description, + char **str) { struct GNUNET_GETOPT_CommandLineOption clo = { .shortName = shortName, @@ -538,6 +552,7 @@ set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, { unsigned long long *val = scls; + (void) ctx; if (1 != SSCANF (value, "%llu", val)) @@ -562,10 +577,10 @@ set_ulong (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, */ struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_ulong (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - unsigned long long *val) + const char *name, + const char *argumentHelp, + const char *description, + unsigned long long *val) { struct GNUNET_GETOPT_CommandLineOption clo = { .shortName = shortName, @@ -601,7 +616,8 @@ set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, const char *value) { struct GNUNET_TIME_Relative *val = scls; - + + (void) ctx; if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_relative (value, val)) @@ -627,10 +643,10 @@ set_relative_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, */ struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_relative_time (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - struct GNUNET_TIME_Relative *val) + const char *name, + const char *argumentHelp, + const char *description, + struct GNUNET_TIME_Relative *val) { struct GNUNET_GETOPT_CommandLineOption clo = { .shortName = shortName, @@ -667,6 +683,7 @@ set_absolute_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, { struct GNUNET_TIME_Absolute *val = scls; + (void) ctx; if (GNUNET_OK != GNUNET_STRINGS_fancy_time_to_absolute (value, val)) @@ -692,10 +709,10 @@ set_absolute_time (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, */ struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_absolute_time (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - struct GNUNET_TIME_Absolute *val) + const char *name, + const char *argumentHelp, + const char *description, + struct GNUNET_TIME_Absolute *val) { struct GNUNET_GETOPT_CommandLineOption clo = { .shortName = shortName, @@ -732,6 +749,7 @@ set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, { unsigned int *val = scls; + (void) ctx; if (1 != SSCANF (value, "%u", val)) @@ -756,10 +774,10 @@ set_uint (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, */ struct GNUNET_GETOPT_CommandLineOption GNUNET_GETOPT_option_uint (char shortName, - const char *name, - const char *argumentHelp, - const char *description, - unsigned int *val) + const char *name, + const char *argumentHelp, + const char *description, + unsigned int *val) { struct GNUNET_GETOPT_CommandLineOption clo = { .shortName = shortName, @@ -813,6 +831,7 @@ set_base32 (struct GNUNET_GETOPT_CommandLineProcessorContext *ctx, { struct Base32Context *bc = scls; + (void) ctx; if (GNUNET_OK != GNUNET_STRINGS_string_to_data (value, strlen (value), diff --git a/src/util/scheduler.c b/src/util/scheduler.c index b96e4e6c4..992f8fdff 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -513,14 +513,14 @@ static void dump_backtrace (struct GNUNET_SCHEDULER_Task *t) { #if EXECINFO - unsigned int i; - - for (i = 0; i < t->num_backtrace_strings; i++) + for (unsigned int i = 0; i < t->num_backtrace_strings; i++) LOG (GNUNET_ERROR_TYPE_WARNING, - "Task %p trace %u: %s\n", - t, - i, - t->backtrace_strings[i]); + "Task %p trace %u: %s\n", + t, + i, + t->backtrace_strings[i]); +#else + (void) t; #endif } -- cgit v1.2.3 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 From 89e31e95490e3221f464b870e608f01cc72389d1 Mon Sep 17 00:00:00 2001 From: lurchi Date: Thu, 4 Jan 2018 20:27:19 +0100 Subject: simplify driver_add_multiple --- src/util/scheduler.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/util') diff --git a/src/util/scheduler.c b/src/util/scheduler.c index 7bd19df7a..fecbc0de5 100644 --- a/src/util/scheduler.c +++ b/src/util/scheduler.c @@ -848,8 +848,7 @@ init_fd_info (struct GNUNET_SCHEDULER_Task *t, * @a driver_func on it, or -1 if no updating not desired. */ static void -driver_add_multiple (struct GNUNET_SCHEDULER_Task *t, - enum GNUNET_SCHEDULER_EventType et) +driver_add_multiple (struct GNUNET_SCHEDULER_Task *t) { struct GNUNET_SCHEDULER_FdInfo *fdi; int success = GNUNET_YES; @@ -860,10 +859,7 @@ driver_add_multiple (struct GNUNET_SCHEDULER_Task *t, success = scheduler_driver->add (scheduler_driver->cls, t, fdi) && success; - if (et != -1) - { - fdi->et = et; - } + fdi->et = GNUNET_SCHEDULER_ET_NONE; } if (GNUNET_YES != success) { @@ -1381,7 +1377,7 @@ add_without_sets (struct GNUNET_TIME_Relative delay, GNUNET_CONTAINER_DLL_insert (pending_head, pending_tail, t); - driver_add_multiple (t, GNUNET_SCHEDULER_ET_NONE); + driver_add_multiple (t); max_priority_added = GNUNET_MAX (max_priority_added, t->priority); init_backtrace (t); @@ -1823,7 +1819,7 @@ GNUNET_SCHEDULER_add_select (enum GNUNET_SCHEDULER_Priority prio, GNUNET_CONTAINER_DLL_insert (pending_head, pending_tail, t); - driver_add_multiple (t, GNUNET_SCHEDULER_ET_NONE); + driver_add_multiple (t); max_priority_added = GNUNET_MAX (max_priority_added, t->priority); LOG (GNUNET_ERROR_TYPE_DEBUG, -- cgit v1.2.3 From 6f1e5e46c284bf5f172404e49b0861912a09493a Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 4 Jan 2018 22:21:58 +0100 Subject: add assertion --- src/fs/fs_dirmetascan.c | 29 ++++++++++++++++++++--------- src/gns/gnunet-service-gns_resolver.c | 3 ++- src/util/network.c | 7 ++++--- 3 files changed, 26 insertions(+), 13 deletions(-) (limited to 'src/util') diff --git a/src/fs/fs_dirmetascan.c b/src/fs/fs_dirmetascan.c index 8a3e37b49..e904b9092 100644 --- a/src/fs/fs_dirmetascan.c +++ b/src/fs/fs_dirmetascan.c @@ -211,9 +211,9 @@ expand_tree (struct GNUNET_FS_ShareTreeItem *parent, chld->short_filename[slen-1] = '\0'; chld->is_directory = is_directory; if (NULL != parent) - GNUNET_CONTAINER_DLL_insert (parent->children_head, - parent->children_tail, - chld); + GNUNET_CONTAINER_DLL_insert (parent->children_head, + parent->children_tail, + chld); return chld; } @@ -259,7 +259,8 @@ process_helper_msgs (void *cls, size_t left; #if 0 - fprintf (stderr, "DMS parses %u-byte message of type %u\n", + fprintf (stderr, + "DMS parses %u-byte message of type %u\n", (unsigned int) ntohs (msg->size), (unsigned int) ntohs (msg->type)); #endif @@ -277,11 +278,18 @@ process_helper_msgs (void *cls, filename, GNUNET_NO, GNUNET_FS_DIRSCANNER_FILE_START); if (NULL == ds->toplevel) + { ds->toplevel = expand_tree (ds->pos, - filename, GNUNET_NO); + filename, + GNUNET_NO); + } else + { + GNUNET_assert (NULL != ds->pos); (void) expand_tree (ds->pos, - filename, GNUNET_NO); + filename, + GNUNET_NO); + } return GNUNET_OK; case GNUNET_MESSAGE_TYPE_FS_PUBLISH_HELPER_PROGRESS_DIRECTORY: if (filename[left-1] != '\0') @@ -303,7 +311,8 @@ process_helper_msgs (void *cls, filename, GNUNET_YES, GNUNET_FS_DIRSCANNER_FILE_START); ds->pos = expand_tree (ds->pos, - filename, GNUNET_YES); + filename, + GNUNET_YES); if (NULL == ds->toplevel) ds->toplevel = ds->pos; return GNUNET_OK; @@ -360,11 +369,13 @@ process_helper_msgs (void *cls, break; } ds->progress_callback (ds->progress_callback_cls, - filename, GNUNET_YES, + filename, + GNUNET_YES, GNUNET_FS_DIRSCANNER_EXTRACT_FINISHED); if (0 < left) { - ds->pos->meta = GNUNET_CONTAINER_meta_data_deserialize (end, left); + ds->pos->meta = GNUNET_CONTAINER_meta_data_deserialize (end, + left); if (NULL == ds->pos->meta) { GNUNET_break (0); diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index ba71e21fa..54d7ff94b 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c @@ -2362,7 +2362,8 @@ GNS_resolver_lookup (const struct GNUNET_CRYPTO_EcdsaPublicKey *zone, uint32_t record_type, const char *name, enum GNUNET_GNS_LocalOptions options, - GNS_ResultProcessor proc, void *proc_cls) + GNS_ResultProcessor proc, + void *proc_cls) { struct GNS_ResolverHandle *rh; diff --git a/src/util/network.c b/src/util/network.c index cf5ef3e00..d7059a057 100644 --- a/src/util/network.c +++ b/src/util/network.c @@ -1326,9 +1326,10 @@ GNUNET_NETWORK_fdset_handle_set (struct GNUNET_NETWORK_FDSet *fds, #else int fd; - GNUNET_DISK_internal_file_handle_ (h, - &fd, - sizeof (int)); + GNUNET_assert (GNUNET_OK == + GNUNET_DISK_internal_file_handle_ (h, + &fd, + sizeof (int))); FD_SET (fd, &fds->sds); fds->nsds = GNUNET_MAX (fd + 1, -- cgit v1.2.3