Hello maintainers,

building from git with GCC 7 is a bit more complited again, as gcc 7 is more
-Werror sensitive.  I've attached a patch that looks like worth having
pushed to me.

There's one remaining issue:

        list.c: In function ‘tartime’:
        list.c:1053:33: error: ‘%02d’ directive writing between 2 and 11 bytes 
into a region of size between 4 and 29 [-Werror=format-overflow=]
            sprintf (buffer, "%04ld-%02d-%02d %02d:%02d:%02d",
                                         ^~~~
        list.c:1053:4: note: ‘sprintf’ output between 20 and 81 bytes into a 
destination of size 37
            sprintf (buffer, "%04ld-%02d-%02d %02d:%02d:%02d",
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
              tm->tm_hour, tm->tm_min, tm->tm_sec);
              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        list.c:1059:31: error: ‘%02d’ directive writing between 2 and 11 bytes 
into a region of size between 4 and 29 [-Werror=format-overflow=]
          sprintf (buffer, "%04ld-%02d-%02d %02d:%02d",
                                       ^~~~
        list.c:1059:2: note: ‘sprintf’ output between 17 and 69 bytes into a 
destination of size 37
          sprintf (buffer, "%04ld-%02d-%02d %02d:%02d",
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            tm->tm_year + 1900L, tm->tm_mon + 1, tm->tm_mday,
            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            tm->tm_hour, tm->tm_min);
            ~~~~~~~~~~~~~~~~~~~~~~~~

This is IMO false positive, as long as we can expect that if
"utc_option ? gmtime (&s) : localtime (&s);" succeeds then it returns
valid 'struct tm'.

The warning can be silenced by e.g. min(0, max(9999, tm->tm_year)) hacks or by
ignoring the warning globally/locally by pragma.  Please silence this warning,
or suggest your preferred fix and I'll have a look at it.

Plus, there's gnulib issue [1].

[1] https://www.mail-archive.com/bug-gnulib@gnu.org/msg34265.html

Pavel
>From b0cda9f0926baf723858809dfbf7899fdd54b111 Mon Sep 17 00:00:00 2001
From: Pavel Raiskup <prais...@redhat.com>
Date: Fri, 8 Sep 2017 08:26:01 +0200
Subject: [PATCH] Fix some GCC warnings

* configure.ac: Use -Wimplicit-fallthrough=1.
* lib/wordsplit.c (wordsplit_perror): Fix missing break.
* src/sparse.c (sparse_scan_file): Explicitly mention fallback.
---
 configure.ac    | 1 +
 lib/wordsplit.c | 1 +
 src/sparse.c    | 1 +
 4 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index e89ed1d..fac44fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -164,6 +164,7 @@ if test "$gl_gcc_warnings" = yes; then
   
   gl_WARN_ADD([-fdiagnostics-show-option])
   gl_WARN_ADD([-funit-at-a-time])
+  gl_WARN_ADD([-Wimplicit-fallthrough=1]) # Be more tolerant to fall-through comments
   
 
   AC_SUBST([WARN_CFLAGS])
diff --git a/lib/wordsplit.c b/lib/wordsplit.c
index 07d0f8a..f2ecada 100644
--- a/lib/wordsplit.c
+++ b/lib/wordsplit.c
@@ -1584,6 +1584,7 @@ wordsplit_perror (struct wordsplit *wsp)
 
     case WRDSE_NOSUPP:
       wsp->ws_error (_("command substitution is not yet supported"));
+      break;
 
     case WRDSE_USAGE:
       wsp->ws_error (_("invalid wordsplit usage"));
diff --git a/src/sparse.c b/src/sparse.c
index b3a3fd3..5bd2b01 100644
--- a/src/sparse.c
+++ b/src/sparse.c
@@ -361,6 +361,7 @@ sparse_scan_file (struct tar_sparse_file *file)
       /* fall back to "raw" for this and all other files */
       hole_detection = HOLE_DETECTION_RAW;
 #endif
+      /* fallthrough */
     case HOLE_DETECTION_RAW:
       if (sparse_scan_file_raw (file))
 	return true;
-- 
2.13.5

Reply via email to