]> Savannah Git Hosting - gnulib.git/commitdiff
same-inode, stat-size: support pointers too
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 Sep 2023 01:14:53 +0000 (18:14 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 4 Sep 2023 01:18:36 +0000 (18:18 -0700)
Add functions and macros so that we can test pointers to struct
stat as well as plain struct stat.  This lets coreutils deal with
structs that are only partly initialized, without relying on
undefined behavior.
* NEWS: Mention this.
* doc/posix-headers/sys_stat.texi, doc/stat-size.texi:
Mention this and modernize.
* lib/at-func2.c (at_func2):
* lib/fts.c (same_fd):
* lib/rename.c (rpl_rename) [RENAME_HARD_LINK_BUG]:
* lib/same-inode.c: New file.
* lib/same.c (same_nameat):
* lib/term-style-control.c (activate_term_style_controller):
Prefer psame_inode (a, b) to SAME_INODE (*a, *b).
* lib/hash-triple-simple.c (triple_compare_ino_str):
* lib/hash-triple.c (triple_compare):
Prefer PSAME_INODE (a, b) to SAME_INODE (*a, *b).
psame_inode is not suitable since the args are not struct stat *.
* lib/same-inode.h: Check that config.h is included first.
(SAME_INODE_INLINE, PSAME_INODE): New macros.
(SAME_INODE): Reimplement in terms of PSAME_INODE.
(psame_inode): New function.
* lib/stat-size.h (STP_BLKSIZE, STP_NBLOCKS): New macros.
(ST_BLKSIZE, ST_NBLOCKS): Use them.
* lib/term-style-control.c (log_signal_handler_called):
Always define as a function, to pacify -Wunused*.
* modules/canonicalize-lgpl-tests (Files): Add m4/musl.m4.
(Depends-on): Call gl_MUSL_LIBC.
* modules/same-inode (Files): Add same-inode.c.
(Depends-on): Add extern-inline, stdbool.
(lib_SOURCES): New macro.
* tests/test-binary-io.c, tests/test-canonicalize-lgpl.c:
* tests/test-canonicalize.c, tests/test-cloexec.c:
* tests/test-dup-safer.c, tests/test-dup2.c, tests/test-error.c:
* tests/test-fcntl.c, tests/test-fdopendir.c, tests/test-fgetc.c:
* tests/test-fputc.c, tests/test-fread.c, tests/test-fstat.c:
* tests/test-fstatat.c, tests/test-ftruncate.c:
* tests/test-fwrite.c, tests/test-getcwd.c:
* tests/test-getdtablesize.c, tests/test-isblank.c:
* tests/test-linkat.c, tests/test-lock.c, tests/test-lstat.h:
* tests/test-malloc-gnu.c, tests/test-openat.c:
* tests/test-pthread-thread.c, tests/test-pthread_sigmask1.c:
* tests/test-pthread_sigmask2.c, tests/test-ptsname.c:
* tests/test-ptsname_r.c, tests/test-raise.c:
* tests/test-realloc-gnu.c, tests/test-rwlock1.c:
* tests/test-sigprocmask.c, tests/test-snprintf.c:
* tests/test-stat.h, tests/test-term-style-control-hello.c:
* tests/test-term-style-control-yes.c, tests/test-thread_create.c:
* tests/test-unlinkat.c, tests/test-vasnprintf.c:
* tests/test-xalloc-die.c:
Adjust to these changes, and fix some warnings elicited by
-Wall -Wextra that I ran into while testing.
* top/maint.mk (sc_prohibit_stat_st_blocks): Mention STP_NBLOCKS.

58 files changed:
ChangeLog
NEWS
doc/posix-headers/sys_stat.texi
doc/stat-size.texi
lib/at-func2.c
lib/fts.c
lib/hash-triple-simple.c
lib/hash-triple.c
lib/rename.c
lib/same-inode.c [new file with mode: 0644]
lib/same-inode.h
lib/same.c
lib/stat-size.h
lib/term-style-control.c
modules/canonicalize-lgpl-tests
modules/same-inode
tests/test-binary-io.c
tests/test-canonicalize-lgpl.c
tests/test-canonicalize.c
tests/test-cloexec.c
tests/test-dup-safer.c
tests/test-dup2.c
tests/test-error.c
tests/test-fcntl.c
tests/test-fdopendir.c
tests/test-fgetc.c
tests/test-fputc.c
tests/test-fread.c
tests/test-fstat.c
tests/test-fstatat.c
tests/test-ftruncate.c
tests/test-fwrite.c
tests/test-getcwd.c
tests/test-getdtablesize.c
tests/test-isblank.c
tests/test-linkat.c
tests/test-lock.c
tests/test-lstat.h
tests/test-malloc-gnu.c
tests/test-openat.c
tests/test-pthread-thread.c
tests/test-pthread_sigmask1.c
tests/test-pthread_sigmask2.c
tests/test-ptsname.c
tests/test-ptsname_r.c
tests/test-raise.c
tests/test-realloc-gnu.c
tests/test-rwlock1.c
tests/test-sigprocmask.c
tests/test-snprintf.c
tests/test-stat.h
tests/test-term-style-control-hello.c
tests/test-term-style-control-yes.c
tests/test-thread_create.c
tests/test-unlinkat.c
tests/test-vasnprintf.c
tests/test-xalloc-die.c
top/maint.mk

index 4273e680ec2663c7b9a45ab2ea2305dc7a91411f..601ab4f2c000318e07cea58d89348895356e3109 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,60 @@
+2023-09-03  Paul Eggert  <eggert@cs.ucla.edu>
+
+       same-inode, stat-size: support pointers too
+       Add functions and macros so that we can test pointers to struct
+       stat as well as plain struct stat.  This lets coreutils deal with
+       structs that are only partly initialized, without relying on
+       undefined behavior.
+       * NEWS: Mention this.
+       * doc/posix-headers/sys_stat.texi, doc/stat-size.texi:
+       Mention this and modernize.
+       * lib/at-func2.c (at_func2):
+       * lib/fts.c (same_fd):
+       * lib/rename.c (rpl_rename) [RENAME_HARD_LINK_BUG]:
+       * lib/same-inode.c: New file.
+       * lib/same.c (same_nameat):
+       * lib/term-style-control.c (activate_term_style_controller):
+       Prefer psame_inode (a, b) to SAME_INODE (*a, *b).
+       * lib/hash-triple-simple.c (triple_compare_ino_str):
+       * lib/hash-triple.c (triple_compare):
+       Prefer PSAME_INODE (a, b) to SAME_INODE (*a, *b).
+       psame_inode is not suitable since the args are not struct stat *.
+       * lib/same-inode.h: Check that config.h is included first.
+       (SAME_INODE_INLINE, PSAME_INODE): New macros.
+       (SAME_INODE): Reimplement in terms of PSAME_INODE.
+       (psame_inode): New function.
+       * lib/stat-size.h (STP_BLKSIZE, STP_NBLOCKS): New macros.
+       (ST_BLKSIZE, ST_NBLOCKS): Use them.
+       * lib/term-style-control.c (log_signal_handler_called):
+       Always define as a function, to pacify -Wunused*.
+       * modules/canonicalize-lgpl-tests (Files): Add m4/musl.m4.
+       (Depends-on): Call gl_MUSL_LIBC.
+       * modules/same-inode (Files): Add same-inode.c.
+       (Depends-on): Add extern-inline, stdbool.
+       (lib_SOURCES): New macro.
+       * tests/test-binary-io.c, tests/test-canonicalize-lgpl.c:
+       * tests/test-canonicalize.c, tests/test-cloexec.c:
+       * tests/test-dup-safer.c, tests/test-dup2.c, tests/test-error.c:
+       * tests/test-fcntl.c, tests/test-fdopendir.c, tests/test-fgetc.c:
+       * tests/test-fputc.c, tests/test-fread.c, tests/test-fstat.c:
+       * tests/test-fstatat.c, tests/test-ftruncate.c:
+       * tests/test-fwrite.c, tests/test-getcwd.c:
+       * tests/test-getdtablesize.c, tests/test-isblank.c:
+       * tests/test-linkat.c, tests/test-lock.c, tests/test-lstat.h:
+       * tests/test-malloc-gnu.c, tests/test-openat.c:
+       * tests/test-pthread-thread.c, tests/test-pthread_sigmask1.c:
+       * tests/test-pthread_sigmask2.c, tests/test-ptsname.c:
+       * tests/test-ptsname_r.c, tests/test-raise.c:
+       * tests/test-realloc-gnu.c, tests/test-rwlock1.c:
+       * tests/test-sigprocmask.c, tests/test-snprintf.c:
+       * tests/test-stat.h, tests/test-term-style-control-hello.c:
+       * tests/test-term-style-control-yes.c, tests/test-thread_create.c:
+       * tests/test-unlinkat.c, tests/test-vasnprintf.c:
+       * tests/test-xalloc-die.c:
+       Adjust to these changes, and fix some warnings elicited by
+       -Wall -Wextra that I ran into while testing.
+       * top/maint.mk (sc_prohibit_stat_st_blocks): Mention STP_NBLOCKS.
+
 2023-09-02  Bruno Haible  <bruno@clisp.org>
 
        alignalloc: Fix license header.
diff --git a/NEWS b/NEWS
index 081a5f603536f844057e875f65b7dd57ff3e563b..a7c22ecb33a7173b7af1465f43487f6ea5f366b4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -74,6 +74,9 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2023-09-03  same-inode      SAME_INODE, ST_BLKSIZE and ST_NBLOCKS args
+            stat-size       must be addressable lvalues.
+
 2023-08-08  readutmp        The result element type of the function read_utmp,
                             STRUCT_UTMP, is no longer the same as the result
                             value type of the function getutxent, struct utmpx.
index afa3a1c9121b038a7a99922cd0d3817367884b1f..52027d7a257ec48dd235b982ed29416ea36df899 100644 (file)
@@ -37,6 +37,13 @@ Portability problems fixed by Gnulib module @code{sys_stat}, together with modul
 On Windows platforms (excluding Cygwin), @code{st_ino} is always 0.
 @end itemize
 
+On platforms where @code{off_t} is a 32-bit type, @code{struct stat}
+cannot represent the size of files or block devices 2 GiB or lager
+and may not work correctly on directories 2 GiB or larger.
+Also, on platforms where @code{ino_t} is a 32-bit type,
+@code{struct stat} cannot represent larger inode numbers.
+@xref{Large File Support}, for how to address these problems.
+
 @xref{Avoiding the year 2038 problem}, for portability issues with the
 @code{time_t} components of @code{struct stat}.
 
@@ -48,15 +55,7 @@ MSVC 14.
 @item
 On OpenVMS, @code{st_ino} is an array of three @code{ino_t} values,
 not a single value.
-@item
-To partially work around the previous two problems, you can test for
-nonzero @code{st_ino} and use the Gnulib @code{same-inode} module to
-compare nonzero values.  For example, @code{SAME_INODE (a, b)}
-is true if the @code{struct stat} values @code{a} and
-@code{b} are known to represent the same file, @code{(a.st_ino &&
-!SAME_INODE (a, b))} is true if they are known to represent different
-files, and @code{!a.st_ino} is true if it is not known whether they
-represent different files.
+@code{b} are known to represent the same file.
 @item
 On some platforms, two different files may have the same @code{st_dev}
 and @code{st_ino} values, even when @code{st_ino} is nonzero:
@@ -70,13 +69,20 @@ Network Appliance NFS servers in snapshot directories; see Network
 Appliance bug #195.
 @item
 ClearCase MVFS; see bug id ATRia04618.
-@end itemize
-One partial workaround is to compare other file metadata such as
-@code{st_mode} and @code{st_mtime} to detect this bug, but this
-approach does not work on files whose metadata are being changed by
-other programs.
 @item
 On some file systems, @code{st_size} contains bogus information for
 symlinks; use the Gnulib module @code{areadlink-with-size} for a
 better way to get symlink contents.
 @end itemize
+
+To partially work around porting problems with Microsoft Windows and OpenVMS,
+you can use the Gnulib @code{same-inode} module to test whether two
+@code{struct stat} objects are known to represent the same file.
+For example, @code{psame_inode (&a, &b)} is true if the @code{struct stat}
+objects @code{a} and @code{b} are known to represent the same file.
+
+Another partial workaround is to compare other file metadata such as
+@code{st_mode} and @code{st_mtime} on platforms where @code{st_dev}
+and @code{st_ino} not uniquely identify a file.  However, this does
+not work reliably on files whose metadata are being changed by other
+programs, or where the metadata happen to be equal.
index 17b5be97f60af878e8c86dbb10f71731a03d424e..80d8ae14bafd1ceb1af65908ecb42bfd81273330 100644 (file)
@@ -9,17 +9,21 @@ intended for interpreting the file size information in an instance of
 @c Youngman as if the ST_NBLOCKSIZE macro should be used instead).
 
 @findex ST_NBLOCKS
