findutils-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Findutils-patches] [PATCH 2/5] maint: avoid warnings from GCC 6.2.1


From: Bernhard Voelker
Subject: [Findutils-patches] [PATCH 2/5] maint: avoid warnings from GCC 6.2.1
Date: Thu, 2 Feb 2017 00:17:20 +0100

buildcmd.c: In function 'bc_push_arg':
buildcmd.c:362:11: error: this 'if' clause does not guard... 
[-Werror=misleading-indentation]
           if (ctl->replace_pat
           ^~
buildcmd.c:366:13: note: ...this statement, but the latter is misleadingly 
indented as if it is guarded by the 'if'
             bc_do_exec (ctl, state);
             ^~~~~~~~~~
pred.c: In function 'print_optlist':
pred.c:1328:46: error: format '%ld' expects argument of type 'long int', but 
argument 3 has type 'long unsigned int' [-Werror=format=]
           fprintf (fp, "[real success rate %ld/%ld", p->perf.successes, 
p->perf.visits);
                                              ^
pred.c:1328:50: error: format '%ld' expects argument of type 'long int', but 
argument 4 has type 'long unsigned int' [-Werror=format=]
           fprintf (fp, "[real success rate %ld/%ld", p->perf.successes, 
p->perf.visits);
                                                  ^
print.c: In function 'scan_for_digit_differences':
print.c:449:46: error: logical 'or' of equal expressions [-Werror=logical-op]
           if (!isdigit ((unsigned char)q[i]) || !isdigit ((unsigned char)q[i]))
                                              ^~
In file included from ../gl/lib/gettext.h:25:0,
                 from locate.c:86:
locate.c: In function 'dolocate':
locate.c:1873:28: error: format '%d' expects argument of type 'int', but 
argument 5 has type 'unsigned int' [-Werror=format=]
                          _("warning: database %s is more than %d %s old 
(actual age is %.1f %s)"),
                            ^
locate.c:1873:26: note: in expansion of macro '_'
                          _("warning: database %s is more than %d %s old 
(actual age is %.1f %s)"),
                          ^
locate.c:1927:18: error: format '%ld' expects argument of type 'long int', but 
argument 2 has type 'long unsigned int' [-Werror=format=]
       printf ("%ld\n", found);
                  ^
cc1: all warnings being treated as errors

* find/pred.c (print_optlist): Use %lu for unsigned long int.
* find/print.c (scan_for_digit_differences): Check p[i] too rather than
q[i] two times.
* lib/buildcmd.c (bc_push_arg): Fix indentation.
* locate/locate.c (dolocate): Use %u format for unsigned int.
Use %lu format for unsigned long int.
---
 find/pred.c     | 2 +-
 find/print.c    | 2 +-
 lib/buildcmd.c  | 2 +-
 locate/locate.c | 4 ++--
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/find/pred.c b/find/pred.c
index c064606d..45cbb1c4 100644
--- a/find/pred.c
+++ b/find/pred.c
@@ -1325,7 +1325,7 @@ print_optlist (FILE *fp, const struct predicate *p)
       fprintf (fp, " [est success rate %.4g] ", p->est_success_rate);
       if (options.debug_options & DebugSuccessRates)
         {
-          fprintf (fp, "[real success rate %ld/%ld", p->perf.successes, 
p->perf.visits);
+          fprintf (fp, "[real success rate %lu/%lu", p->perf.successes, 
p->perf.visits);
           if (p->perf.visits)
             {
               double real_rate = (double)p->perf.successes / 
(double)p->perf.visits;
diff --git a/find/print.c b/find/print.c
index 4c43f57f..20351572 100644
--- a/find/print.c
+++ b/find/print.c
@@ -446,7 +446,7 @@ scan_for_digit_differences (const char *p, const char *q,
     {
       if (p[i] != q[i])
         {
-          if (!isdigit ((unsigned char)q[i]) || !isdigit ((unsigned char)q[i]))
+          if (!isdigit ((unsigned char)p[i]) || !isdigit ((unsigned char)q[i]))
             return false;
 
           if (!seen)
diff --git a/lib/buildcmd.c b/lib/buildcmd.c
index b0677d70..bc2f260d 100644
--- a/lib/buildcmd.c
+++ b/lib/buildcmd.c
@@ -363,7 +363,7 @@ bc_push_arg (struct buildcmd_control *ctl,
               || (ctl->exit_if_size_exceeded &&
                   (ctl->lines_per_exec || ctl->args_per_exec)))
             error (EXIT_FAILURE, 0, _("argument list too long"));
-            bc_do_exec (ctl, state);
+          bc_do_exec (ctl, state);
         }
       if (bc_argc_limit_reached (initial_args, ctl, state))
             bc_do_exec (ctl, state);
diff --git a/locate/locate.c b/locate/locate.c
index c4a97140..14b18ad8 100644
--- a/locate/locate.c
+++ b/locate/locate.c
@@ -1870,7 +1870,7 @@ dolocate (int argc, char **argv, int secure_db_fd)
                   /* For example:
                      warning: database `fred' is more than 8 days old (actual 
age is 10 days)*/
                   error (0, 0,
-                         _("warning: database %s is more than %d %s old 
(actual age is %.1f %s)"),
+                         _("warning: database %s is more than %u %s old 
(actual age is %.1f %s)"),
                          quotearg_n_style (0,  locale_quoting_style, db_name),
                          warn_number_units,              _(warn_name_units),
                          (age/(double)SECONDS_PER_UNIT), _(warn_name_units));
@@ -1924,7 +1924,7 @@ dolocate (int argc, char **argv, int secure_db_fd)
 
   if (just_count)
     {
-      printf ("%ld\n", found);
+      printf ("%lu\n", found);
     }
 
   if (found || (use_limit && (limits.limit==0)) || stats )
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]