[PATCH v3 4/4] md5sum: use kernel crypto API

2018-04-28 Thread Matteo Croce
Use AF_ALG for md5 too

Signed-off-by: Matteo Croce 
---
 lib/md5.c  | 18 +-
 modules/crypto/md5 |  6 +-
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/lib/md5.c b/lib/md5.c
index 68d00a6c7..307abbbe7 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -32,6 +32,10 @@
 #include 
 #include 
 
+#ifdef HAVE_LINUX_IF_ALG_H
+# include "af_alg.h"
+#endif
+
 #if USE_UNLOCKED_IO
 # include "unlocked-io.h"
 #endif
@@ -142,8 +146,20 @@ md5_stream (FILE *stream, void *resblock)
 {
   struct md5_ctx ctx;
   size_t sum;
+  char *buffer;
+
+#ifdef HAVE_LINUX_IF_ALG_H
+  int ret;
+
+  ret = afalg_stream(stream, resblock, "md5", MD5_DIGEST_SIZE);
+  if (!ret)
+  return 0;
+
+  if (ret == -EIO)
+  return 1;
+#endif
 
-  char *buffer = malloc (BLOCKSIZE + 72);
+  buffer = malloc (BLOCKSIZE + 72);
   if (!buffer)
 return 1;
 
diff --git a/modules/crypto/md5 b/modules/crypto/md5
index e5fb39ced..415cf0523 100644
--- a/modules/crypto/md5
+++ b/modules/crypto/md5
@@ -5,8 +5,11 @@ Files:
 lib/gl_openssl.h
 lib/md5.h
 lib/md5.c
+lib/af_alg.h
+lib/af_alg.c
 m4/gl-openssl.m4
 m4/md5.m4
+m4/linux-if-alg.m4
 
 Depends-on:
 extern-inline
@@ -15,9 +18,10 @@ stdint
 
 configure.ac:
 gl_MD5
+gl_LINUX_IF_ALG_H
 
 Makefile.am:
-lib_SOURCES += md5.c
+lib_SOURCES += md5.c af_alg.c
 
 Include:
 "md5.h"
-- 
2.14.3




[PATCH v3 3/4] sha512sum: use kernel crypto API

2018-04-28 Thread Matteo Croce
Use AF_ALG for sha384 and sha512 too

Signed-off-by: Matteo Croce 
---
 lib/sha512.c  | 32 ++--
 modules/crypto/sha512 |  6 +-
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/lib/sha512.c b/lib/sha512.c
index 8a6dd4e83..72e5fdd24 100644
--- a/lib/sha512.c
+++ b/lib/sha512.c
@@ -32,6 +32,10 @@
 #include 
 #include 
 
+#ifdef HAVE_LINUX_IF_ALG_H
+# include "af_alg.h"
+#endif
+
 #if USE_UNLOCKED_IO
 # include "unlocked-io.h"
 #endif
@@ -185,8 +189,20 @@ sha512_stream (FILE *stream, void *resblock)
 {
   struct sha512_ctx ctx;
   size_t sum;
+  char *buffer;
+
+#ifdef HAVE_LINUX_IF_ALG_H
+  int ret;
+
+  ret = afalg_stream(stream, resblock, "sha512", SHA512_DIGEST_SIZE);
+  if (!ret)
+  return 0;
+
+  if (ret == -EIO)
+  return 1;
+#endif
 
-  char *buffer = malloc (BLOCKSIZE + 72);
+  buffer = malloc (BLOCKSIZE + 72);
   if (!buffer)
 return 1;
 
@@ -256,8 +272,20 @@ sha384_stream (FILE *stream, void *resblock)
 {
   struct sha512_ctx ctx;
   size_t sum;
+  char *buffer;
+
+#ifdef HAVE_LINUX_IF_ALG_H
+  int ret;
+
+  ret = afalg_stream(stream, resblock, "sha384", SHA384_DIGEST_SIZE);
+  if (!ret)
+  return 0;
+
+  if (ret == -EIO)
+  return 1;
+#endif
 
-  char *buffer = malloc (BLOCKSIZE + 72);
+  buffer = malloc (BLOCKSIZE + 72);
   if (!buffer)
 return 1;
 
diff --git a/modules/crypto/sha512 b/modules/crypto/sha512
index 4c97604cd..6d0dd1019 100644
--- a/modules/crypto/sha512
+++ b/modules/crypto/sha512
@@ -5,8 +5,11 @@ Files:
 lib/gl_openssl.h
 lib/sha512.h
 lib/sha512.c
+lib/af_alg.h
+lib/af_alg.c
 m4/gl-openssl.m4
 m4/sha512.m4
+m4/linux-if-alg.m4
 
 Depends-on:
 extern-inline
@@ -16,9 +19,10 @@ u64
 
 configure.ac:
 gl_SHA512
+gl_LINUX_IF_ALG_H
 
 Makefile.am:
-lib_SOURCES += sha512.c
+lib_SOURCES += sha512.c af_alg.c
 
 Include:
 "sha512.h"
-- 
2.14.3




[PATCH v3 1/4] sha1sum: use AF_ALG when available

2018-04-28 Thread Matteo Croce
Linux supports accessing kernel crypto API via AF_ALG since
version 2.6.38. Coreutils uses libcrypto when available and fallbacks to
generic C implementation of various hashing functions.

Add a generic afalg_stream() function which uses AF_ALG to calculate the
hash of a stream and use sendfile() when possible (regular file with size
less or equal than 0x7000 (2,147,479,552) bytes, AKA MAX_RW_COUNT).

Use afalg_stream() only in sha1sum for now, but other hashes are possible.
The speed gain really depends on the CPU type, on systems which doesn't use
libcrypto ranges from ~10% to 320%.

This is a test on a Intel(R) Xeon(R) CPU E3-1265L V2 and Debian stretch:

$ truncate -s 2GB 2g.bin
$ time sha1sum 2g.bin
752ef2367f479e79e4f0cded9c270c2890506ab0  2g.bin

real0m4.829s
user0m4.437s
sys 0m0.391s
$ time ./sha1sum-afalg 2g.bin
752ef2367f479e79e4f0cded9c270c2890506ab0  2g.bin

real0m3.164s
user0m0.000s
sys 0m3.162s

Signed-off-by: Matteo Croce 
---
 lib/af_alg.c| 115 
 lib/af_alg.h|  49 ++
 lib/sha1.c  |  17 +++-
 m4/linux-if-alg.m4  |  29 +
 modules/crypto/sha1 |   6 ++-
 5 files changed, 214 insertions(+), 2 deletions(-)
 create mode 100644 lib/af_alg.c
 create mode 100644 lib/af_alg.h
 create mode 100644 m4/linux-if-alg.m4

diff --git a/lib/af_alg.c b/lib/af_alg.c
new file mode 100644
index 0..3af099e43
--- /dev/null
+++ b/lib/af_alg.c
@@ -0,0 +1,115 @@
+/* af_alg.c - Functions to compute message digest from file streams using
+   Linux kernel crypto API.
+   Copyright (C) 2018 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 2, 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 .  */
+
+/* Written by Matteo Croce , 2018.  */
+
+#include 
+
+#ifdef HAVE_LINUX_IF_ALG_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "af_alg.h"
+
+/* from linux/include/linux/fs.h: (INT_MAX & PAGE_MASK).  */
+#define MAX_RW_COUNT 0x7000
+#define BLOCKSIZE 32768
+
+int
+afalg_stream (FILE * stream, void *resblock, const char *alg, ssize_t hashlen)
+{
+  struct sockaddr_alg salg = {
+.salg_family = AF_ALG,
+.salg_type = "hash",
+  };
+  int ret, cfd, ofd;
+  struct stat st;
+
+  cfd = socket (AF_ALG, SOCK_SEQPACKET, 0);
+  if (cfd < 0)
+return -EAFNOSUPPORT;
+
+  /* avoid calling both strcpy and strlen.  */
+  for (int i = 0; (salg.salg_name[i] = alg[i]); i++)
+if (i == sizeof salg.salg_name - 1)
+  return -EINVAL;
+
+  ret = bind (cfd, (struct sockaddr *) &salg, sizeof salg);
+  if (ret < 0)
+{
+  ret = -EAFNOSUPPORT;
+  goto out_cfd;
+}
+
+  ofd = accept (cfd, NULL, 0);
+  if (ofd < 0)
+{
+  ret = -EAFNOSUPPORT;
+  goto out_cfd;
+}
+
+  /* if file is a regular file, attempt sendfile to pipe the data.  */
+  if (!fstat (fileno (stream), &st)
+  && (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st))
+  && st.st_size && st.st_size <= MAX_RW_COUNT)
+{
+  if (sendfile (ofd, fileno (stream), NULL, st.st_size) != st.st_size)
+{
+  ret = -EIO;
+  goto out_ofd;
+}
+  else
+ret = 0;
+}
+  else
+{
+  /* sendfile not possible, do a classic read-write loop.  */
+  ssize_t size;
+  char buf[BLOCKSIZE];
+  while ((size = fread (buf, 1, sizeof buf, stream)))
+{
+  if (send (ofd, buf, size, MSG_MORE) != size)
+{
+  ret = -EIO;
+  goto out_ofd;
+}
+}
+  if (ferror (stream))
+{
+  ret = -EIO;
+  goto out_ofd;
+}
+}
+
+  if (read (ofd, resblock, hashlen) != hashlen)
+ret = -EIO;
+  else
+ret = 0;
+
+out_ofd:
+  close (ofd);
+out_cfd:
+  close (cfd);
+  return ret;
+}
+
+#endif
diff --git a/lib/af_alg.h b/lib/af_alg.h
new file mode 100644
index 0..978e21d36
--- /dev/null
+++ b/lib/af_alg.h
@@ -0,0 +1,49 @@
+/* af_alg.h - Declaration of functions to compute message digest from
+   file streams using Linux kernel crypto API.
+   Copyright (C) 2018 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 2, or (at your option) any
+  

[PATCH v3 0/4] Use AF_ALG in checksum utilities

2018-04-28 Thread Matteo Croce
Let md5sum and all sha*sum utilities use Linux kernel cryptographic API via the
AF_ALG address family.

Speed gain depends on the CPU type:

Xeon E3-1265L V2:

$ truncate -s 2GB 2g.bin
$ time sha1sum 2g.bin
752ef2367f479e79e4f0cded9c270c2890506ab0  2g.bin

real0m4.829s
user0m4.437s
sys 0m0.391s
$ time ./sha1sum-afalg 2g.bin
752ef2367f479e79e4f0cded9c270c2890506ab0  2g.bin

real0m3.164s
user0m0.000s
sys 0m3.162s

Xeon E3-1240 v6:

$ time sha1sum disk.qcow2
47be301f86c71c20eae4ccc5bab4c02e09e729a4  disk.qcow2

real  0m28.390s
user  0m13.352s
sys  0m1.376s
$ time ./sha1sum-afalg disk.qcow2
47be301f86c71c20eae4ccc5bab4c02e09e729a4  disk.qcow2

real  0m8.373s
user  0m0.052s
sys  0m8.308s

Marvell Armada 8040 - MACCHIATOBin Dual shot:

$ dd if=/dev/zero bs=1G count=10 |time -p sha1sum
a0b6e2ca4e28360a929943e8eb966f703a69dc44  2g.bin

real  0m49.390s
user  0m46.852s
sys  0m2.076s
$ dd if=/dev/zero bs=1G count=10 |time -p ./sha1sum-afalg
a0b6e2ca4e28360a929943e8eb966f703a69dc44  2g.bin

real  0m15.104s
user  0m0.052s
sys  0m15.008s

Correctness of the implementation was tested with the following script:

algos='md5sum sha1sum sha224sum sha256sum sha384sum sha512sum'
dd='dd status=none if=/dev/zero'

for alg in $algos; do
echo -n "Checking $alg..."
for bs in 1 31 512 1K 4K 1M; do
for count in 0 1 1234 4096; do
  hash1=$($dd bs=$bs count=$count |$alg)
  hash2=$($dd bs=$bs count=$count |src/$alg)
  [ "$hash1" = "$hash2" ] || \
exec echo "\n$alg: hash differs with bs=$bs count=$count"
done
truncate -s $bs /tmp/filechk-$$
hash1=$($alg /tmp/filechk-$$)
hash2=$(src/$alg /tmp/filechk-$$)
[ "$hash1" = "$hash2" ] || \
  exec echo "\n$alg: hash differs reading '/tmp/filechk-$$'!"
rm -f /tmp/filechk-$$
hash1=$($alg /proc/version)
hash2=$(src/$alg /proc/version)
[ "$hash1" = "$hash2" ] || \
  exec echo "\n$alg: hash differs reading from procfs!"
done
echo " ok"
done

Changes since v2:
* added m4 script to check for af_alg in configury
* more strict error checking in af_alg.c
* don't allocate temporary buffer if using sendfile
* adhere to GNU coding style
* don't include more headers than necessary
* don't use sendfile for empty files as it breaks reading from procfs
* use sendfile for shared memory objects too

Changes since v1:
* add copyright nore in af_alg.c
* check for AF_ALG in sys/socket.h to avoid build failures when unavailable
* don't include unneeded header files in af_alg.h
* revert wrong Include directive in module description
* revert unneeded 'Hey Emacs!' blocks
* use correct GNU indentation
* prefer size_t over int to denote memory segments
* avoid possible overflow by checking arguments size
* return -EIO if sendfile() returns a short read/write count
* fix a file descriptor leak when bind() returns error

Matteo Croce (4):
  sha1sum: use AF_ALG when available
  sha256sum: use kernel crypto API
  sha512sum: use kernel crypto API
  md5sum: use kernel crypto API

 lib/af_alg.c  | 115 ++
 lib/af_alg.h  |  49 +
 lib/md5.c |  18 +++-
 lib/sha1.c|  17 +++-
 lib/sha256.c  |  32 +-
 lib/sha512.c  |  32 +-
 m4/linux-if-alg.m4|  29 +
 modules/crypto/md5|   6 ++-
 modules/crypto/sha1   |   6 ++-
 modules/crypto/sha256 |   6 ++-
 modules/crypto/sha512 |   6 ++-
 11 files changed, 306 insertions(+), 10 deletions(-)
 create mode 100644 lib/af_alg.c
 create mode 100644 lib/af_alg.h
 create mode 100644 m4/linux-if-alg.m4

-- 
2.14.3




[PATCH v3 2/4] sha256sum: use kernel crypto API

2018-04-28 Thread Matteo Croce
Use AF_ALG for sha224 and sha256 too

Signed-off-by: Matteo Croce 
---
 lib/sha256.c  | 32 ++--
 modules/crypto/sha256 |  6 +-
 2 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/lib/sha256.c b/lib/sha256.c
index 85405b20f..578f43e4d 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -32,6 +32,10 @@
 #include 
 #include 
 
+#ifdef HAVE_LINUX_IF_ALG_H
+# include "af_alg.h"
+#endif
+
 #if USE_UNLOCKED_IO
 # include "unlocked-io.h"
 #endif
@@ -177,8 +181,20 @@ sha256_stream (FILE *stream, void *resblock)
 {
   struct sha256_ctx ctx;
   size_t sum;
+  char *buffer;
+
+#ifdef HAVE_LINUX_IF_ALG_H
+  int ret;
+
+  ret = afalg_stream(stream, resblock, "sha256", SHA256_DIGEST_SIZE);
+  if (!ret)
+  return 0;
+
+  if (ret == -EIO)
+  return 1;
+#endif
 
-  char *buffer = malloc (BLOCKSIZE + 72);
+  buffer = malloc (BLOCKSIZE + 72);
   if (!buffer)
 return 1;
 
@@ -248,8 +264,20 @@ sha224_stream (FILE *stream, void *resblock)
 {
   struct sha256_ctx ctx;
   size_t sum;
+  char *buffer;
+
+#ifdef HAVE_LINUX_IF_ALG_H
+  int ret;
+
+  ret = afalg_stream(stream, resblock, "sha224", SHA224_DIGEST_SIZE);
+  if (!ret)
+  return 0;
+
+  if (ret == -EIO)
+  return 1;
+#endif
 
-  char *buffer = malloc (BLOCKSIZE + 72);
+  buffer = malloc (BLOCKSIZE + 72);
   if (!buffer)
 return 1;
 
diff --git a/modules/crypto/sha256 b/modules/crypto/sha256
index 37fabfd90..9d4f11578 100644
--- a/modules/crypto/sha256
+++ b/modules/crypto/sha256
@@ -5,8 +5,11 @@ Files:
 lib/gl_openssl.h
 lib/sha256.h
 lib/sha256.c
+lib/af_alg.h
+lib/af_alg.c
 m4/gl-openssl.m4
 m4/sha256.m4
+m4/linux-if-alg.m4
 
 Depends-on:
 extern-inline
@@ -15,9 +18,10 @@ stdint
 
 configure.ac:
 gl_SHA256
+gl_LINUX_IF_ALG_H
 
 Makefile.am:
-lib_SOURCES += sha256.c
+lib_SOURCES += sha256.c af_alg.c
 
 Include:
 "sha256.h"
-- 
2.14.3




[PATCH] bootstrap: Avoid gnulib operations if not needed

2018-04-28 Thread Paul Smith
* build-aux/bootstrap: Remove unused variable gnulib_mk.
Set $gnulib_extra_files early so it can be overridden in .conf.
Remove redundant --import flag from $gnulib_tool_options.
Set $use_gnulib to false if no gnulib modules or files are needed.
If $use_gnulib is false, don't do anything related to gnulib.
---
A lot of this is just whitespace (indentation) changes.

 build-aux/bootstrap | 218 ++
--
 1 file changed, 110 insertions(+), 108 deletions(-)

diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index 92be114..eddacfb 100755
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Print a version string.
-scriptversion=2018-03-07.03; # UTC
+scriptversion=2018-04-28.14; # UTC
 
 # Bootstrap this package from checked-out sources.
 
@@ -109,9 +109,6 @@ die() { warn_ "$@"; exit 1; }
 
 # Configuration.
 
-# Name of the Makefile.am
-gnulib_mk=gnulib.mk
-
 # List of gnulib modules needed.
 gnulib_modules=
 
@@ -170,7 +167,15 @@ source_base=lib
 m4_base=m4
 doc_base=doc
 tests_base=tests
-gnulib_extra_files=''
+gnulib_extra_files="
+build-aux/install-sh
+build-aux/mdate-sh
+build-aux/texinfo.tex
+build-aux/depcomp
+build-aux/config.guess
+build-aux/config.sub
+doc/INSTALL
+"
 
 # Additional gnulib-tool options to use.  Use "\newline" to break
lines.
 gnulib_tool_option_extras=
@@ -264,24 +269,18 @@ case "$0" in
   *) test -r "$0.conf" && . ./"$0.conf" ;;
 esac
 
-# Extra files from gnulib, which override files from other sources.
-test -z "${gnulib_extra_files}" && \
-  gnulib_extra_files="
-build-aux/install-sh
-build-aux/mdate-sh
-build-aux/texinfo.tex
-build-aux/depcomp
-build-aux/config.guess
-build-aux/config.sub
-doc/INSTALL
-"
-
 if test "$vc_ignore" = auto; then
   vc_ignore=
   test -d .git && vc_ignore=.gitignore
   test -d CVS && vc_ignore="$vc_ignore .cvsignore"
 fi
 
+if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then
+  use_gnulib=false
+else
+  use_gnulib=true
+fi
+
 # Translate configuration into internal form.
 
 # Parse options.
@@ -612,85 +611,87 @@ git_modules_config () {
   test -f .gitmodules && git config --file .gitmodules "$@"
 }
 
-if $use_git; then
-  gnulib_path=$(git_modules_config submodule.gnulib.path)
-  test -z "$gnulib_path" && gnulib_path=gnulib
-fi
+if $use_gnulib; then
+  if $use_git; then
+gnulib_path=$(git_modules_config submodule.gnulib.path)
+test -z "$gnulib_path" && gnulib_path=gnulib
+  fi
 
-# Get gnulib files.  Populate $GNULIB_SRCDIR, possibly updating a
-# submodule, for use in the rest of the script.
+  # Get gnulib files.  Populate $GNULIB_SRCDIR, possibly updating a
+  # submodule, for use in the rest of the script.
 
-case ${GNULIB_SRCDIR--} in
--)
-  # Note that $use_git is necessarily true in this case.
-  if git_modules_config submodule.gnulib.url >/dev/null; then
-echo "$0: getting gnulib files..."
-git submodule init -- "$gnulib_path" || exit $?
-git submodule update -- "$gnulib_path" || exit $?
+  case ${GNULIB_SRCDIR--} in
+  -)
+# Note that $use_git is necessarily true in this case.
+if git_modules_config submodule.gnulib.url >/dev/null; then
+  echo "$0: getting gnulib files..."
+  git submodule init -- "$gnulib_path" || exit $?
+  git submodule update -- "$gnulib_path" || exit $?
 
-  elif [ ! -d "$gnulib_path" ]; then
-echo "$0: getting gnulib files..."
+elif [ ! -d "$gnulib_path" ]; then
+  echo "$0: getting gnulib files..."
 
-trap cleanup_gnulib 1 2 13 15
+  trap cleanup_gnulib 1 2 13 15
 
-shallow=
-git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='
--depth 2'
-git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
-  cleanup_gnulib
+  shallow=
+  git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='
--depth 2'
+  git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
+cleanup_gnulib
 
-trap - 1 2 13 15
-  fi
-  GNULIB_SRCDIR=$gnulib_path
-  ;;
-*)
-  # Use GNULIB_SRCDIR directly or as a reference.
-  if $use_git && test -d "$GNULIB_SRCDIR"/.git && \
-git_modules_config submodule.gnulib.url >/dev/null; then
-echo "$0: getting gnulib files..."
-if git submodule -h|grep -- --reference > /dev/null; then
-  # Prefer the one-liner available in git 1.6.4 or newer.
-  git submodule update --init --reference "$GNULIB_SRCDIR" \
-"$gnulib_path" || exit $?
-else
-  # This fallback allows at least git 1.5.5.
-  if test -f "$gnulib_path"/gnulib-tool; then
-# Since file already exists, assume submodule init already
complete.
-git submodule update -- "$gnulib_path" || exit $?
+  trap - 1 2 13 15
+fi
+GNULIB_SRCDIR=$gnulib_path
+;;
+  *)
+# Use GNULIB_SRCDIR directly or as a reference.
+if $use_git && test -d "$GNULIB_SRCDIR"/.git && \

[PATCH] manywarnings: port to GCC 8.0

2018-04-28 Thread Paul Eggert
* build-aux/gcc-warning.spec: Add -Wcatch-value,
-Wclass-memaccess, -Wdo-subscript, -Wextra-semi.  Adjust to the
fact that the GCC help message now mentions operands for
-Warray-bounds, -Wformat, -Wformat-overflow, -Wformat-truncation,
-Wimplicit-fallthrough, -Wplacement-new, -Wshift-overflow,
-Wstrict-aliasing, -Wstrict-overflow, -Wstringop-overflow,
and -Wunused-const-variable.
* m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Add -Wattribute-alias,
-Wcast-align=strict, -Wcast-function-type, -Wif-not-aligned,
-Wmissing-attributes, -Wmultistatement-macros,
-Wpacked-not-aligned, -Wsizeof-pointer-div, -Wstringop-truncation,
-Wsuggest-attribute=cold, -Wsuggest-attribute=malloc.
---
 ChangeLog  | 16 
 build-aux/gcc-warning.spec | 30 +-
 m4/manywarnings.m4 | 20 +++-
 3 files changed, 48 insertions(+), 18 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9f809cce8..1ef9799f3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2018-04-27  Paul Eggert  
+
+   manywarnings: port to GCC 8.0
+   * build-aux/gcc-warning.spec: Add -Wcatch-value,
+   -Wclass-memaccess, -Wdo-subscript, -Wextra-semi.  Adjust to the
+   fact that the GCC help message now mentions operands for
+   -Warray-bounds, -Wformat, -Wformat-overflow, -Wformat-truncation,
+   -Wimplicit-fallthrough, -Wplacement-new, -Wshift-overflow,
+   -Wstrict-aliasing, -Wstrict-overflow, -Wstringop-overflow,
+   and -Wunused-const-variable.
+   * m4/manywarnings.m4 (gl_MANYWARN_ALL_GCC): Add -Wattribute-alias,
+   -Wcast-align=strict, -Wcast-function-type, -Wif-not-aligned,
+   -Wmissing-attributes, -Wmultistatement-macros,
+   -Wpacked-not-aligned, -Wsizeof-pointer-div, -Wstringop-truncation,
+   -Wsuggest-attribute=cold, -Wsuggest-attribute=malloc.
+
 2018-04-24  Bruno Haible  
 
sys_socket: Make SO_REUSEPORT available across platforms.
diff --git a/build-aux/gcc-warning.spec b/build-aux/gcc-warning.spec
index 9b9c39faf..2ffdb2ba4 100644
--- a/build-aux/gcc-warning.spec
+++ b/build-aux/gcc-warning.spec
@@ -6,7 +6,6 @@
 -Waggregate-return obsolescent
 -Waliasing fortran
 -Walign-commonsfortran
--Waligned-new  c++
 -Waligned-new=[none|global|all]c++
 -Walloca   we like alloca in small doses
 -Walloca-larger-than=  FIXME: choose something sane?
@@ -15,7 +14,7 @@
 -Wampersandfortran
 -Wargument-mismatchfortran
 -Warray-bounds covered by -Warray-bounds=
--Warray-bounds=handled specially by 
gl_MANYWARN_ALL_GCC
+-Warray-bounds=<0,2>   handled specially by gl_MANYWARN_ALL_GCC
 -Warray-temporariesfortran
 -Wassign-intercept objc/objc++
 -Wc++-compat   FIXME maybe? borderline.  some will 
want this
@@ -28,7 +27,10 @@
 -Wc90-c99-compat   c compatibility
 -Wc99-c11-compat   c compatibility
 -Wcast-qualFIXME maybe? too much noise; encourages 
bad changes
+-Wcatch-value  c++
+-Wcatch-value=<0,3>c++
 -Wcharacter-truncation fortran
+-Wclass-memaccess  c++
 -Wcompare-realsfortran
 -Wconditionally-supported  c++ and objc++
 -Wconversion   FIXME maybe? too much noise; encourages 
bad changes
@@ -38,20 +40,22 @@
 -Wdeclaration-after-statement  FIXME: do not want.  others may
 -Wdelete-incompletec++ and objc++
 -Wdelete-non-virtual-dtor  c++
+-Wdo-subscript fortran
 -Weffc++   c++
 -Werror-implicit-function-declaration  deprecated
+-Wextra-semi   c++
 -Wfloat-conversion FIXME maybe? borderline.  some will 
want this
 -Wfloat-equal  FIXME maybe? borderline.  some will 
want this
 -Wformat   covered by -Wformat=2
--Wformat=  gcc --help=warnings artifact
--Wformat-overflow  covered by -Wformat-overflow=2
--Wformat-overflow= handled specially by gl_MANYWARN_ALL_GCC
+-Wformat=<0,2> gcc --help=warnings artifact
+-Wformat-overflow<0,2> gcc --help=warnings artifact
+-Wformat-overflow=<0,2>handled specially by 
gl_MANYWARN_ALL_GCC
 -Wformat-truncationcovered by -Wformat-truncation=2
--Wformat-truncation=   handled specially by gl_MANYWARN_ALL_GCC
+-Wformat-truncation=<0,2>  handled specially by gl_MANYWARN_ALL_GCC
 -Wframe-larger-than=  

Re: [PATCH] bootstrap: Avoid gnulib operations if not needed

2018-04-28 Thread Paul Eggert
Thanks, but it looks like Evolution broke the patch by folding lines; could you 
please resend it as an attachment? "git format-patch" is a good way to format 
patches, and I use "git send-email" to send them if you prefer not to use 
attachments.




Re: [PATCH] bootstrap: Avoid gnulib operations if not needed

2018-04-28 Thread Paul Smith
On Sat, 2018-04-28 at 14:00 -0700, Paul Eggert wrote:
> Thanks, but it looks like Evolution broke the patch by folding lines; could 
> you 
> please resend it as an attachment? "git format-patch" is a good way to format 
> patches, and I use "git send-email" to send them if you prefer not to use 
> attachments

Hrm.  I did use git format-patch, but apparently something went wrong
when I inserted the text; I assumed Evo would not reformat if I used
"Insert text file" but perhaps that was naive.

I've never figured out how to use git send-email with SMTP servers
which require secure connections.  Probably I should do that, someday.

I'll resend.



[PATCH] bootstrap: Avoid gnulib operations if not needed

2018-04-28 Thread Paul Smith




Re: [PATCH] bootstrap: Avoid gnulib operations if not needed

2018-04-28 Thread Paul Eggert

Paul Smith wrote:

I've never figured out how to use git send-email with SMTP servers
which require secure connections.


To get that to work, I put something like the following into my ~/.gitconfig 
file (I used my own info of course, with UCLA-CS's SMTP server). Admittedly it's 
a bit of a black art.


[user]
name = Paul Smith
email = psm...@gnu.org
[sendemail]
smtpencryption = ssl
smtpserver = your.favorite.server.domain.name
smtpuser = psmith
smtpserverport = 465




Re: [PATCH] bootstrap: Avoid gnulib operations if not needed

2018-04-28 Thread Paul Eggert
That email was empty, so I attempted to repair Evolution's damage in the patch 
you originally sent, and installed the attached into the Gnulib master on 
Savannah. Please give a try. Thanks.
>From b48a0b952b98b15fb1abb1f18f3676a647935a5f Mon Sep 17 00:00:00 2001
From: Paul Smith 
Date: Sat, 28 Apr 2018 16:37:50 -0700
Subject: [PATCH] bootstrap: Avoid gnulib operations if not needed

* build-aux/bootstrap: Remove unused variable gnulib_mk.
Set $gnulib_extra_files early so it can be overridden in .conf.
Remove redundant --import flag from $gnulib_tool_options.
Set $use_gnulib to false if no gnulib modules or files are needed.
If $use_gnulib is false, don't do anything related to gnulib.
A lot of this is just whitespace (indentation) changes.
---
 ChangeLog   |  10 +++
 build-aux/bootstrap | 218 ++--
 2 files changed, 120 insertions(+), 108 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1ef9799..409848f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2018-04-28  Paul Smith  
+
+	bootstrap: Avoid gnulib operations if not needed
+	* build-aux/bootstrap: Remove unused variable gnulib_mk.
+	Set $gnulib_extra_files early so it can be overridden in .conf.
+	Remove redundant --import flag from $gnulib_tool_options.
+	Set $use_gnulib to false if no gnulib modules or files are needed.
+	If $use_gnulib is false, don't do anything related to gnulib.
+	A lot of this is just whitespace (indentation) changes.
+
 2018-04-27  Paul Eggert  
 
 	manywarnings: port to GCC 8.0
diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index 92be114..eddacfb 100755
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Print a version string.
-scriptversion=2018-03-07.03; # UTC
+scriptversion=2018-04-28.14; # UTC
 
 # Bootstrap this package from checked-out sources.
 
@@ -109,9 +109,6 @@ die() { warn_ "$@"; exit 1; }
 
 # Configuration.
 
-# Name of the Makefile.am
-gnulib_mk=gnulib.mk
-
 # List of gnulib modules needed.
 gnulib_modules=
 
@@ -170,7 +167,15 @@ source_base=lib
 m4_base=m4
 doc_base=doc
 tests_base=tests
-gnulib_extra_files=''
+gnulib_extra_files="
+build-aux/install-sh
+build-aux/mdate-sh
+build-aux/texinfo.tex
+build-aux/depcomp
+build-aux/config.guess
+build-aux/config.sub
+doc/INSTALL
+"
 
 # Additional gnulib-tool options to use.  Use "\newline" to break lines.
 gnulib_tool_option_extras=
@@ -264,24 +269,18 @@ case "$0" in
   *) test -r "$0.conf" && . ./"$0.conf" ;;
 esac
 
-# Extra files from gnulib, which override files from other sources.
-test -z "${gnulib_extra_files}" && \
-  gnulib_extra_files="
-build-aux/install-sh
-build-aux/mdate-sh
-build-aux/texinfo.tex
-build-aux/depcomp
-build-aux/config.guess
-build-aux/config.sub
-doc/INSTALL
-"
-
 if test "$vc_ignore" = auto; then
   vc_ignore=
   test -d .git && vc_ignore=.gitignore
   test -d CVS && vc_ignore="$vc_ignore .cvsignore"
 fi
 
+if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then
+  use_gnulib=false
+else
+  use_gnulib=true
+fi
+
 # Translate configuration into internal form.
 
 # Parse options.
@@ -612,85 +611,87 @@ git_modules_config () {
   test -f .gitmodules && git config --file .gitmodules "$@"
 }
 
-if $use_git; then
-  gnulib_path=$(git_modules_config submodule.gnulib.path)
-  test -z "$gnulib_path" && gnulib_path=gnulib
-fi
+if $use_gnulib; then
+  if $use_git; then
+gnulib_path=$(git_modules_config submodule.gnulib.path)
+test -z "$gnulib_path" && gnulib_path=gnulib
+  fi
 
-# Get gnulib files.  Populate $GNULIB_SRCDIR, possibly updating a
-# submodule, for use in the rest of the script.
+  # Get gnulib files.  Populate $GNULIB_SRCDIR, possibly updating a
+  # submodule, for use in the rest of the script.
 
-case ${GNULIB_SRCDIR--} in
--)
-  # Note that $use_git is necessarily true in this case.
-  if git_modules_config submodule.gnulib.url >/dev/null; then
-echo "$0: getting gnulib files..."
-git submodule init -- "$gnulib_path" || exit $?
-git submodule update -- "$gnulib_path" || exit $?
+  case ${GNULIB_SRCDIR--} in
+  -)
+# Note that $use_git is necessarily true in this case.
+if git_modules_config submodule.gnulib.url >/dev/null; then
+  echo "$0: getting gnulib files..."
+  git submodule init -- "$gnulib_path" || exit $?
+  git submodule update -- "$gnulib_path" || exit $?
 
-  elif [ ! -d "$gnulib_path" ]; then
-echo "$0: getting gnulib files..."
+elif [ ! -d "$gnulib_path" ]; then
+  echo "$0: getting gnulib files..."
 
-trap cleanup_gnulib 1 2 13 15
+  trap cleanup_gnulib 1 2 13 15
 
-shallow=
-git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
-git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
-  cleanup_gnulib
+  shallow=
+  git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='-

[PATCH] bootstrap: Avoid gnulib operations if not needed.

2018-04-28 Thread Paul Smith
* build-aux/bootstrap: Remove unused variable gnulib_mk.
Set $gnulib_extra_files early so it can be overridden in .conf.
Remove redundant --import flag from $gnulib_tool_options.
Set $use_gnulib to false if no gnulib modules or files are needed.
If $use_gnulib is false, don't do anything related to gnulib.
---
Resend to resolve line wrapping issues.
A lot of this is just whitespace (indentation) changes.

 build-aux/bootstrap | 218 ++--
 1 file changed, 110 insertions(+), 108 deletions(-)

diff --git a/build-aux/bootstrap b/build-aux/bootstrap
index 92be114..eddacfb 100755
--- a/build-aux/bootstrap
+++ b/build-aux/bootstrap
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Print a version string.
-scriptversion=2018-03-07.03; # UTC
+scriptversion=2018-04-28.14; # UTC
 
 # Bootstrap this package from checked-out sources.
 
@@ -109,9 +109,6 @@ die() { warn_ "$@"; exit 1; }
 
 # Configuration.
 
-# Name of the Makefile.am
-gnulib_mk=gnulib.mk
-
 # List of gnulib modules needed.
 gnulib_modules=
 
@@ -170,7 +167,15 @@ source_base=lib
 m4_base=m4
 doc_base=doc
 tests_base=tests
-gnulib_extra_files=''
+gnulib_extra_files="
+build-aux/install-sh
+build-aux/mdate-sh
+build-aux/texinfo.tex
+build-aux/depcomp
+build-aux/config.guess
+build-aux/config.sub
+doc/INSTALL
+"
 
 # Additional gnulib-tool options to use.  Use "\newline" to break lines.
 gnulib_tool_option_extras=
@@ -264,24 +269,18 @@ case "$0" in
   *) test -r "$0.conf" && . ./"$0.conf" ;;
 esac
 
-# Extra files from gnulib, which override files from other sources.
-test -z "${gnulib_extra_files}" && \
-  gnulib_extra_files="
-build-aux/install-sh
-build-aux/mdate-sh
-build-aux/texinfo.tex
-build-aux/depcomp
-build-aux/config.guess
-build-aux/config.sub
-doc/INSTALL
-"
-
 if test "$vc_ignore" = auto; then
   vc_ignore=
   test -d .git && vc_ignore=.gitignore
   test -d CVS && vc_ignore="$vc_ignore .cvsignore"
 fi
 
+if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then
+  use_gnulib=false
+else
+  use_gnulib=true
+fi
+
 # Translate configuration into internal form.
 
 # Parse options.
@@ -612,85 +611,87 @@ git_modules_config () {
   test -f .gitmodules && git config --file .gitmodules "$@"
 }
 
-if $use_git; then
-  gnulib_path=$(git_modules_config submodule.gnulib.path)
-  test -z "$gnulib_path" && gnulib_path=gnulib
-fi
+if $use_gnulib; then
+  if $use_git; then
+gnulib_path=$(git_modules_config submodule.gnulib.path)
+test -z "$gnulib_path" && gnulib_path=gnulib
+  fi
 
-# Get gnulib files.  Populate $GNULIB_SRCDIR, possibly updating a
-# submodule, for use in the rest of the script.
+  # Get gnulib files.  Populate $GNULIB_SRCDIR, possibly updating a
+  # submodule, for use in the rest of the script.
 
-case ${GNULIB_SRCDIR--} in
--)
-  # Note that $use_git is necessarily true in this case.
-  if git_modules_config submodule.gnulib.url >/dev/null; then
-echo "$0: getting gnulib files..."
-git submodule init -- "$gnulib_path" || exit $?
-git submodule update -- "$gnulib_path" || exit $?
+  case ${GNULIB_SRCDIR--} in
+  -)
+# Note that $use_git is necessarily true in this case.
+if git_modules_config submodule.gnulib.url >/dev/null; then
+  echo "$0: getting gnulib files..."
+  git submodule init -- "$gnulib_path" || exit $?
+  git submodule update -- "$gnulib_path" || exit $?
 
-  elif [ ! -d "$gnulib_path" ]; then
-echo "$0: getting gnulib files..."
+elif [ ! -d "$gnulib_path" ]; then
+  echo "$0: getting gnulib files..."
 
-trap cleanup_gnulib 1 2 13 15
+  trap cleanup_gnulib 1 2 13 15
 
-shallow=
-git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
-git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
-  cleanup_gnulib
+  shallow=
+  git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
+  git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
+cleanup_gnulib
 
-trap - 1 2 13 15
-  fi
-  GNULIB_SRCDIR=$gnulib_path
-  ;;
-*)
-  # Use GNULIB_SRCDIR directly or as a reference.
-  if $use_git && test -d "$GNULIB_SRCDIR"/.git && \
-git_modules_config submodule.gnulib.url >/dev/null; then
-echo "$0: getting gnulib files..."
-if git submodule -h|grep -- --reference > /dev/null; then
-  # Prefer the one-liner available in git 1.6.4 or newer.
-  git submodule update --init --reference "$GNULIB_SRCDIR" \
-"$gnulib_path" || exit $?
-else
-  # This fallback allows at least git 1.5.5.
-  if test -f "$gnulib_path"/gnulib-tool; then
-# Since file already exists, assume submodule init already complete.
-git submodule update -- "$gnulib_path" || exit $?
+  trap - 1 2 13 15
+fi
+GNULIB_SRCDIR=$gnulib_path
+;;
+  *)
+# Use GNULIB_SRCDIR directly or as a reference.
+if $use_git &