+@findex STP_NBLOCKS
 @findex ST_NBLOCKSIZE
 @cindex block size
 On POSIX systems, the @code{st_blocks} member of @code{struct stat}
 contains the number of disk blocks occupied by a file.  The
-@code{ST_NBLOCKS} macro is used to estimate this quantity on systems
+@code{ST_NBLOCKS} and @code{STP_NBLOCKS} macros
+estimate this quantity on systems
 which don't actually have @code{st_blocks}.  Each of these blocks
 contains @code{ST_NBLOCKSIZE} bytes.
 
 @findex ST_BLKSIZE
+@findex STP_BLKSIZE
 The value of @code{ST_NBLOCKSIZE} is often quite small, small enough
 that performing I/O in chunks that size would be inefficient.
-@code{ST_BLKSIZE} is the I/O block size recommended for I/O to this
+The @code{ST_BLKSIZE} and @code{STP_BLKSIZE} macros
+give the I/O block size recommended for I/O to this
 file.  This is not guaranteed to give optimum performance, but it
 should be reasonably efficient.
index bea7ea6ce66f0fdd3b77db955d62aa83ab9399fa..bdec139bdf62dec8639efae2727af2f74788fbed 100644 (file)
@@ -132,7 +132,7 @@ at_func2 (int fd1, char const *file1,
           errno = ENOTDIR;
           return -1;
         }
