]> Savannah Git Hosting - gnulib.git/commitdiff
af_alg: Pacify --enable-gcc-warnings
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 7 May 2018 07:25:57 +0000 (00:25 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 7 May 2018 07:26:25 +0000 (00:26 -0700)
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.

ChangeLog
lib/af_alg.c
lib/sha512.c

index ab3143c536e57d061304f2c192b2a37254e39e14..428897fa347ff085e1a764d97546ec0ec35b94fa 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
index 08d6659271403a0087188a27a9b2ac67864fb15f..c9809c70e9e71310230e8e7ac3bf256cb095cb25 100644 (file)
@@ -41,7 +41,7 @@ afalg_buffer (const char *buffer, size_t len, const char *alg,
               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 @@ afalg_stream (FILE *stream, const char *alg,
   if (cfd < 0)
     return -EAFNOSUPPORT;
 
+  int fd;
+  struct stat st;
+
   int result;
   struct sockaddr_alg salg = {
     .salg_family = AF_ALG,
@@ -137,8 +140,7 @@ afalg_stream (FILE *stream, const char *alg,
     }
 
   /* 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 @@ afalg_stream (FILE *stream, const char *alg,
 
       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 @@ afalg_stream (FILE *stream, const char *alg,
           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;
index af0776c728efb603f4eebe4eda26062f5b1fd78e..852c43495057502a0d344e0206d7091bcf7fe3c4 100644 (file)
@@ -183,7 +183,7 @@ sha384_finish_ctx (struct sha512_ctx *ctx, void *resbuf)
    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 *))