The attached contains:

 * [PATCH 1/5] maint: avoid unused-macros warning from GCC 7
 * [PATCH 2/5] maint: avoid implicit-fallthrough warnings from GCC 7
 * [PATCH 3/5] maint: add die.h; avoid missing-fallthrough warnings
 * [PATCH 4/5] maint: avoid unused-but-set-variable, unused-parameter
 * [PATCH 5/5] maint: document the https change in NEWS

Have a nice day,
Berny
>From 3876904855478f7fda64d14f02035d8eaa57a527 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <m...@bernhard-voelker.de>
Date: Thu, 2 Nov 2017 13:02:38 +0100
Subject: [PATCH 1/5] maint: avoid unused-macros warning from GCC 7

GCC-7.2.1 on openSUSE-Tumbleweed complains:
  listfile.c:56:0: error: macro "HAVE_MAJOR" is not used \
  [-Werror=unused-macros]
  #define HAVE_MAJOR

* listfile.c (major,minor): Avoid the temporary #define HAVE_MAJOR
by using #else's.
---
 lib/listfile.c | 23 +++++++++--------------
 1 file changed, 9 insertions(+), 14 deletions(-)

diff --git a/lib/listfile.c b/lib/listfile.c
index 4f9462b3..ff730691 100644
--- a/lib/listfile.c
+++ b/lib/listfile.c
@@ -49,21 +49,16 @@
 /* Since major is a function on SVR4, we can't use `ifndef major'.  */
 #ifdef MAJOR_IN_MKDEV
 #include <sys/mkdev.h>
-#define HAVE_MAJOR
-#endif
-#ifdef MAJOR_IN_SYSMACROS
-#include <sys/sysmacros.h>
-#define HAVE_MAJOR
-#endif
-
-#ifdef major                    /* Might be defined in sys/types.h.  */
-#define HAVE_MAJOR
-#endif
-#ifndef HAVE_MAJOR
-#define major(dev)  (((dev) >> 8) & 0xff)
-#define minor(dev)  ((dev) & 0xff)
+#else
+#  ifdef MAJOR_IN_SYSMACROS
+#    include <sys/sysmacros.h>
+#  else
+#    ifndef major                    /* Might be defined in sys/types.h.  */
+#      define major(dev)  (((dev) >> 8) & 0xff)
+#      define minor(dev)  ((dev) & 0xff)
+#    endif
+#  endif
 #endif
-#undef HAVE_MAJOR
 
 #if ENABLE_NLS
 # include <libintl.h>
-- 
2.14.3


>From a7e7526798c9d53b2a2ce67654e6d452cf9f1253 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <m...@bernhard-voelker.de>
Date: Thu, 2 Nov 2017 13:18:38 +0100
Subject: [PATCH 2/5] maint: avoid implicit-fallthrough warnings from GCC 7

Avoid the new warnings GCC 7 gives with the
"-Werror=implicit-fallthrough=" compiler option.
Since version 7, GCC requires fallthrough switch/cases to be
marked by the appropriate attribute.

* lib/system.h: Add new header file defining the FALLTHROUGH macro.
* lib/Makefile.am (libfind_a_SOURCES): Reference it.
* find/print.c (do_fprintf): Use the new macro.
* xargs/xargs.c (read_line): Likewise.
(xargs_do_exec): For error(3), GCC 7 doesn't know that the function
does not return, and would complain about falling through into the
following case.  Temporarily add an abort call - this will be fixed
with another commit.
---
 find/print.c    | 11 ++++-------
 lib/Makefile.am |  3 ++-
 lib/system.h    | 43 +++++++++++++++++++++++++++++++++++++++++++
 xargs/xargs.c   |  6 +++++-
 4 files changed, 54 insertions(+), 9 deletions(-)
 create mode 100644 lib/system.h

diff --git a/find/print.c b/find/print.c
index 02785ea2..b820333e 100644
--- a/find/print.c
+++ b/find/print.c
@@ -44,6 +44,7 @@
 #include "xalloc.h"
 
 /* find-specific headers. */
+#include "system.h"
 #include "defs.h"
 #include "print.h"
 
@@ -951,13 +952,9 @@ do_fprintf (struct format_val *dest,
                 checked_fprintf (dest, segment->text, g->gr_name);
                 break;
               }
-            else
-              {
-                /* Do nothing. */
-                /*FALLTHROUGH*/
-              }
+            /* else fallthru */
           }