-      if (SAME_INODE (st1, st2)) /* Reduced to cases 1, 5.  */
+      if (psame_inode (&st1, &st2)) /* Reduced to cases 1, 5.  */
         return func (file1, file2);
     }
   else if (fd2 == AT_FDCWD) /* Cases 12, 13.  */
@@ -144,7 +144,7 @@ at_func2 (int fd1, char const *file1,
           errno = ENOTDIR;
           return -1;
         }
-      if (SAME_INODE (st1, st2)) /* Reduced to cases 4, 5.  */
+      if (psame_inode (&st1, &st2)) /* Reduced to cases 4, 5.  */
         return func (file1, file2);
     }
   else if (fd1 != fd2) /* Case 15b.  */
@@ -156,10 +156,10 @@ at_func2 (int fd1, char const *file1,
           errno = ENOTDIR;
           return -1;
         }
-      if (SAME_INODE (st1, st2)) /* Reduced to case 15a.  */
+      if (psame_inode (&st1, &st2)) /* Reduced to case 15a.  */
         {
           fd2 = fd1;
-          if (stat (".", &st1) == 0 && SAME_INODE (st1, st2))
+          if (stat (".", &st1) == 0 && psame_inode (&st1, &st2))
             return func (file1, file2); /* Further reduced to case 5.  */
         }
     }
@@ -172,7 +172,7 @@ at_func2 (int fd1, char const *file1,
           errno = ENOTDIR;
           return -1;
         }
-      if (stat (".", &st2) == 0 && SAME_INODE (st1, st2))
+      if (stat (".", &st2) == 0 && psame_inode (&st1, &st2))
         return func (file1, file2); /* Reduced to case 5.  */
     }
 
index faeb4b20a5edb8d89a9d1af15cf4bbf3bf98704d..d66c134fb8c5c70cdacd44408c5554bade85278b 100644 (file)
--- a/lib/fts.c
+++ b/lib/fts.c
@@ -1714,7 +1714,7 @@ same_fd (int fd1, int fd2)
   struct stat sb1, sb2;
   return (fstat (fd1, &sb1) == 0
           && fstat (fd2, &sb2) == 0
-          && SAME_INODE (sb1, sb2));
+          && psame_inode (&sb1, &sb2));
 }
 
 static void
index b0fd31dc3a15747ee4ba95008771559a4242dd24..4b8016049bb7167aa84a48974b42181d75fd0c2b 100644 (file)
@@ -46,7 +46,7 @@ triple_compare_ino_str (void const *x, void const *y)
 {
   struct F_triple const *a = x;
   struct F_triple const *b = y;
-  return (SAME_INODE (*a, *b) && STREQ (a->name, b->name)) ? true : false;
+  return PSAME_INODE (a, b) && STREQ (a->name, b->name);
 }
 
 /* Free an F_triple.  */
index 3e51b5992eabab1633b82ec98ec4fb348f83a73c..523c07ab172301517ebd111e9a2f28358eede63b 100644 (file)
@@ -40,5 +40,5 @@ triple_compare (void const *x, void const *y)
 {
   struct F_triple const *a = x;
   struct F_triple const *b = y;
-  return (SAME_INODE (*a, *b) && same_name (a->name, b->name)) ? true : false;
+  return PSAME_INODE (a, b) && same_name (a->name, b->name);
 }
index aa3afd87684dca7b4103498836040b619160ae6c..a1dcc004bbb840a92501018bb5eb23f6d622a31a 100644 (file)
@@ -351,7 +351,7 @@ rpl_rename (char const *src, char const *dst)
           return -1;
         }
 # if RENAME_HARD_LINK_BUG
-      if (SAME_INODE (src_st, dst_st))
+      if (psame_inode (&src_st, &dst_st))
         return 0;
 # endif /* RENAME_HARD_LINK_BUG */
       dst_exists = true;
diff --git a/lib/same-inode.c b/lib/same-inode.c
new file mode 100644 (file)
index 0000000..08c66a2
--- /dev/null
@@ -0,0 +1,3 @@
+#include <config.h>
+#define SAME_INODE_INLINE _GL_EXTERN_INLINE
+#include "same-inode.h"
index 10964f00fc6d0ab51044dbe6aba3d76c689c2df6..2518f4b1ac170c95ee11d4a57d3e198a023c9836 100644 (file)
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
 
 #ifndef SAME_INODE_H
-# define SAME_INODE_H 1
-
-# include <sys/types.h>
-
-# if defined __VMS && __CRTL_VER < 80200000
-#  define SAME_INODE(a, b)             \
-    ((a).st_ino[0] == (b).st_ino[0]    \
-     && (a).st_ino[1] == (b).st_ino[1] \
-     && (a).st_ino[2] == (b).st_ino[2] \
-     && (a).st_dev == (b).st_dev)
-# elif defined _WIN32 && ! defined __CYGWIN__
-   /* Native Windows.  */
-#  if _GL_WINDOWS_STAT_INODES
-    /* stat() and fstat() set st_dev and st_ino to 0 if information about
-       the inode is not available.  */
-#   define SAME_INODE(a, b) \
-     (!((a).st_ino == 0 && (a).st_dev == 0) \
-      && (a).st_ino == (b).st_ino && (a).st_dev == (b).st_dev)
+#define SAME_INODE_H 1
+
+/* This file uses _GL_INLINE_HEADER_BEGIN, _GL_INLINE.  */
+#if !_GL_CONFIG_H_INCLUDED
+ #error "Please include config.h first."
+#endif
+
+#include <sys/stat.h>
+
+_GL_INLINE_HEADER_BEGIN
+#ifndef SAME_INODE_INLINE
+# define SAME_INODE_INLINE _GL_INLINE
+#endif
+
+/* True if A and B point to structs with st_dev and st_ino members
+   that are known to represent the same file.
+
+   Use | and ^ to shorten generated code, and to lessen the
+   probability of screwups if st_ino is an array.  */
+
+#if defined __VMS && __CRTL_VER < 80200000
+# define PSAME_INODE(a, b) (! (((a)->st_dev ^ (b)->st_dev) \
+                               | ((a)->st_ino[0] ^ (b)->st_ino[0]) \
+                               | ((a)->st_ino[1] ^ (b)->st_ino[1]) \
+                               | ((a)->st_ino[2] ^ (b)->st_ino[2])))
+#elif defined _WIN32 && ! defined __CYGWIN__
+  /* Native Windows.  */
+# if _GL_WINDOWS_STAT_INODES
+  /* stat() and fstat() set st_dev and st_ino to 0 if information about
+     the inode is not available.  */
+#  if _GL_WINDOWS_STAT_INODES == 2
+#   define PSAME_INODE(a, b) \
+     (! (! ((a)->st_dev | (a)->st_ino._gl_ino[0] | (a)->st_ino._gl_ino[1]) \
+         | ((a)->st_dev ^ (b)->st_dev) \
+         | ((a)->st_ino._gl_ino[0] ^ (b)->st_ino._gl_ino[0]) \
+         | ((a)->st_ino._gl_ino[1] ^ (b)->st_ino._gl_ino[1])))
 #  else
