From 07019e218c1c10cf22d942b462b96dbd1944450f Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 4 Jan 2018 17:50:50 +0100 Subject: [PATCH] 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(-) 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 } -- 2.25.1