+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.
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.
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}.
@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:
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.
@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.
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. */
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. */
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. */
}
}
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. */
}
struct stat sb1, sb2;
return (fstat (fd1, &sb1) == 0
&& fstat (fd2, &sb2) == 0
- && SAME_INODE (sb1, sb2));
+ && psame_inode (&sb1, &sb2));
}
static void
{
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. */
{
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);
}
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;
--- /dev/null
+#include <config.h>
+#define SAME_INODE_INLINE _GL_EXTERN_INLINE
+#include "same-inode.h"
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
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)
/* 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);
-/* 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
# 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
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. */
# 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
# 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 */
#else
-# define log_signal_handler_called(sig)
+static void
+log_signal_handler_called (_GL_UNUSED int sig)
+{
+}
#endif
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;
Files:
+m4/musl.m4
tests/test-canonicalize-lgpl.c
tests/signature.h
tests/null-ptr.h
symlink
configure.ac:
+gl_MUSL_LIBC
Makefile.am:
TESTS += test-canonicalize-lgpl
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"
#include "macros.h"
int
-main (int argc, char *argv[])
+main (_GL_UNUSED int argc, char *argv[])
{
/* Test the O_BINARY macro. */
{
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);
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);
}
#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
#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
#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
}
int
-main (int argc, char *argv[])
+main ()
{
/* Test error() function with zero STATUS and zero ERRNUM. */
error (0, 0, "bummer");
#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. */
}
int
-main (int argc, char *argv[])
+main (int argc, _GL_UNUSED char *argv[])
{
if (argc > 1)
/* child process */
#include "macros.h"
int
-main (_GL_UNUSED int argc, char *argv[])
+main ()
{
DIR *d;
int fd;
#include "macros.h"
int
-main (int argc, char **argv)
+main ()
{
const char *filename = "test-fgetc.txt";
#include "macros.h"
int
-main (int argc, char **argv)
+main ()
{
const char *filename = "test-fputc.txt";
#include "macros.h"
int
-main (int argc, char **argv)
+main ()
{
const char *filename = "test-fread.txt";
#include "macros.h"
int
-main (int argc, char *argv[])
+main ()
{
/* Test behaviour for invalid file descriptors. */
{
}
int
-main (_GL_UNUSED int argc, char *argv[])
+main (_GL_UNUSED int argc, _GL_UNUSED char *argv[])
{
int result;
#include "macros.h"
int
-main (int argc, char *argv[])
+main (_GL_UNUSED int argc, char *argv[])
{
const char *filename = argv[1];
#include "macros.h"
int
-main (int argc, char **argv)
+main ()
{
const char *filename = "test-fwrite.txt";
}
int
-main (int argc, char **argv)
+main ()
{
int err1 = test_abort_bug ();
int err2 = test_long_name ();
#endif
int
-main (int argc, char *argv[])
+main ()
{
ASSERT (getdtablesize () >= 3);
ASSERT (dup2 (0, getdtablesize() - 1) == getdtablesize () - 1);
#include "macros.h"
int
-main (int argc, char *argv[])
+main ()
{
unsigned int c;
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);
}
gl_lock_define_initialized(static, my_lock)
static void *
-lock_mutator_thread (void *arg)
+lock_mutator_thread (_GL_UNUSED void *arg)
{
int repeat;
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)
{
gl_rwlock_define_initialized(static, my_rwlock)
static void *
-rwlock_mutator_thread (void *arg)
+rwlock_mutator_thread (_GL_UNUSED void *arg)
{
int repeat;
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)
{
}
static void *
-reclock_mutator_thread (void *arg)
+reclock_mutator_thread (_GL_UNUSED void *arg)
{
int repeat;
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)
{
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));
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);
#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);
}
int
-main (_GL_UNUSED int argc, char *argv[])
+main ()
{
int result;
static volatile int work_done;
static void *
-worker_thread_func (void *arg)
+worker_thread_func (_GL_UNUSED void *arg)
{
work_done = 1;
return MAGIC;
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 ();
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);
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;
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
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
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);
}
#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);
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
}
static void *
-reader2_func (void *ignored)
+reader2_func (_GL_UNUSED void *ignored)
{
int err;
}
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. */
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 ();
#include "macros.h"
int
-main (int argc, char *argv[])
+main ()
{
char buf[8];
int size;
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;
}
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);
}
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,
};
int
-main (int argc, char *argv[])
+main ()
{
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);
}
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,
};
int
-main (int argc, char *argv[])
+main ()
{
struct term_style_user_data user_data;
static volatile int work_done;
static void *
-worker_thread_func (void *arg)
+worker_thread_func (_GL_UNUSED void *arg)
{
work_done = 1;
return &dummy;
}
int
-main (_GL_UNUSED int argc, char *argv[])
+main ()
{
/* FIXME: Add tests of fd other than ".". */
int result1;
}
int
-main (int argc, char *argv[])
+main ()
{
test_vasnprintf ();
test_asnprintf ();
#include "xalloc.h"
int
-main (_GL_UNUSED int argc, char **argv)
+main ()
{
xalloc_die ();
return 0;
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.