-    /* stat() and fstat() set st_ino to 0 always.  */
-#   define SAME_INODE(a, b) 0
+#   define PSAME_INODE(a, b) (! (! ((a)->st_dev | (a)->st_ino) \
+                                 | ((a)->st_dev ^ (b)->st_dev) \
+                                 | ((a)->st_ino ^ (b)->st_ino)))
 #  endif
 # else
-#  define SAME_INODE(a, b)    \
-    ((a).st_ino == (b).st_ino \
-     && (a).st_dev == (b).st_dev)
+  /* stat() and fstat() set st_ino to 0 always.  */
+#  define PSAME_INODE(a, b) 0
 # endif
+#else
+  /* POSIX.  */
+# define PSAME_INODE(a, b) (! (((a)->st_dev ^ (b)->st_dev) \
+                               | ((a)->st_ino ^ (b)->st_ino)))
+#endif
+
+/* True if struct objects A and B are known to represent the same file.  */
+
+#define SAME_INODE(a, b) PSAME_INODE (&(a), &(b))
+
+/* True if *A and *B represent the same file.  Unlike PSAME_INODE,
+   args are evaluated once and must point to struct stat.  */
+
+SAME_INODE_INLINE bool
+psame_inode (struct stat const *a, struct stat const *b)
+{
+  return PSAME_INODE (a, b);
+}
+
+_GL_INLINE_HEADER_END
 
 #endif
index 65c9d4ffa3388db41b70471ea563d51f23162644..82a5cc3cff408cbe98b5501b86bba1ade210537f 100644 (file)
@@ -111,7 +111,7 @@ same_nameat (int source_dfd, char const *source,
       int destdir_fd = openat (dest_dfd, dest_dirname, open_flags);
       if (destdir_fd < 0 || fstat (destdir_fd, &dest_dir_stats) != 0)
         destdir_errno = errno;
-      else if (SAME_INODE (source_dir_stats, dest_dir_stats))
+      else if (psame_inode (&source_dir_stats, &dest_dir_stats))
         {
           same = identical_basenames;
           if (! same)
@@ -138,7 +138,7 @@ same_nameat (int source_dfd, char const *source,
           /* Shouldn't happen.  */
           error (1, errno, "%s", dest_dirname);
         }
-      same = SAME_INODE (source_dir_stats, dest_dir_stats);
+      same = psame_inode (&source_dir_stats, &dest_dir_stats);
 #endif
 
       free (dest_dirname);
index bda00b7289b1dd3de37e280b488f70e435c78e85..8f2b47f3e491e1d49f49a973058eea7550ec8936 100644 (file)
@@ -1,4 +1,4 @@
-/* macros useful in interpreting size-related values in struct stat.
+/* Yield size-related values in struct stat.
    Copyright (C) 1989, 1991-2023 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
-/*
-   Macros defined by this file (s is an rvalue of type struct stat):
 
-   DEV_BSIZE:       The device blocksize.  But use ST_NBLOCKSIZE instead.
-   ST_BLKSIZE(s):   Preferred (in the sense of best performance) I/O blocksize
-                    for the file, in bytes.
-   ST_NBLOCKS(s):   Number of blocks in the file, including indirect blocks.
-   ST_NBLOCKSIZE:   Size of blocks used when calculating ST_NBLOCKS.
- */
 #ifndef STAT_SIZE_H
 #define STAT_SIZE_H
 
@@ -35,8 +27,8 @@
 # include <sys/param.h>
 #endif
 
-
-/* Get or fake the disk device blocksize.
+/* The device blocksize, or a faked version thereof.
+   But use ST_NBLOCKSIZE instead.
    Usually defined by sys/param.h (if at all).  */
 #if !defined DEV_BSIZE && defined BSIZE
 # define DEV_BSIZE BSIZE
 # define DEV_BSIZE 4096
 #endif
 
-
-
-/* Extract or fake data from a 'struct stat'.
-   ST_BLKSIZE: Preferred I/O blocksize for the file, in bytes.
-   ST_NBLOCKS: Number of blocks in the file, including indirect blocks.
+/* Extract or fake data from a struct stat *st.
+   STP_BLKSIZE(st): Preferred performance I/O blocksize, in bytes.
+   STP_NBLOCKS(st): Number of blocks, including indirect blocks.
    ST_NBLOCKSIZE: Size of blocks used when calculating ST_NBLOCKS.  */
 #ifndef HAVE_STRUCT_STAT_ST_BLOCKS
-# define ST_BLKSIZE(statbuf) DEV_BSIZE
+# define STP_BLKSIZE(st) DEV_BSIZE
   /* coreutils' fileblocks.c also uses BSIZE.  */
 # if defined _POSIX_SOURCE || !defined BSIZE
-#  define ST_NBLOCKS(statbuf) \
-  ((statbuf).st_size / ST_NBLOCKSIZE + ((statbuf).st_size % ST_NBLOCKSIZE != 0))
+#  define STP_NBLOCKS(st) \
+    ((st)->st_size / ST_NBLOCKSIZE + ((st)->st_size % ST_NBLOCKSIZE != 0))
 # else
    /* This definition calls st_blocks, which is in the fileblocks module. */
-#  define ST_NBLOCKS(statbuf) \
-  (S_ISREG ((statbuf).st_mode) || S_ISDIR ((statbuf).st_mode) ? \
-   st_blocks ((statbuf).st_size) : 0)
+#  define STP_NBLOCKS(st) \
+    (S_ISREG ((st)->st_mode) || S_ISDIR ((st)->st_mode) \
+     ? st_blocks ((st)->st_size) : 0)
 # endif
 #else
 /* When running 'rsh hpux11-system cat any-file', cat would
@@ -75,9 +65,9 @@
    suffice, since "cat" sometimes multiplies the result by 4.)  If
    anyone knows of a system for which this limit is too small, please
    report it as a bug in this code.  */
-# define ST_BLKSIZE(statbuf) ((0 < (statbuf).st_blksize \
-                               && (statbuf).st_blksize <= ((size_t)-1) / 8 + 1) \
-                              ? (statbuf).st_blksize : DEV_BSIZE)
+# define STP_BLKSIZE(st) ((0 < (st)->st_blksize \
+                           && (st)->st_blksize <= (size_t) -1 / 8 + 1)  \
+                          ? (st)->st_blksize : DEV_BSIZE)
 # if defined hpux || defined __hpux__ || defined __hpux
   /* HP-UX counts st_blocks in 1024-byte units.
      This loses when mixing HP-UX and BSD file systems with NFS.  */
@@ -85,8 +75,8 @@
 # endif
 #endif
 
-#ifndef ST_NBLOCKS
-# define ST_NBLOCKS(statbuf) ((statbuf).st_blocks)
+#ifndef STP_NBLOCKS
+# define STP_NBLOCKS(st) ((st)->st_blocks)
 #endif
 
 #ifndef ST_NBLOCKSIZE
@@ -97,4 +87,8 @@
 # endif
 #endif
 
