changeset 39344:17e92a7c6c04

af_alg: Pacify --enable-gcc-warnings Problem reported by Assaf Gordon in: https://lists.gnu.org/r/bug-gnulib/2018-05/msg00041.html * lib/af_alg.c (afalg_buffer): Move local decls to pacify gcc -Wjump-misses-init. * lib/sha512.c (shaxxx_stream): Now static.
author Paul Eggert <eggert@cs.ucla.edu>
date Mon, 07 May 2018 00:25:57 -0700
parents 3603cbcfab21
children 8a9dcfeeced4
files ChangeLog lib/af_alg.c lib/sha512.c
diffstat 3 files changed, 17 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun May 06 09:05:42 2018 -0700
+++ b/ChangeLog	Mon May 07 00:25:57 2018 -0700
@@ -1,3 +1,12 @@
+2018-05-07  Paul Eggert  <eggert@cs.ucla.edu>
+
+	af_alg: Pacify --enable-gcc-warnings
+	Problem reported by Assaf Gordon in:
+	https://lists.gnu.org/r/bug-gnulib/2018-05/msg00041.html
+	* lib/af_alg.c (afalg_buffer): Move local decls to pacify
+	gcc -Wjump-misses-init.
+	* lib/sha512.c (shaxxx_stream): Now static.
+
 2018-05-06  Bruno Haible  <bruno@clisp.org>
 
 	af_alg: Add ability to use Linux kernel crypto API on data in memory.
--- a/lib/af_alg.c	Sun May 06 09:05:42 2018 -0700
+++ b/lib/af_alg.c	Mon May 07 00:25:57 2018 -0700
@@ -41,7 +41,7 @@
               void *resblock, ssize_t hashlen)
 {
   /* On Linux < 4.9, the value for an empty stream is wrong (all zeroes).
-     See <https://patchwork.kernel.org/patch/9434741/>.  */
+     See <https://patchwork.kernel.org/patch/9308641/>.  */
   if (len == 0)
     return -EAFNOSUPPORT;
 
@@ -109,6 +109,9 @@
   if (cfd < 0)
     return -EAFNOSUPPORT;
 
+  int fd;
+  struct stat st;
+
   int result;
   struct sockaddr_alg salg = {
     .salg_family = AF_ALG,
@@ -137,8 +140,7 @@
     }
 
   /* if file is a regular file, attempt sendfile to pipe the data.  */
-  int fd = fileno (stream);
-  struct stat st;
+  fd = fileno (stream);
   if (fstat (fd, &st) == 0
       && (S_ISREG (st.st_mode) || S_TYPEISSHM (&st) || S_TYPEISTMO (&st))
       && 0 < st.st_size && st.st_size <= SYS_BUFSIZE_MAX)
@@ -159,7 +161,7 @@
 
       off_t nbytes = st.st_size - lseek (fd, 0, SEEK_CUR);
       /* On Linux < 4.9, the value for an empty stream is wrong (all zeroes).
-         See <https://patchwork.kernel.org/patch/9434741/>.  */
+         See <https://patchwork.kernel.org/patch/9308641/>.  */
       if (nbytes <= 0)
         {
           result = -EAFNOSUPPORT;
@@ -192,7 +194,7 @@
           goto out_ofd;
         }
       /* On Linux < 4.9, the value for an empty stream is wrong (all zeroes).
-         See <https://patchwork.kernel.org/patch/9434741/>.  */
+         See <https://patchwork.kernel.org/patch/9308641/>.  */
       if (!non_empty)
         {
           result = -EAFNOSUPPORT;
--- a/lib/sha512.c	Sun May 06 09:05:42 2018 -0700
+++ b/lib/sha512.c	Mon May 07 00:25:57 2018 -0700
@@ -183,7 +183,7 @@
    Write the message digest into RESBLOCK, which contains HASHLEN bytes.
    The initial and finishing operations are INIT_CTX and FINISH_CTX.
    Return zero if and only if successful.  */
-int
+static int
 shaxxx_stream (FILE *stream, char const *alg, void *resblock,
                ssize_t hashlen, void (*init_ctx) (struct sha512_ctx *),
                void *(*finish_ctx) (struct sha512_ctx *, void *))