-          /*FALLTHROUGH*/ /*...sometimes, so 'G' case.*/
+          FALLTHROUGH; /*...sometimes, so 'G' case.*/
 
         case 'G':               /* GID number */
           /* UNTRUSTED, probably unexploitable */
@@ -1167,7 +1164,7 @@ do_fprintf (struct format_val *dest,
               }
             /* else fallthru */
           }
-          /* FALLTHROUGH*/ /* .. to case U */
+          FALLTHROUGH; /* .. to case U */
 
         case 'U':               /* UID number */
           /* UNTRUSTED, probably unexploitable */
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 739f2ceb..7686d565 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -56,7 +56,8 @@ libfind_a_SOURCES = \
 	splitstring.c \
 	splitstring.h \
 	bugreports.c \
-	bugreports.h
+	bugreports.h \
+	system.h
 
 EXTRA_DIST = unused-result.h check-regexprops.sh
 SUFFIXES =
diff --git a/lib/system.h b/lib/system.h
new file mode 100644
index 00000000..15658bda
--- /dev/null
+++ b/lib/system.h
@@ -0,0 +1,43 @@
+/* system.h -- system-dependent definitions for findutils
+
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation, either version 3 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <https://www.gnu.org/licenses/>.
+*/
+#if !defined SYSTEM_H
+# define SYSTEM_H
+
+/* FALLTHROUGH
+ * Since GCC7, the "-Werror=implicit-fallthrough=" option requires
+ * fallthrough cases to be marked as such via:
+ *     __attribute__ ((__fallthrough__))
+ * Usage:
+ *   switch (c)
+ *     {
+ *     case 1:
+ *       doOne();
+ *       FALLTHROUGH;
+ *     case 2:
+ *     ...
+ *     }
+ */
+#ifndef FALLTHROUGH
+# if __GNUC__ < 7
+#  define FALLTHROUGH ((void) 0)
+# else
+#  define FALLTHROUGH __attribute__ ((__fallthrough__))
+# endif
+#endif
+
+#endif /* SYSTEM_H */
diff --git a/xargs/xargs.c b/xargs/xargs.c
index 321b5ba0..20fb75a6 100644
--- a/xargs/xargs.c
+++ b/xargs/xargs.c
@@ -67,6 +67,7 @@
 #include "bugreports.h"
 #include "findutils-version.h"
 #include "gcc-function-attributes.h"
+#include "system.h"
 
 #if ENABLE_NLS
 # include <libintl.h>
@@ -904,7 +905,7 @@ read_line (void)
 	  if (ISSPACE (c))
 	    continue;
 	  state = NORM;
-	  /* aaahhhh....  */
+	  FALLTHROUGH;  /* aaahhhh....  */
 
 	case NORM:
 	  if (c == '\n')