+/* Preferred blocksize and number of blocks for a struct stat object.  */
+#define ST_BLKSIZE(statbuf) STP_BLKSIZE (&(statbuf))
+#define ST_NBLOCKS(statbuf) STP_NBLOCKS (&(statbuf))
+
 #endif /* STAT_SIZE_H */
index 18259c827c65538511a2f94dc19fe0d24d1f6856..454e72e38355657dd5d072fff81ad01e03db49d3 100644 (file)
@@ -225,7 +225,10 @@ log_signal_handler_called (int sig)
 
 #else
 
-# define log_signal_handler_called(sig)
+static void
+log_signal_handler_called (_GL_UNUSED int sig)
+{
+}
 
 #endif
 
@@ -970,7 +973,7 @@ activate_term_style_controller (const struct term_style_controller *controller,
       if (fd == STDERR_FILENO
           || (fstat (fd, &statbuf1) >= 0
               && fstat (STDERR_FILENO, &statbuf2) >= 0
-              && SAME_INODE (statbuf1, statbuf2)))
+              && psame_inode (&statbuf1, &statbuf2)))
         control_data->same_as_stderr = true;
       else
         control_data->same_as_stderr = false;
index 73a0e32abbbc7249a4d449f508f0c589e64b2493..409ee7225b7a7c8ac0e08404d63dba1a2127242c 100644 (file)
@@ -1,4 +1,5 @@
 Files:
+m4/musl.m4
 tests/test-canonicalize-lgpl.c
 tests/signature.h
 tests/null-ptr.h
@@ -10,6 +11,7 @@ same-inode
 symlink
 
 configure.ac:
+gl_MUSL_LIBC
 
 Makefile.am:
 TESTS += test-canonicalize-lgpl
index 53964d0409d2998501729ff431c487250e417fea..f31ade64fc3bd2a56f1bb1ea9534a9f78a1b2730 100644 (file)
@@ -2,14 +2,18 @@ Description:
 compare inodes
 
 Files:
+lib/same-inode.c
 lib/same-inode.h
 
 Depends-on:
+extern-inline
+stdbool
 sys_types
 
 configure.ac:
 
 Makefile.am:
+lib_SOURCES += same-inode.h same-inode.c
 
 Include:
 "same-inode.h"
index a474d37179ed4d9992d07aff01704469d9dac6df..97b2f27bda3ddf06916a93997d193d3e1a02537a 100644 (file)
@@ -30,7 +30,7 @@
 #include "macros.h"
 
 int
