]> Savannah Git Hosting - gnulib.git/commitdiff
canonicalize, canonicalize-lgpl: remove lint
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 25 Dec 2020 05:33:18 +0000 (21:33 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 25 Dec 2020 05:49:01 +0000 (21:49 -0800)
Pacify GCC.  Some of these problems were reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2020-12/msg00217.html
* lib/canonicalize-lgpl.c, lib/canonicalize.c:
Sort shared include directives, for consistency.
(IF_LINT): New macro.
(suffix_requires_dir_check): Mark with _GL_ATTRIBUTE_PURE.
* lib/canonicalize-lgpl.c (GCC_LINT, _GL_ATTRIBUTE_PURE) [_LIBC]:
New macros.
(realpath_stk): Suppress bogus -Wmaybe-uninitialized warning.
* lib/canonicalize.c (canonicalize_filename_mode_stk):
Omit unused local.  Suppress bogus -Wmaybe-uninitialized warning.

ChangeLog
lib/canonicalize-lgpl.c
lib/canonicalize.c

index 8f27b286efa7d9a1388cd7773050e671a7786094..dff97afe43e3d5713f2243067064f5f84e42c8d2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2020-12-24  Paul Eggert  <eggert@cs.ucla.edu>
+
+       canonicalize, canonicalize-lgpl: remove lint
+       Pacify GCC.  Some of these problems were reported by Bruno Haible in:
+       https://lists.gnu.org/r/bug-gnulib/2020-12/msg00217.html
+       * lib/canonicalize-lgpl.c, lib/canonicalize.c:
+       Sort shared include directives, for consistency.
+       (IF_LINT): New macro.
+       (suffix_requires_dir_check): Mark with _GL_ATTRIBUTE_PURE.
+       * lib/canonicalize-lgpl.c (GCC_LINT, _GL_ATTRIBUTE_PURE) [_LIBC]:
+       New macros.
+       (realpath_stk): Suppress bogus -Wmaybe-uninitialized warning.
+       * lib/canonicalize.c (canonicalize_filename_mode_stk):
+       Omit unused local.  Suppress bogus -Wmaybe-uninitialized warning.
+
 2020-12-24  Bruno Haible  <bruno@clisp.org>
 
        spawn-pipe: Use posix_spawn by default on native Windows.
index 8c8f98abc49989132b2b551fa5069e9030607a13..68b6fdf6edcc49781931767a441562a2201898fd 100644 (file)
@@ -38,8 +38,8 @@
 #include <unistd.h>
 
 #include <eloop-threshold.h>
-#include <idx.h>
 #include <filename.h>
+#include <idx.h>
 #include <scratch_buffer.h>
 
 #ifdef _LIBC
@@ -50,6 +50,8 @@
 # else
 #  define FACCESSAT_NEVER_EOVERFLOWS true
 # endif
+# define GCC_LINT 1
+# define _GL_ATTRIBUTE_PURE __attribute__ ((__pure__))
 #else
 # define __canonicalize_file_name canonicalize_file_name
 # define __realpath realpath
 # define __stat stat
 #endif
 
+/* Suppress bogus GCC -Wmaybe-uninitialized warnings.  */
+#if defined GCC_LINT || defined lint
+# define IF_LINT(Code) Code
+#else
+# define IF_LINT(Code) /* empty */
+#endif
+
 #ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
 # define DOUBLE_SLASH_IS_DISTINCT_ROOT false
 #endif
@@ -114,7 +123,7 @@ file_accessible (char const *file)
    component within END.  END must either be empty, or start with a
    slash.  */
 
-static bool
+static bool _GL_ATTRIBUTE_PURE
 suffix_requires_dir_check (char const *end)
 {
   /* If END does not start with a slash, the suffix is OK.  */
@@ -338,7 +347,7 @@ realpath_stk (const char *name, char *resolved,
               buf[n] = '\0';
 
               char *extra_buf = extra_buffer.data;
-              idx_t end_idx;
+              idx_t end_idx IF_LINT (= 0);
               if (end_in_extra_buffer)
                 end_idx = end - extra_buf;
               idx_t len = strlen (end);
index 2c88335bf42697a70c227dbf95b336401bc98f94..e8b74d855abd3373e24544f93a1f08a9d32532c0 100644 (file)
 #include <sys/stat.h>
 #include <unistd.h>
 
+#include <filename.h>
+#include <idx.h>
 #include <scratch_buffer.h>
 
 #include "attribute.h"
 #include "file-set.h"
-#include "idx.h"
 #include "hash-triple.h"
 #include "xalloc.h"
-#include "filename.h"
+
+/* Suppress bogus GCC -Wmaybe-uninitialized warnings.  */
+#if defined GCC_LINT || defined lint
+# define IF_LINT(Code) Code
+#else
+# define IF_LINT(Code) /* empty */
+#endif
 
 #ifndef DOUBLE_SLASH_IS_DISTINCT_ROOT
 # define DOUBLE_SLASH_IS_DISTINCT_ROOT false
@@ -72,7 +79,7 @@ file_accessible (char const *file)
    component within END.  END must either be empty, or start with a
    slash.  */
 
-static bool
+static bool _GL_ATTRIBUTE_PURE
 suffix_requires_dir_check (char const *end)
 {
   /* If END does not start with a slash, the suffix is OK.  */
@@ -334,7 +341,6 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
           dest = mempcpy (dest, start, startlen);
           *dest = '\0';
 
-          char discard;
           char *buf;
           ssize_t n = -1;
           if (!logical)
@@ -386,7 +392,7 @@ canonicalize_filename_mode_stk (const char *name, canonicalize_mode_t can_mode,
               buf[n] = '\0';
 
               char *extra_buf = extra_buffer.data;
-              idx_t end_idx;
+              idx_t end_idx IF_LINT (= 0);
               if (end_in_extra_buffer)
                 end_idx = end - extra_buf;
               idx_t len = strlen (end);