@@ -1277,6 +1278,9 @@ xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char *
 	{
 	case -1:
 	  error (EXIT_FAILURE, errno, _("cannot fork"));
+	  /* error(EXIT_FAILURE, ...) does not return, but tell GCC 7 that
+	     we don't fall through here; fixed with another commit.  */
+	  abort();
 
 	case 0:		/* Child.  */
 	  {
-- 
2.14.3


>From 0da12e14025da4d022cf9ae6453fc86596f31237 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <m...@bernhard-voelker.de>
Date: Fri, 3 Nov 2017 00:41:27 +0100
Subject: [PATCH 3/5] maint: add die.h; avoid missing-fallthrough warnings
 after error w/ GCC 7

* lib/die.h (die): New file/function from grep/coreutils.
Note: this file will probably be migrated to gnulib.
* lib/Makefile.am (libfind_a_SOURCES): Reference it.
* xargs/xargs.c: Include die.h.
(xargs_do_exec): Use die in place of error-nonzero, thus allowing
the compiler to know that we do not fall through into the 0 (child)
case.
---
 lib/Makefile.am |  3 ++-
 lib/die.h       | 32 ++++++++++++++++++++++++++++++++
 xargs/xargs.c   |  8 +++-----
 3 files changed, 37 insertions(+), 6 deletions(-)
 create mode 100644 lib/die.h

diff --git a/lib/Makefile.am b/lib/Makefile.am
index 7686d565..f0d6640e 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -57,7 +57,8 @@ libfind_a_SOURCES = \
 	splitstring.h \
 	bugreports.c \
 	bugreports.h \
-	system.h
+	system.h \
+	die.h
 
 EXTRA_DIST = unused-result.h check-regexprops.sh
 SUFFIXES =
diff --git a/lib/die.h b/lib/die.h
new file mode 100644
index 00000000..0b329266
--- /dev/null
+++ b/lib/die.h
@@ -0,0 +1,32 @@
+/* Report an error and exit.
+   Copyright (C) 2017 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+   02110-1301, USA.  */
+
+/* Borrowed from coreutils.  */
+#ifndef DIE_H
+# define DIE_H
+
+# include <error.h>
+# include <stdbool.h>
+# include <verify.h>
+
+/* Like 'error (STATUS, ...)', except STATUS must be a nonzero constant.
+   This may pacify the compiler or help it generate better code.  */
+# define die(status, ...) \
+  verify_expr (status, (error (status, __VA_ARGS__), assume (false)))
+
+#endif /* DIE_H */
diff --git a/xargs/xargs.c b/xargs/xargs.c
index 20fb75a6..8ef91dee 100644
--- a/xargs/xargs.c
+++ b/xargs/xargs.c
@@ -63,8 +63,9 @@
 
 /* find headers. */
 #include "buildcmd.h"
-#include "fdleak.h"
+#include "die.h"
 #include "bugreports.h"
+#include "fdleak.h"
 #include "findutils-version.h"
 #include "gcc-function-attributes.h"
 #include "system.h"
@@ -1277,10 +1278,7 @@ xargs_do_exec (struct buildcmd_control *ctl, void *usercontext, int argc, char *
       switch (child)
 	{
 	case -1:
-	  error (EXIT_FAILURE, errno, _("cannot fork"));
-	  /* error(EXIT_FAILURE, ...) does not return, but tell GCC 7 that
-	     we don't fall through here; fixed with another commit.  */
-	  abort();
+	  die (EXIT_FAILURE, errno, _("cannot fork"));
 
 	case 0:		/* Child.  */
 	  {
-- 
2.14.3


>From 7302d90616e69e839d5a01e093c14699a0f38dfa Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <m...@bernhard-voelker.de>
Date: Fri, 3 Nov 2017 01:10:36 +0100
Subject: [PATCH 4/5] maint: avoid unused-but-set-variable, unused-parameter
 warnings from GCC 7

GCC-7.2.1 complained about this occur during 'make check'.

* lib/regexprops.c (menu): Remove set-but-unused-variable 'options'.
* lib/test_splitstring.c (main): Avoid unused-parameter warnings
for 'argc' and 'argv'.
---
 lib/regexprops.c       | 4 ++--
 lib/test_splitstring.c | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/lib/regexprops.c b/lib/regexprops.c
index 048315e7..fcbdd5db 100644
--- a/lib/regexprops.c
+++ b/lib/regexprops.c
@@ -478,12 +478,12 @@ ignore (int ix, const unsigned int context)
 static void
 menu (unsigned int context)
 {
-  int i, options;
+  int i;
   const char *name;
 
   output ("@menu\n", 0);
   for (i=0;
-       options = get_regex_type_flags (i),
+       get_regex_type_flags (i),
 	 name=get_regex_type_name (i);
        ++i)
     {
diff --git a/lib/test_splitstring.c b/lib/test_splitstring.c
index b01b6b79..0feb089e 100644
--- a/lib/test_splitstring.c
+++ b/lib/test_splitstring.c
@@ -196,6 +196,9 @@ static void test_consecutive_empty (void)
 
 int main (int argc, char *argv[])
 {
+  (void) argc; /* pacify -Werror=unused-parameter */
+  (void) argv; /* pacify -Werror=unused-parameter */
+
   test_empty ();
   test_onefield ();
   test_not_colon ();
-- 
2.14.3


>From c15a51e515d021aa68c1ead211f9a59419e4bdbe Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <m...@bernhard-voelker.de>
Date: Wed, 8 Nov 2017 01:13:31 +0100
Subject: [PATCH 5/5] maint: document the https change in NEWS

* NEWS (Documentation Changes): Mention the switch from http to https
done in commit 2cb10332.
---
 NEWS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/NEWS b/NEWS
index 3e0b915e..cfd18b88 100644
--- a/NEWS
+++ b/NEWS
@@ -48,6 +48,8 @@ interactive application.  Added for compatibility with BSD.
 
 ** Documentation Changes
 
+Prefer https:// over http:// links where possible, e.g. for '*.gnu.org' servers.
+
 Some minor documentation improvements are listed in "Bug Fixes" below.
 
 ** Bug Fixes
-- 
2.14.3

Reply via email to