-main (int argc, char *argv[])
+main (_GL_UNUSED int argc, char *argv[])
 {
   /* Test the O_BINARY macro.  */
   {
index 9d249dff54299cbde4d737c08df9eed7f3617ec2..1216ee212c7182b700c7474cdcba575efb310888 100644 (file)
@@ -261,16 +261,18 @@ main (void)
     ASSERT (result2);
     ASSERT (stat ("/", &st1) == 0);
     ASSERT (stat ("//", &st2) == 0);
-    /* On IBM z/OS, "/" and "//" are distinct, yet they both have
-       st_dev == st_ino == 1.  */
-#ifndef __MVS__
-    if (SAME_INODE (st1, st2))
+    bool same = psame_inode (&st1, &st2);
+#if defined __MVS__ || defined MUSL_LIBC
+    /* On IBM z/OS and musl libc, "/" and "//" both canonicalize to
+       themselves, yet they both have st_dev == st_ino == 1.  */
+    same = false;
+#endif
+    if (same)
       {
         ASSERT (strcmp (result1, "/") == 0);
         ASSERT (strcmp (result2, "/") == 0);
       }
     else
-#endif
       {
         ASSERT (strcmp (result1, "//") == 0);
         ASSERT (strcmp (result2, "//") == 0);
index 8c5207ff7d1a441d94fc1e67c8936892c11b40d2..5a2ea998dc3a918dd73574dbbc4bde42814fe04a 100644 (file)
@@ -393,7 +393,13 @@ main (void)
     ASSERT (result4);
     ASSERT (stat ("/", &st1) == 0);
     ASSERT (stat ("//", &st2) == 0);
-    if (SAME_INODE (st1, st2))
+    bool same = psame_inode (&st1, &st2);
+#if defined __MVS__ || defined MUSL_LIBC
+    /* On IBM z/OS and musl libc, "/" and "//" both canonicalize to
+       themselves, yet they both have st_dev == st_ino == 1.  */
+    same = false;
+#endif
+    if (same)
       {
         ASSERT (strcmp (result1, "/") == 0);
         ASSERT (strcmp (result2, "/") == 0);
index e8c8eb61a68e2c3574a0661daa0c56b280377b01..b859db03eec569302b1c1ab2e641d4b0fdaf8046 100644 (file)
@@ -62,8 +62,12 @@ is_inheritable (int fd)
 }
 
 #if !O_BINARY
-# define set_binary_mode(f,m) zero ()
-static int zero (void) { return 0; }
+# define set_binary_mode my_set_binary_mode
+static int
+set_binary_mode (_GL_UNUSED int fd, _GL_UNUSED int mode)
+{
+  return 0;
+}
 #endif
 
 /* Return non-zero if FD is open in the given MODE, which is either
index c2de3003ffb094b1cf56237a64de94cde8e3ba7f..334f82c3b1997979782d89469da08255034be176 100644 (file)
 #endif
 
 #if !O_BINARY
-# define set_binary_mode(f,m) zero ()
-static int zero (void) { return 0; }
+# define set_binary_mode my_set_binary_mode
+static int
+set_binary_mode (_GL_UNUSED int fd, _GL_UNUSED int mode)
+{
+  return 0;
+}
 #endif
 
 /* This test intentionally closes stderr.  So, we arrange to have fd 10
index 8acbc038caec0b9bb2ae330ccd8a73bd82000ae4..8d2467f49312cceb43550532aa13ca5f92104b8a 100644 (file)
@@ -98,8 +98,12 @@ is_inheritable (int fd)
 #endif /* GNULIB_TEST_CLOEXEC */
 
 #if !O_BINARY
-# define set_binary_mode(f,m) zero ()
-static int zero (void) { return 0; }
+# define set_binary_mode my_set_binary_mode
+static int
+set_binary_mode (_GL_UNUSED int fd, _GL_UNUSED int mode)
+{
+  return 0;
+}
 #endif
 
 /* Return non-zero if FD is open in the given MODE, which is either
index 697e783eee2a789150b47a1d459c79855a4288d7..463b1915c43c939e82e34718e0113b4399d035da 100644 (file)
@@ -31,7 +31,7 @@ print_no_progname (void)
 }
 
 int
-main (int argc, char *argv[])
+main ()
 {
   /* Test error() function with zero STATUS and zero ERRNUM.  */
   error (0, 0, "bummer");
index 5fb554afe74dfc42688986ceecb27de3630402fd..7b63cc7ceddf6a62a81b3f42753b989d177500da 100644 (file)
@@ -51,8 +51,12 @@ SIGNATURE_CHECK (fcntl, int, (int, int, ...));
 #endif
 
 #if !O_BINARY
-# define set_binary_mode(f,m) zero ()
-static int zero (void) { return 0; }
+# define set_binary_mode my_set_binary_mode
+static int
+set_binary_mode (_GL_UNUSED int fd, _GL_UNUSED int mode)
+{
+  return 0;
+}
 #endif
 
 /* Return true if FD is open.  */
@@ -217,7 +221,7 @@ check_flags (void)
 }
 
 int
-main (int argc, char *argv[])
+main (int argc, _GL_UNUSED char *argv[])
 {
   if (argc > 1)
     /* child process */
index 41b15f3e77e2bdd44f66b5f77c4f92b96067641c..88b912cf5dcaf2a7731fa909f4e036fff3404b93 100644 (file)
@@ -30,7 +30,7 @@ SIGNATURE_CHECK (fdopendir, DIR *, (int));
 #include "macros.h"
 
 int
-main (_GL_UNUSED int argc, char *argv[])
+main ()
 {
   DIR *d;
   int fd;
index c8c65f58aab4c2bfdec2c6d750f2dbd1e91296c5..169451410b7c1598b6e5d1bd5dfe70cab4497173 100644 (file)
@@ -32,7 +32,7 @@ SIGNATURE_CHECK (fgetc, int, (FILE *));
 #include "macros.h"
 
 int
-main (int argc, char **argv)
+main ()
 {
   const char *filename = "test-fgetc.txt";
 
index 3a9e7c38ac7ac0dddfbdc6446546ce1e6096d873..ae7c718014b4624aa238dedbaf928df91cc19f12 100644 (file)
@@ -32,7 +32,7 @@ SIGNATURE_CHECK (fputc, int, (int, FILE *));
 #include "macros.h"
 
 int
-main (int argc, char **argv)
+main ()
 {
   const char *filename = "test-fputc.txt";
 
index d6d16ec3d91a01ef7a98395b8bf8a721fc94db63..8bdb551487f06e9a2f61869e9d222ea3a34fc079 100644 (file)
@@ -32,7 +32,7 @@ SIGNATURE_CHECK (fread, size_t, (void *, size_t, size_t, FILE *));
 #include "macros.h"
 
 int
-main (int argc, char **argv)
+main ()
 {
   const char *filename = "test-fread.txt";
 
index 59c2dc4d1a08bb70c8b541d698bfc9f3613ef865..9a7b521f8e53fdb49b19c79ab998a8cdff743ee2 100644 (file)
@@ -27,7 +27,7 @@ SIGNATURE_CHECK (fstat, int, (int, struct stat *));
 #include "macros.h"
 
 int
-main (int argc, char *argv[])
+main ()
 {
   /* Test behaviour for invalid file descriptors.  */
   {
index fe8a6940764dbfa66f8d4acf8742ea225999b314..684681d3897d6c9abd8f81c1ce2617cc6c99c1db 100644 (file)
@@ -66,7 +66,7 @@ do_lstat (char const *name, struct stat *st)
 }
 
 int
-main (_GL_UNUSED int argc, char *argv[])
+main (_GL_UNUSED int argc, _GL_UNUSED char *argv[])
 {
   int result;
 
index bcd63932fa1785cc03b705fec86d212c172668f1..ae6444a557ccb31003204fc979138b15b89d8c6e 100644 (file)
@@ -27,7 +27,7 @@ SIGNATURE_CHECK (ftruncate, int, (int, off_t));
 #include "macros.h"
 
 int
-main (int argc, char *argv[])
+main (_GL_UNUSED int argc, char *argv[])
 {
   const char *filename = argv[1];
 
index 503e849b4778e01aa940d9d31dcb5bdb0a2f4faf..4e097fff7ad38dc8e08a83e8cbad0c7646a4d083 100644 (file)
@@ -32,7 +32,7 @@ SIGNATURE_CHECK (fwrite, size_t, (const void *, size_t, size_t, FILE *));
 #include "macros.h"
 
 int
-main (int argc, char **argv)
+main ()
 {
   const char *filename = "test-fwrite.txt";
 
index aa510d4e455822620a189643becda32d9264cfbd..090fa027235b8243d8523d79db7b51068fd14a75 100644 (file)
@@ -262,7 +262,7 @@ test_long_name (void)
 }
 
 int
-main (int argc, char **argv)
+main ()
 {
   int err1 = test_abort_bug ();
   int err2 = test_long_name ();
index d2c93f19a401df18a3331bfbe78b627506f9b70b..82f3a19535740d06659da483ea04298e2cdac9e7 100644 (file)
@@ -31,7 +31,7 @@ SIGNATURE_CHECK (getdtablesize, int, (void));
 #endif
 
 int
-main (int argc, char *argv[])
+main ()
 {
   ASSERT (getdtablesize () >= 3);
   ASSERT (dup2 (0, getdtablesize() - 1) == getdtablesize () - 1);
index 5f2a1838f88c4db7fad39a3dae413ad51061fdc9..6f20716202002c199e468510309b4bd6bc60e9da 100644 (file)
@@ -29,7 +29,7 @@ SIGNATURE_CHECK (isblank, int, (int));
 #include "macros.h"
 
 int
-main (int argc, char *argv[])
+main ()
 {
   unsigned int c;
 
index 44c1bb945e3a73708846f520515fe0e3d1f74a3e..4c8d365d8821316aa4d88bc4fce61f0fc6f3eabd 100644 (file)
@@ -78,7 +78,7 @@ check_same_link (char const *name1, char const *name2)
   ASSERT (contents2);
   ASSERT (strcmp (contents1, contents2) == 0);
   if (EXPECT_LINK_HARDLINKS_SYMLINKS)
-    ASSERT (SAME_INODE (st1, st2));
+    ASSERT (psame_inode (&st1, &st2));
   free (contents1);
   free (contents2);
 }
index b52f7e0cd85562f3ac38a84f3ffccb9cb983366a..d7fcec02357d1132a4696d4dd523d124685f3a72 100644 (file)
@@ -143,7 +143,7 @@ check_accounts (void)
 gl_lock_define_initialized(static, my_lock)
 
 static void *
-lock_mutator_thread (void *arg)
+lock_mutator_thread (_GL_UNUSED void *arg)
 {
   int repeat;
 
@@ -181,7 +181,7 @@ lock_mutator_thread (void *arg)
 static struct atomic_int lock_checker_done;
 
 static void *
-lock_checker_thread (void *arg)
+lock_checker_thread (_GL_UNUSED void *arg)
 {
   while (get_atomic_int_value (&lock_checker_done) == 0)
     {
@@ -234,7 +234,7 @@ test_lock (void)
 gl_rwlock_define_initialized(static, my_rwlock)
 
 static void *
-rwlock_mutator_thread (void *arg)
+rwlock_mutator_thread (_GL_UNUSED void *arg)
 {
   int repeat;
 
@@ -266,7 +266,7 @@ rwlock_mutator_thread (void *arg)
 static struct atomic_int rwlock_checker_done;
 
 static void *
-rwlock_checker_thread (void *arg)
+rwlock_checker_thread (_GL_UNUSED void *arg)
 {
   while (get_atomic_int_value (&rwlock_checker_done) == 0)
     {
@@ -345,7 +345,7 @@ recshuffle (void)
 }
 
 static void *
-reclock_mutator_thread (void *arg)
+reclock_mutator_thread (_GL_UNUSED void *arg)
 {
   int repeat;
 
@@ -369,7 +369,7 @@ reclock_mutator_thread (void *arg)
 static struct atomic_int reclock_checker_done;
 
 static void *
-reclock_checker_thread (void *arg)
+reclock_checker_thread (_GL_UNUSED void *arg)
 {
   while (get_atomic_int_value (&reclock_checker_done) == 0)
     {
index 8a367678c4335a7858e602d4663460ddd927596f..fb7287e4133de062ff94e36c9180a16a32fb3848 100644 (file)
@@ -32,14 +32,14 @@ test_lstat_func (int (*func) (char const *, struct stat *), bool print)
   ASSERT (func (".", &st1) == 0);
   ASSERT (func ("./", &st2) == 0);
 #if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES)
-  ASSERT (SAME_INODE (st1, st2));
+  ASSERT (psame_inode (&st1, &st2));
 #endif
   ASSERT (S_ISDIR (st1.st_mode));
   ASSERT (S_ISDIR (st2.st_mode));
   ASSERT (func ("/", &st1) == 0);
   ASSERT (func ("///", &st2) == 0);
 #if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES)
-  ASSERT (SAME_INODE (st1, st2));
+  ASSERT (psame_inode (&st1, &st2));
 #endif
   ASSERT (S_ISDIR (st1.st_mode));
   ASSERT (S_ISDIR (st2.st_mode));
@@ -90,7 +90,7 @@ test_lstat_func (int (*func) (char const *, struct stat *), bool print)
   ASSERT (S_ISDIR (st1.st_mode));
   ASSERT (S_ISDIR (st2.st_mode));
 #if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES)
-  ASSERT (SAME_INODE (st1, st2));
+  ASSERT (psame_inode (&st1, &st2));
 #endif
 
   ASSERT (func (BASE "link2", &st1) == 0);
index e2462dad48e043ca276182db0eb69752df55ca84..48284d0b342df16a7827c74d036e660fbe774ccc 100644 (file)
@@ -25,7 +25,7 @@
 #include "macros.h"
 
 int
-main (int argc, char **argv)
+main (int argc, _GL_UNUSED char **argv)
 {
   /* Check that malloc (0) is not a NULL pointer.  */
   void *volatile p = malloc (0);
index ff6cd988fc2bfc4c6d88beef5ebdd6272a124fa2..7a54fa8d58238f1bfd5dc170f8845b3d3d23f906 100644 (file)
@@ -57,7 +57,7 @@ do_open (char const *name, int flags, ...)
 }
 
 int
-main (_GL_UNUSED int argc, char *argv[])
+main ()
 {
   int result;
 
index 5a5bce569176145947c91b32c099eb1d32320487..02c637e9d1b2691a3f0b01d9bfb5ab2ba1a98934 100644 (file)
@@ -33,7 +33,7 @@ static pthread_t worker_thread;
 static volatile int work_done;
 
 static void *
-worker_thread_func (void *arg)
+worker_thread_func (_GL_UNUSED void *arg)
 {
   work_done = 1;
   return MAGIC;
index b1b6eb5ab9978b5c9cdd9122619baed726087491..06158f9d58b6d4d2bac994ffbc030af2d74400f9 100644 (file)
@@ -36,13 +36,13 @@ SIGNATURE_CHECK (pthread_sigmask, int, (int, const sigset_t *, sigset_t *));
 static volatile int sigint_occurred;
 
 static void
-sigint_handler (int sig)
+sigint_handler (_GL_UNUSED int sig)
 {
   sigint_occurred++;
 }
 
 int
-main (int argc, char *argv[])
+main ()
 {
   sigset_t set;
   pid_t pid = getpid ();
index 94f951f3234e8b3e87c924ceaf0880469dddeb33..f126690bca781054a842181a1e7aa5f8b8cbd931 100644 (file)
@@ -33,7 +33,7 @@ static pthread_t main_thread;
 static pthread_t killer_thread;
 
 static void *
-killer_thread_func (void *arg)
+killer_thread_func (_GL_UNUSED void *arg)
 {
   sleep (1);
   pthread_kill (main_thread, SIGINT);
@@ -43,13 +43,13 @@ killer_thread_func (void *arg)
 static volatile int sigint_occurred;
 
 static void
-sigint_handler (int sig)
+sigint_handler (_GL_UNUSED int sig)
 {
   sigint_occurred++;
 }
 
 int
-main (int argc, char *argv[])
+main ()
 {
   sigset_t set;
 
index 142b6a0a1d2baf61df16f7fc03f3c5b061fc1728..75647c352b062aa63e3ab990699d5fc9a450fcd4 100644 (file)
@@ -50,7 +50,7 @@ same_slave (const char *slave_name1, const char *slave_name2)
   return (strcmp (slave_name1, slave_name2) == 0
           || (stat (slave_name1, &statbuf1) >= 0
               && stat (slave_name2, &statbuf2) >= 0
-              && SAME_INODE (statbuf1, statbuf2)));
+              && psame_inode (&statbuf1, &statbuf2)));
 }
 
 int
index 9806b53eb7290dbd24c8397d5d1050cfffb19146..cd2605f618d017ccc36173de346aa7ad29201c92 100644 (file)
@@ -59,7 +59,7 @@ same_slave (const char *slave_name1, const char *slave_name2)
   return (strcmp (slave_name1, slave_name2) == 0
           || (stat (slave_name1, &statbuf1) >= 0
               && stat (slave_name2, &statbuf2) >= 0
-              && SAME_INODE (statbuf1, statbuf2)));
+              && psame_inode (&statbuf1, &statbuf2)));
 }
 
 static void
index 7574b2b4a43a340e0769c0eef0ce2f43d87487ac..97be64dd2ce7416553e582a2b5463ca27b4d71fa 100644 (file)
@@ -30,7 +30,7 @@ SIGNATURE_CHECK (raise, int, (int));
    exit() is a non-returning function, even on platforms where its declaration
    in <stdlib.h> does not have the 'noreturn' attribute.  */
 static _Noreturn void
-handler (int sig)
+handler (_GL_UNUSED int sig)
 {
   _exit (0);
 }
index 28afc628de0cd604085d50823022a152732a7b89..435f10b6102d9b2f12dade4df5e42206e5cb7255 100644 (file)
@@ -25,7 +25,7 @@
 #include "macros.h"
 
 int
-main (int argc, char **argv)
+main (int argc, _GL_UNUSED char **argv)
 {
   /* Check that realloc (NULL, 0) is not a NULL pointer.  */
   void *volatile p = realloc (NULL, 0);
index a5675317d3fbfd398f392e2523d149e5470c5d1d..26ff878f2ec01d01c6d713e9879b19df0dd9fec0 100644 (file)
@@ -73,7 +73,7 @@ static gl_thread_t timer;
 static gl_lock_t baton;
 
 static void *
-timer_func (void *ignored)
+timer_func (_GL_UNUSED void *ignored)
 {
   /* Step 13 (can be before or after step 12):
      The timer thread takes the baton, then waits a moment to make sure
@@ -87,7 +87,7 @@ timer_func (void *ignored)
 }
 
 static void *
-reader2_func (void *ignored)
+reader2_func (_GL_UNUSED void *ignored)
 {
   int err;
 
@@ -113,7 +113,7 @@ reader2_func (void *ignored)
 }
 
 static void *
-writer_func (void *ignored)
+writer_func (_GL_UNUSED void *ignored)
 {
   /* Step 4: Take the baton, so that the second reader thread does not go ahead
      too early.  */
index b6d0114c8b08027bc2321c587c295952764056f0..640a8e2eb0545a9bf99e1cb597504042888d813d 100644 (file)
@@ -36,13 +36,13 @@ SIGNATURE_CHECK (sigprocmask, int, (int, const sigset_t *, sigset_t *));
 static volatile int sigint_occurred;
 
 static void
-sigint_handler (int sig)
+sigint_handler (_GL_UNUSED int sig)
 {
   sigint_occurred++;
 }
 
 int
-main (int argc, char *argv[])
+main ()
 {
   sigset_t set;
   pid_t pid = getpid ();
index d106ad65dd06d072605fcd7d61c35e9f93a159ec..3b679254880b70b27e69237cd2319a157055f4dd 100644 (file)
@@ -28,7 +28,7 @@ SIGNATURE_CHECK (snprintf, int, (char *, size_t, char const *, ...));
 #include "macros.h"
 
 int
-main (int argc, char *argv[])
+main ()
 {
   char buf[8];
   int size;
index f2132c2a35e92ee08fa59ad30caf76a080f3386e..7cdc44b8f690bfda5391c72ff47ea24832d4aecd 100644 (file)
@@ -33,16 +33,16 @@ test_stat_func (int (*func) (char const *, struct stat *), bool print)
   ASSERT (func (".", &st1) == 0);
   ASSERT (func ("./", &st2) == 0);
 #if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES)
-  ASSERT (SAME_INODE (st1, st2));
+  ASSERT (psame_inode (&st1, &st2));
 #endif
   ASSERT (func (cwd, &st2) == 0);
 #if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES)
-  ASSERT (SAME_INODE (st1, st2));
+  ASSERT (psame_inode (&st1, &st2));
 #endif
   ASSERT (func ("/", &st1) == 0);
   ASSERT (func ("///", &st2) == 0);
 #if !(defined _WIN32 && !defined __CYGWIN__ && !_GL_WINDOWS_STAT_INODES)
-  ASSERT (SAME_INODE (st1, st2));
+  ASSERT (psame_inode (&st1, &st2));
 #endif
 
   errno = 0;
index b9004ea41d2560ba12e9ce71a27f7a45fbb3af55..0db9dc49847fe128b1b6ea61ed82b9ac6680a8bf 100644 (file)
@@ -56,7 +56,7 @@ get_control_data (struct term_style_user_data *user_data)
 }
 
 static void
-restore (struct term_style_user_data *user_data)
+restore (_GL_UNUSED struct term_style_user_data *user_data)
 {
   fputs (set_underline_off, stdout);
   fputs (set_background_color_default, stdout);
@@ -64,7 +64,7 @@ restore (struct term_style_user_data *user_data)
 }
 
 static _GL_ASYNC_SAFE void
-async_restore (struct term_style_user_data *user_data)
+async_restore (_GL_UNUSED struct term_style_user_data *user_data)
 {
   /* No <stdio.h> calls here!  */
   full_write (STDOUT_FILENO, set_underline_off,
@@ -94,7 +94,7 @@ static const struct term_style_controller controller =
 };
 
 int
-main (int argc, char *argv[])
+main ()
 {
   struct term_style_user_data user_data;
 
index 118434c99fb8b11696a60d1cd34f50f27b2c55a2..830e8d5c7190f5052d9c47cf0826154a84222955 100644 (file)
@@ -57,7 +57,7 @@ get_control_data (struct term_style_user_data *user_data)
 }
 
 static void
-restore (struct term_style_user_data *user_data)
+restore (_GL_UNUSED struct term_style_user_data *user_data)
 {
   fputs (set_underline_off, stdout);
   fputs (set_foreground_color_default, stdout);
@@ -65,7 +65,7 @@ restore (struct term_style_user_data *user_data)
 }
 
 static _GL_ASYNC_SAFE void
-async_restore (struct term_style_user_data *user_data)
+async_restore (_GL_UNUSED struct term_style_user_data *user_data)
 {
   /* No <stdio.h> calls here!  */
   full_write (STDOUT_FILENO, set_underline_off,
@@ -96,7 +96,7 @@ static const struct term_style_controller controller =
 };
 
 int
-main (int argc, char *argv[])
+main ()
 {
   struct term_style_user_data user_data;
 
index 9312d8e9101950b410a88466028573aac94c958f..d23f0107803ba40eaab88f8d6375e1414326d277 100644 (file)
@@ -33,7 +33,7 @@ static int dummy;
 static volatile int work_done;
 
 static void *
-worker_thread_func (void *arg)
+worker_thread_func (_GL_UNUSED void *arg)
 {
   work_done = 1;
   return &dummy;
index 22c17e7aedd4bfb1a500165a78fb43d1a661b333..a21fb465a2146c3deed2993a7914fb0392a71245 100644 (file)
@@ -55,7 +55,7 @@ unlinker (char const *name)
 }
 
 int
-main (_GL_UNUSED int argc, char *argv[])
+main ()
 {
   /* FIXME: Add tests of fd other than ".".  */
   int result1;
index 635654bb13658737f22f1760bbe3f4a9864f436b..97ed573de28ae748c03de2e01a948fe6d42abc6a 100644 (file)
@@ -113,7 +113,7 @@ test_asnprintf ()
 }
 
 int
-main (int argc, char *argv[])
+main ()
 {
   test_vasnprintf ();
   test_asnprintf ();
index 07dcb1dbda3e09bb04718081ca5ee2b481b1aeb7..10b5abfa42d8d32cb0bc1d162491fefc355c71d2 100644 (file)
@@ -21,7 +21,7 @@
 #include "xalloc.h"
 
 int
-main (_GL_UNUSED int argc, char **argv)
+main ()
 {
   xalloc_die ();
   return 0;
index edcf3c7049cc3fdd86bb7c2e515bfa4fb1224e57..1173b64d10379aca6578d38eeb9ce43ccf4ce5f5 100644 (file)
@@ -998,12 +998,12 @@ sc_prohibit_empty_lines_at_EOF:
               exit 1; }                                                \
          || :
 
-# Make sure we don't use st_blocks.  Use ST_NBLOCKS instead.
+# Make sure we don't use st_blocks.  Use ST_NBLOCKS or STP_NBLOCKS instead.
 # This is a bit of a kludge, since it prevents use of the string
 # even in comments, but for now it does the job with no false positives.
 sc_prohibit_stat_st_blocks:
        @prohibit='[.>]st_blocks'                                       \
-       halt='do not use st_blocks; use ST_NBLOCKS'                     \
+       halt='do not use st_blocks; use ST_NBLOCKS or STP_NBLOCKS'      \
          $(_sc_search_regexp)
 
 # Make sure we don't define any S_IS* macros in src/*.c files.