* [PATCH 7/7] lib: remove random.c
2025-02-06 21:19 [PATCH 0/7] fstests: enable sparse checking & fix fallout Eric Sandeen
@ 2025-02-06 21:20 ` Eric Sandeen
2025-02-06 22:47 ` Darrick J. Wong
2025-02-07 5:01 ` Christoph Hellwig
0 siblings, 2 replies; 20+ messages in thread
From: Eric Sandeen @ 2025-02-06 21:20 UTC (permalink / raw)
To: fstests; +Cc: Eric Sandeen
sparse points out that lots of things in random.c could be static,
and upon doing so we realize that nothing in this file is used.
Which is unsurprising since these are all part of the standard
C library ... so just remove the file.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
lib/Makefile | 5 +-
lib/random.c | 224 ---------------------------------------------------
2 files changed, 2 insertions(+), 227 deletions(-)
delete mode 100644 lib/random.c
diff --git a/lib/Makefile b/lib/Makefile
index 53540ca7..ce4381a2 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -11,13 +11,12 @@ LT_REVISION = 0
LT_AGE = 0
#
-# Everything (except for random.c) copied directly from LTP.
+# Everything copied directly from LTP.
# Refer to http://ltp.sourceforge.net/ for complete source.
#
CFILES = dataascii.c databin.c datapid.c file_lock.c forker.c \
pattern.c open_flags.c random_range.c string_to_tokens.c \
- str_to_bytes.c tlibio.c write_log.c \
- random.c
+ str_to_bytes.c tlibio.c write_log.c
default: depend $(LTLIBRARY)
diff --git a/lib/random.c b/lib/random.c
deleted file mode 100644
index d5c81be8..00000000
--- a/lib/random.c
+++ /dev/null
@@ -1,224 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * random.c -- pseudo random number generator
- * Copyright (C) 1994 Chris Wallace (csw@bruce.cs.monash.edu.au)
- */
-
-#include <sys/types.h>
-
-/*
- * modified by dxm@sgi.com so that this file acts as a drop in replacement
- * for srandom and random.
- */
-
-/*
- * A random number generator called as a function by
- * random (iseed) or irandm (iseed)
- * The parameter should be a pointer to a 2-element int32_t vector.
- * The first function returns a double uniform in 0 .. 1.
- * The second returns a int32_t integer uniform in 0 .. 2**31-1
- * Both update iseed[] in exactly the same way.
- * iseed[] must be a 2-element integer vector.
- * The initial value of the second element may be anything.
- *
- * The period of the random sequence is 2**32 * (2**32-1)
- * The table mt[0:127] is defined by mt[i] = 69069 ** (128-i)
- */
-
-#define MASK ((int32_t) 593970775)
-/* or in hex, 23674657 */
-
-#define SCALE ((double) 1.0 / (1024.0 * 1024.0 * 1024.0 * 2.0))
-/* i.e. 2 to power -31 */
-
-static int32_t mt [128] = {
- 902906369,
- 2030498053,
- -473499623,
- 1640834941,
- 723406961,
- 1993558325,
- -257162999,
- -1627724755,
- 913952737,
- 278845029,
- 1327502073,
- -1261253155,
- 981676113,
- -1785280363,
- 1700077033,
- 366908557,
- -1514479167,
- -682799163,
- 141955545,
- -830150595,
- 317871153,
- 1542036469,
- -946413879,
- -1950779155,
- 985397153,
- 626515237,
- 530871481,
- 783087261,
- -1512358895,
- 1031357269,
- -2007710807,
- -1652747955,
- -1867214463,
- 928251525,
- 1243003801,
- -2132510467,
- 1874683889,
- -717013323,
- 218254473,
- -1628774995,
- -2064896159,
- 69678053,
- 281568889,
- -2104168611,
- -165128239,
- 1536495125,
- -39650967,
- 546594317,
- -725987007,
- 1392966981,
- 1044706649,
- 687331773,
- -2051306575,
- 1544302965,
- -758494647,
- -1243934099,
- -75073759,
- 293132965,
- -1935153095,
- 118929437,
- 807830417,
- -1416222507,
- -1550074071,
- -84903219,
- 1355292929,
- -380482555,
- -1818444007,
- -204797315,
- 170442609,
- -1636797387,
- 868931593,
- -623503571,
- 1711722209,
- 381210981,
- -161547783,
- -272740131,
- -1450066095,
- 2116588437,
- 1100682473,
- 358442893,
- -1529216831,
- 2116152005,
- -776333095,
- 1265240893,
- -482278607,
- 1067190005,
- 333444553,
- 86502381,
- 753481377,
- 39000101,
- 1779014585,
- 219658653,
- -920253679,
- 2029538901,
- 1207761577,
- -1515772851,
- -236195711,
- 442620293,
- 423166617,
- -1763648515,
- -398436623,
- -1749358155,
- -538598519,
- -652439379,
- 430550625,
- -1481396507,
- 2093206905,
- -1934691747,
- -962631983,
- 1454463253,
- -1877118871,
- -291917555,
- -1711673279,
- 201201733,
- -474645415,
- -96764739,
- -1587365199,
- 1945705589,
- 1303896393,
- 1744831853,
- 381957665,
- 2135332261,
- -55996615,
- -1190135011,
- 1790562961,
- -1493191723,
- 475559465,
- 69069
- };
-
-double
-_random (int32_t is [2])
-{
- int32_t it, leh, nit;
-
- it = is [0];
- leh = is [1];
- if (it <= 0)
- it = (it + it) ^ MASK;
- else
- it = it + it;
- nit = it - 1;
-/* to ensure all-ones pattern omitted */
- leh = leh * mt[nit & 127] + nit;
- is [0] = it; is [1] = leh;
- if (leh < 0) leh = ~leh;
- return (SCALE * ((int32_t) (leh | 1)));
-}
-
-
-
-int32_t
-_irandm (int32_t is [2])
-{
- int32_t it, leh, nit;
-
- it = is [0];
- leh = is [1];
- if (it <= 0)
- it = (it + it) ^ MASK;
- else
- it = it + it;
- nit = it - 1;
-/* to ensure all-ones pattern omitted */
- leh = leh * mt[nit & 127] + nit;
- is [0] = it; is [1] = leh;
- if (leh < 0) leh = ~leh;
- return (leh);
-}
-
-/*
- * make this a drop in replacement for random and srandom
- *
- * XXX not thread safe I guess.
- */
-
-static int32_t saved_seed[2];
-
-long random(void)
-{
- return _irandm(saved_seed);
-}
-
-void srandom(unsigned seed)
-{
- saved_seed[0]=seed;
- saved_seed[1]=0;
- _irandm(saved_seed);
-}
-
--
2.48.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 7/7] lib: remove random.c
2025-02-06 21:20 ` [PATCH 7/7] lib: remove random.c Eric Sandeen
@ 2025-02-06 22:47 ` Darrick J. Wong
2025-02-07 5:01 ` Christoph Hellwig
1 sibling, 0 replies; 20+ messages in thread
From: Darrick J. Wong @ 2025-02-06 22:47 UTC (permalink / raw)
To: Eric Sandeen; +Cc: fstests
On Thu, Feb 06, 2025 at 03:20:02PM -0600, Eric Sandeen wrote:
> sparse points out that lots of things in random.c could be static,
> and upon doing so we realize that nothing in this file is used.
> Which is unsurprising since these are all part of the standard
> C library ... so just remove the file.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
> lib/Makefile | 5 +-
> lib/random.c | 224 ---------------------------------------------------
> 2 files changed, 2 insertions(+), 227 deletions(-)
Thus marks the return of Sandeen, Remover of Code!!
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> delete mode 100644 lib/random.c
>
> diff --git a/lib/Makefile b/lib/Makefile
> index 53540ca7..ce4381a2 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -11,13 +11,12 @@ LT_REVISION = 0
> LT_AGE = 0
>
> #
> -# Everything (except for random.c) copied directly from LTP.
> +# Everything copied directly from LTP.
> # Refer to http://ltp.sourceforge.net/ for complete source.
> #
> CFILES = dataascii.c databin.c datapid.c file_lock.c forker.c \
> pattern.c open_flags.c random_range.c string_to_tokens.c \
> - str_to_bytes.c tlibio.c write_log.c \
> - random.c
> + str_to_bytes.c tlibio.c write_log.c
>
> default: depend $(LTLIBRARY)
>
> diff --git a/lib/random.c b/lib/random.c
> deleted file mode 100644
> index d5c81be8..00000000
> --- a/lib/random.c
> +++ /dev/null
> @@ -1,224 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+
> -/*
> - * random.c -- pseudo random number generator
> - * Copyright (C) 1994 Chris Wallace (csw@bruce.cs.monash.edu.au)
> - */
> -
> -#include <sys/types.h>
> -
> -/*
> - * modified by dxm@sgi.com so that this file acts as a drop in replacement
> - * for srandom and random.
> - */
> -
> -/*
> - * A random number generator called as a function by
> - * random (iseed) or irandm (iseed)
> - * The parameter should be a pointer to a 2-element int32_t vector.
> - * The first function returns a double uniform in 0 .. 1.
> - * The second returns a int32_t integer uniform in 0 .. 2**31-1
> - * Both update iseed[] in exactly the same way.
> - * iseed[] must be a 2-element integer vector.
> - * The initial value of the second element may be anything.
> - *
> - * The period of the random sequence is 2**32 * (2**32-1)
> - * The table mt[0:127] is defined by mt[i] = 69069 ** (128-i)
> - */
> -
> -#define MASK ((int32_t) 593970775)
> -/* or in hex, 23674657 */
> -
> -#define SCALE ((double) 1.0 / (1024.0 * 1024.0 * 1024.0 * 2.0))
> -/* i.e. 2 to power -31 */
> -
> -static int32_t mt [128] = {
> - 902906369,
> - 2030498053,
> - -473499623,
> - 1640834941,
> - 723406961,
> - 1993558325,
> - -257162999,
> - -1627724755,
> - 913952737,
> - 278845029,
> - 1327502073,
> - -1261253155,
> - 981676113,
> - -1785280363,
> - 1700077033,
> - 366908557,
> - -1514479167,
> - -682799163,
> - 141955545,
> - -830150595,
> - 317871153,
> - 1542036469,
> - -946413879,
> - -1950779155,
> - 985397153,
> - 626515237,
> - 530871481,
> - 783087261,
> - -1512358895,
> - 1031357269,
> - -2007710807,
> - -1652747955,
> - -1867214463,
> - 928251525,
> - 1243003801,
> - -2132510467,
> - 1874683889,
> - -717013323,
> - 218254473,
> - -1628774995,
> - -2064896159,
> - 69678053,
> - 281568889,
> - -2104168611,
> - -165128239,
> - 1536495125,
> - -39650967,
> - 546594317,
> - -725987007,
> - 1392966981,
> - 1044706649,
> - 687331773,
> - -2051306575,
> - 1544302965,
> - -758494647,
> - -1243934099,
> - -75073759,
> - 293132965,
> - -1935153095,
> - 118929437,
> - 807830417,
> - -1416222507,
> - -1550074071,
> - -84903219,
> - 1355292929,
> - -380482555,
> - -1818444007,
> - -204797315,
> - 170442609,
> - -1636797387,
> - 868931593,
> - -623503571,
> - 1711722209,
> - 381210981,
> - -161547783,
> - -272740131,
> - -1450066095,
> - 2116588437,
> - 1100682473,
> - 358442893,
> - -1529216831,
> - 2116152005,
> - -776333095,
> - 1265240893,
> - -482278607,
> - 1067190005,
> - 333444553,
> - 86502381,
> - 753481377,
> - 39000101,
> - 1779014585,
> - 219658653,
> - -920253679,
> - 2029538901,
> - 1207761577,
> - -1515772851,
> - -236195711,
> - 442620293,
> - 423166617,
> - -1763648515,
> - -398436623,
> - -1749358155,
> - -538598519,
> - -652439379,
> - 430550625,
> - -1481396507,
> - 2093206905,
> - -1934691747,
> - -962631983,
> - 1454463253,
> - -1877118871,
> - -291917555,
> - -1711673279,
> - 201201733,
> - -474645415,
> - -96764739,
> - -1587365199,
> - 1945705589,
> - 1303896393,
> - 1744831853,
> - 381957665,
> - 2135332261,
> - -55996615,
> - -1190135011,
> - 1790562961,
> - -1493191723,
> - 475559465,
> - 69069
> - };
> -
> -double
> -_random (int32_t is [2])
> -{
> - int32_t it, leh, nit;
> -
> - it = is [0];
> - leh = is [1];
> - if (it <= 0)
> - it = (it + it) ^ MASK;
> - else
> - it = it + it;
> - nit = it - 1;
> -/* to ensure all-ones pattern omitted */
> - leh = leh * mt[nit & 127] + nit;
> - is [0] = it; is [1] = leh;
> - if (leh < 0) leh = ~leh;
> - return (SCALE * ((int32_t) (leh | 1)));
> -}
> -
> -
> -
> -int32_t
> -_irandm (int32_t is [2])
> -{
> - int32_t it, leh, nit;
> -
> - it = is [0];
> - leh = is [1];
> - if (it <= 0)
> - it = (it + it) ^ MASK;
> - else
> - it = it + it;
> - nit = it - 1;
> -/* to ensure all-ones pattern omitted */
> - leh = leh * mt[nit & 127] + nit;
> - is [0] = it; is [1] = leh;
> - if (leh < 0) leh = ~leh;
> - return (leh);
> -}
> -
> -/*
> - * make this a drop in replacement for random and srandom
> - *
> - * XXX not thread safe I guess.
> - */
> -
> -static int32_t saved_seed[2];
> -
> -long random(void)
> -{
> - return _irandm(saved_seed);
> -}
> -
> -void srandom(unsigned seed)
> -{
> - saved_seed[0]=seed;
> - saved_seed[1]=0;
> - _irandm(saved_seed);
> -}
> -
> --
> 2.48.0
>
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 7/7] lib: remove random.c
2025-02-06 21:20 ` [PATCH 7/7] lib: remove random.c Eric Sandeen
2025-02-06 22:47 ` Darrick J. Wong
@ 2025-02-07 5:01 ` Christoph Hellwig
1 sibling, 0 replies; 20+ messages in thread
From: Christoph Hellwig @ 2025-02-07 5:01 UTC (permalink / raw)
To: Eric Sandeen; +Cc: fstests
On Thu, Feb 06, 2025 at 03:20:02PM -0600, Eric Sandeen wrote:
> sparse points out that lots of things in random.c could be static,
> and upon doing so we realize that nothing in this file is used.
> Which is unsurprising since these are all part of the standard
> C library ... so just remove the file.
Heh.
Looks good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 0/7 V2] fstests: enable sparse checking & fix fallout
@ 2025-03-10 18:29 Eric Sandeen
2025-03-10 18:29 ` [PATCH 1/7] fstests: enable sparse checking with make C=[12] Eric Sandeen
` (6 more replies)
0 siblings, 7 replies; 20+ messages in thread
From: Eric Sandeen @ 2025-03-10 18:29 UTC (permalink / raw)
To: fstests; +Cc: djwong, hch
This does so, in the same manner as the kernel and xfsprogs,i.e.
make C=1 or make C=2.
The rest of the patches fix most of the warnings that showed up
for me after that.
V2: Rather than -Dlinux in builddefs, switch all #ifdef linux
to #ifdef __linux__ which hch says is preferred now (Patch 2)
Otherwise unchanged, with RVB: added to patches 1,3-7
Thanks,
-Eric
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 1/7] fstests: enable sparse checking with make C=[12]
2025-03-10 18:29 [PATCH 0/7 V2] fstests: enable sparse checking & fix fallout Eric Sandeen
@ 2025-03-10 18:29 ` Eric Sandeen
2025-03-10 18:29 ` [PATCH 2/7] treewide: check for #ifdef __linux__ not linux Eric Sandeen
` (5 subsequent siblings)
6 siblings, 0 replies; 20+ messages in thread
From: Eric Sandeen @ 2025-03-10 18:29 UTC (permalink / raw)
To: fstests; +Cc: djwong, hch, Eric Sandeen, Christoph Hellwig
Enable "make C=1" sparse checking when files get rebuilt. To check
all files, run "make clean" first.
Enable "make C=2" sparse checking of all files without rebuilding them.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
Makefile | 14 ++++++++++++++
include/buildrules | 19 +++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/Makefile b/Makefile
index f955f0d3..a48d8d62 100644
--- a/Makefile
+++ b/Makefile
@@ -14,6 +14,20 @@ else
Q = @
endif
+CHECK=sparse
+CHECK_OPTS=-Wsparse-all -Wbitwise -Wno-transparent-union -Wno-return-void -Wno-undef \
+ -Wno-non-pointer-null -D__CHECK_ENDIAN__ -D__linux__
+
+ifeq ("$(origin C)", "command line")
+ CHECK_CMD=$(CHECK) $(CHECK_OPTS)
+ CHECKSRC=$(C)
+else
+ CHECK_CMD=@true
+ CHECKSRC=0
+endif
+
+export CHECK_CMD CHECKSRC
+
MAKEOPTS = --no-print-directory Q=$(Q)
TOPDIR = .
diff --git a/include/buildrules b/include/buildrules
index bf187662..6c2b7e18 100644
--- a/include/buildrules
+++ b/include/buildrules
@@ -35,6 +35,21 @@ endif
# Standard targets
#
+ifeq ($(CHECKSRC),2)
+
+# Check every .c file with sparse CHECK_CMD, do not call compiler
+$(LTCOMMAND) $(LTLIBRARY) : $(SUBDIRS) $(OBJECTS)
+.PHONY: $(LTCOMMAND) $(LTLIBRARY)
+
+%.lo %.o : %.c FORCE
+ @echo " [CHECK] $<"
+ $(Q)$(CHECK_CMD) $(CFLAGS) $<
+
+FORCE:
+
+else
+# Regular build, possibly calling sparse CHECK_CMD as well
+
ifdef LTCOMMAND
$(LTCOMMAND) : $(SUBDIRS) $(OBJECTS) $(LTDEPENDENCIES)
@echo " [LD] $*"
@@ -49,12 +64,16 @@ $(LTLIBRARY) : $(SUBDIRS) $(LTOBJECTS)
%.lo: %.c
@echo " [CC] $@"
$(Q)$(LTCOMPILE) -c $<
+ $(Q)$(CHECK_CMD) $(CFLAGS) $<
else
+
%.o: %.c
@echo " [CC] $@"
$(Q)$(CC) $(CFLAGS) -c $<
+ $(Q)$(CHECK_CMD) $(CFLAGS) $<
endif
+endif
ifdef POTHEAD
%.pot: $(XGETTEXTFILES)
--
2.48.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 2/7] treewide: check for #ifdef __linux__ not linux
2025-03-10 18:29 [PATCH 0/7 V2] fstests: enable sparse checking & fix fallout Eric Sandeen
2025-03-10 18:29 ` [PATCH 1/7] fstests: enable sparse checking with make C=[12] Eric Sandeen
@ 2025-03-10 18:29 ` Eric Sandeen
2025-03-11 7:37 ` Christoph Hellwig
2025-03-11 13:46 ` [PATCH 2/7 V3] " Eric Sandeen
2025-03-10 18:29 ` [PATCH 3/7] lib: Fix non-ANSI function declarations Eric Sandeen
` (4 subsequent siblings)
6 siblings, 2 replies; 20+ messages in thread
From: Eric Sandeen @ 2025-03-10 18:29 UTC (permalink / raw)
To: fstests; +Cc: djwong, hch, Eric Sandeen
There are several #ifdef linux guards in the code, which caused
a few sparse warnings, because while gcc defines both linux
and __linux__, sparse defines only __linux__. So, switch our
guards to check for __linux__ which hch says "is the preferred
version these days."
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
include/tlibio.h | 6 +++---
include/write_log.h | 2 +-
lib/str_to_bytes.c | 2 +-
lib/tlibio.c | 12 ++++++------
lib/write_log.c | 2 +-
ltp/doio.c | 8 ++++----
ltp/iogen.c | 6 +++---
7 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/include/tlibio.h b/include/tlibio.h
index 12649cf5..4f462ff1 100644
--- a/include/tlibio.h
+++ b/include/tlibio.h
@@ -11,7 +11,7 @@
#define LIO_IO_SYNCV 00020 /* single-buffer readv/writev */
#define LIO_IO_SYNCP 00040 /* pread/pwrite */
-#ifdef linux
+#ifdef __linux__
#define LIO_IO_TYPES 00021 /* all io types */
#endif /* linux */
@@ -21,14 +21,14 @@
#define LIO_WAIT_SIGPAUSE 00100000 /* call pause */
#define LIO_WAIT_SIGACTIVE 00200000 /* spin waiting for signal */
-#ifdef linux
+#ifdef __linux__
#define LIO_WAIT_TYPES 00300000 /* all wait types, except nowait */
#endif /* linux */
/* meta wait io */
/* 00 000 0000 */
-#ifdef linux
+#ifdef __linux__
/* all signal wait types */
#define LIO_WAIT_SIGTYPES (LIO_WAIT_SIGPAUSE)
#endif /* linux */
diff --git a/include/write_log.h b/include/write_log.h
index 025ebac0..6b088416 100644
--- a/include/write_log.h
+++ b/include/write_log.h
@@ -79,7 +79,7 @@ struct wlog_rec {
*/
struct wlog_rec_disk {
-#ifdef linux
+#ifdef __linux__
uint w_offset : 32; /* file offset */
uint w_extra0 : 32; /* EXTRA BITS IN WORD 0 */
#endif
diff --git a/lib/str_to_bytes.c b/lib/str_to_bytes.c
index 2f6b2b92..89bc7d31 100644
--- a/lib/str_to_bytes.c
+++ b/lib/str_to_bytes.c
@@ -31,7 +31,7 @@
*
****************************************************************************/
-#if linux
+#ifdef __linux__
#define B_MULT DEV_BSIZE /* block size */
#endif
diff --git a/lib/tlibio.c b/lib/tlibio.c
index 5b810059..ae936f41 100644
--- a/lib/tlibio.c
+++ b/lib/tlibio.c
@@ -74,7 +74,7 @@
#endif
-#ifndef linux
+#ifndef __linux__
static void lio_async_signal_handler();
#endif
@@ -351,7 +351,7 @@ lio_help2(char *prefix)
return;
}
-#ifndef linux
+#ifndef __linux__
/***********************************************************************
* This is an internal signal handler.
* If the handler is called, it will increment the Received_signal
@@ -453,7 +453,7 @@ char **errmsg; /* char pointer that will be updated to point to err message */
long wrd; /* to allow future features, use zero for now */
{
int ret = 0; /* syscall return or used to get random method */
-#ifndef linux
+#ifndef __linux__
int omethod = method;
int listio_cmd; /* Holds the listio/lio_listio cmd */
#endif
@@ -650,7 +650,7 @@ char **errmsg; /* char pointer that will be updated to point to err message */
long wrd; /* to allow future features, use zero for now */
{
int ret = 0; /* syscall return or used to get random method */
-#ifndef linux
+#ifndef __linux__
int listio_cmd; /* Holds the listio/lio_listio cmd */
int omethod = method;
#endif
@@ -797,7 +797,7 @@ long wrd; /* to allow future features, use zero for now */
} /* end of lio_read_buffer */
-#ifndef linux
+#ifndef __linux__
/***********************************************************************
* This function will check that async io was successful.
* It can also be used to check sync listio since it uses the
@@ -998,7 +998,7 @@ lio_wait4asyncio(int method, int fd, aiocb_t *aiocbp)
} /* end of lio_wait4asyncio */
-#endif /* ifndef linux */
+#endif /* ifndef __linux__ */
#if UNIT_TEST
/***********************************************************************
diff --git a/lib/write_log.c b/lib/write_log.c
index cdc72593..7c58a95f 100644
--- a/lib/write_log.c
+++ b/lib/write_log.c
@@ -49,7 +49,7 @@
#include "write_log.h"
#ifndef BSIZE
-#ifdef linux
+#ifdef __linux__
#define BSIZE DEV_BSIZE
#else
#define BSIZE BBSIZE
diff --git a/ltp/doio.c b/ltp/doio.c
index fd64df0f..ba080a0b 100644
--- a/ltp/doio.c
+++ b/ltp/doio.c
@@ -222,7 +222,7 @@ int parse_cmdline( int, char **, char * );
int lock_file_region( char *, int, int, int, int );
struct fd_cache *alloc_fdcache(char *, int);
int aio_register( int, int, int );
-#ifndef linux
+#ifndef __linux__
int aio_wait(int);
#endif
@@ -1990,7 +1990,7 @@ do_rw(req)
/*
* If the syscall was async, wait for I/O to complete
*/
-#ifndef linux
+#ifndef __linux__
if(sy->sy_flags & SY_ASYNC) {
for(i=0; i < nents; i++) {
aio_wait(s->aioid[i]);
@@ -2425,7 +2425,7 @@ int nbytes;
static int mturn = 0; /* which memory type to use */
struct memalloc *M;
char filename[255];
-#ifdef linux
+#ifdef __linux__
struct shmid_ds shm_ds;
bzero( &shm_ds, sizeof(struct shmid_ds) );
#endif
@@ -2997,7 +2997,7 @@ int aio_id;
return 0;
}
-#ifndef linux
+#ifndef __linux__
int
aio_wait(aio_id)
int aio_id;
diff --git a/ltp/iogen.c b/ltp/iogen.c
index 0c8b97e9..416dedbc 100644
--- a/ltp/iogen.c
+++ b/ltp/iogen.c
@@ -128,7 +128,7 @@ void startup_info(FILE *stream, int seed);
*/
struct strmap Aio_Strat_Map[] = {
-#ifndef linux
+#ifndef __linux__
{ "poll", A_POLL },
{ "signal", A_SIGNAL },
#else
@@ -1610,7 +1610,7 @@ FILE *stream;
{
usage(stream);
fprintf(stream, "\n");
-#ifndef linux
+#ifndef __linux__
fprintf(stream, "\t-a aio_type,... Async io completion types to choose. Supported types\n");
fprintf(stream, "\t are: poll, signal, suspend, and callback.\n");
fprintf(stream, "\t Default is all of the above.\n");
@@ -1643,7 +1643,7 @@ FILE *stream;
fprintf(stream, "\t-q Quiet mode. Normally iogen spits out info\n");
fprintf(stream, "\t about test files, options, etc. before starting.\n");
fprintf(stream, "\t-s syscall,... Syscalls to do. Supported syscalls are\n");
-#ifdef linux
+#ifdef __linux__
fprintf(stream, "\t read, write, pread, pwrite, readv, writev,\n");
fprintf(stream, "\t mmread, mmwrite, fsync2, fdatasync,\n");
fprintf(stream, "\t Default is 'read,write,readv,writev,mmread,mmwrite'.\n");
--
2.48.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 3/7] lib: Fix non-ANSI function declarations
2025-03-10 18:29 [PATCH 0/7 V2] fstests: enable sparse checking & fix fallout Eric Sandeen
2025-03-10 18:29 ` [PATCH 1/7] fstests: enable sparse checking with make C=[12] Eric Sandeen
2025-03-10 18:29 ` [PATCH 2/7] treewide: check for #ifdef __linux__ not linux Eric Sandeen
@ 2025-03-10 18:29 ` Eric Sandeen
2025-03-10 18:29 ` [PATCH 4/7] lib: fix empty arg function prototypes Eric Sandeen
` (3 subsequent siblings)
6 siblings, 0 replies; 20+ messages in thread
From: Eric Sandeen @ 2025-03-10 18:29 UTC (permalink / raw)
To: fstests; +Cc: djwong, hch, Eric Sandeen, Christoph Hellwig
lib/ was full of non-ANSI function declarations, fix them to make
sparse happier.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
lib/dataascii.c | 59 +++++++++++++++++++++-----------------------
lib/databin.c | 28 ++++++++++-----------
lib/datapid.c | 32 +++++++++---------------
lib/file_lock.c | 12 ++-------
lib/forker.c | 19 ++++++---------
lib/pattern.c | 14 ++---------
lib/random_range.c | 61 ++++++++++++++--------------------------------
lib/str_to_bytes.c | 9 +++----
lib/tlibio.c | 50 ++++++++++++++++++-------------------
lib/write_log.c | 32 ++++++++----------------
10 files changed, 119 insertions(+), 197 deletions(-)
diff --git a/lib/dataascii.c b/lib/dataascii.c
index e2509f8d..d11609ee 100644
--- a/lib/dataascii.c
+++ b/lib/dataascii.c
@@ -17,18 +17,18 @@
static char Errmsg[80];
int
-dataasciigen(listofchars, buffer, bsize, offset)
-char *listofchars; /* a null terminated list of characters */
-char *buffer;
-int bsize;
-int offset;
+dataasciigen(
+ char *listofchars, /* a null terminated list of characters */
+ char *buffer,
+ int bsize,
+ int offset)
{
- int cnt;
- int total;
- int ind; /* index into CHARS array */
- char *chr;
- int chars_size;
- char *charlist;
+ int cnt;
+ int total;
+ int ind; /* index into CHARS array */
+ char *chr;
+ int chars_size;
+ char *charlist;
chr=buffer;
total=offset+bsize;
@@ -52,19 +52,19 @@ int offset;
} /* end of dataasciigen */
int
-dataasciichk(listofchars, buffer, bsize, offset, errmsg)
-char *listofchars; /* a null terminated list of characters */
-char *buffer;
-int bsize;
-int offset;
-char **errmsg;
+dataasciichk(
+ char *listofchars, /* a null terminated list of characters */
+ char *buffer,
+ int bsize,
+ int offset,
+ char **errmsg)
{
- int cnt;
- int total;
- int ind; /* index into CHARS array */
- char *chr;
- int chars_size;
- char *charlist;
+ int cnt;
+ int total;
+ int ind; /* index into CHARS array */
+ char *chr;
+ int chars_size;
+ char *charlist;
chr=buffer;
total=offset+bsize;
@@ -104,15 +104,12 @@ char **errmsg;
* main for doing unit testing
***********************************************************************/
int
-main(ac, ag)
-int ac;
-char **ag;
+main(int ac, char **ag)
{
-
-int size=1023;
-char *buffer;
-int ret;
-char *errmsg;
+ int size=1023;
+ char *buffer;
+ int ret;
+ char *errmsg;
if ((buffer=(char *)malloc(size)) == NULL ) {
perror("malloc");
diff --git a/lib/databin.c b/lib/databin.c
index 8a36dff3..000d0d1a 100644
--- a/lib/databin.c
+++ b/lib/databin.c
@@ -16,13 +16,13 @@
static char Errmsg[80];
void
-databingen (mode, buffer, bsize, offset)
-int mode; /* either a, c, r, o, z or C */
-unsigned char *buffer; /* buffer pointer */
-int bsize; /* size of buffer */
-int offset; /* offset into the file where buffer starts */
+databingen(
+ int mode, /* either a, c, r, o, z or C */
+ unsigned char *buffer, /* buffer pointer */
+ int bsize, /* size of buffer */
+ int offset) /* offset into the file where buffer starts */
{
-int ind;
+ int ind;
switch (mode)
{
@@ -63,12 +63,12 @@ int ind;
* < 0 : no error
***********************************************************************/
int
-databinchk(mode, buffer, bsize, offset, errmsg)
-int mode; /* either a, c, r, z, o, or C */
-unsigned char *buffer; /* buffer pointer */
-int bsize; /* size of buffer */
-int offset; /* offset into the file where buffer starts */
-char **errmsg;
+databinchk(
+ int mode, /* either a, c, r, z, o, or C */
+ unsigned char *buffer, /* buffer pointer */
+ int bsize, /* size of buffer */
+ int offset, /* offset into the file where buffer starts */
+ char **errmsg)
{
int cnt;
unsigned char *chr;
@@ -138,9 +138,7 @@ char **errmsg;
* main for doing unit testing
***********************************************************************/
int
-main(ac, ag)
-int ac;
-char **ag;
+main(int ac, char **ag)
{
int size=1023;
diff --git a/lib/datapid.c b/lib/datapid.c
index 15af8871..6786323d 100644
--- a/lib/datapid.c
+++ b/lib/datapid.c
@@ -57,15 +57,13 @@ static char Errmsg[80];
* Thus, offset 8 is in middle of word 1
***********************************************************************/
int
-datapidgen(pid, buffer, bsize, offset)
-int pid;
-char *buffer;
-int bsize;
-int offset;
+datapidgen(
+ int pid,
+ char *buffer,
+ int bsize,
+ int offset)
{
return -1; /* not support on non-64 bits word machines */
-
-
}
/***********************************************************************
@@ -73,12 +71,7 @@ int offset;
*
***********************************************************************/
int
-datapidchk(pid, buffer, bsize, offset, errmsg)
-int pid;
-char *buffer;
-int bsize;
-int offset;
-char **errmsg;
+datapidchk(int pid, char *buffer, int bsize, int offset, char **errmsg)
{
if ( errmsg != NULL ) {
*errmsg = Errmsg;
@@ -94,15 +87,12 @@ char **errmsg;
* main for doing unit testing
***********************************************************************/
int
-main(ac, ag)
-int ac;
-char **ag;
+main( int ac, char **ag)
{
-
-int size=1234;
-char *buffer;
-int ret;
-char *errmsg;
+ int size=1234;
+ char *buffer;
+ int ret;
+ char *errmsg;
if ((buffer=(char *)malloc(size)) == NULL ) {
perror("malloc");
diff --git a/lib/file_lock.c b/lib/file_lock.c
index f0791489..6d87e281 100644
--- a/lib/file_lock.c
+++ b/lib/file_lock.c
@@ -34,10 +34,7 @@ static char errmsg[256];
* It will loop if the LOCK_NB flags is NOT set.
***********************************************************************/
int
-file_lock(fd, flags, errormsg)
-int fd;
-int flags;
-char **errormsg;
+file_lock(int fd, int flags, char **errormsg)
{
register int cmd, ret;
struct flock flocks;
@@ -109,12 +106,7 @@ char **errormsg;
* It will loop if the LOCK_NB flags is NOT set.
***********************************************************************/
int
-record_lock(fd, flags, start, len, errormsg)
-int fd;
-int flags;
-int start;
-int len;
-char **errormsg;
+record_lock(int fd, int flags, int start, int len, char **errormsg)
{
register int cmd, ret;
struct flock flocks;
diff --git a/lib/forker.c b/lib/forker.c
index 63d8fcdb..10920ddb 100644
--- a/lib/forker.c
+++ b/lib/forker.c
@@ -105,8 +105,7 @@ int Forker_npids=0; /* number of entries in Forker_pids */
* !0 : if fork failed, the return value will be the errno.
***********************************************************************/
int
-background(prefix)
-char *prefix;
+background(char *prefix)
{
switch (fork()) {
case -1:
@@ -131,12 +130,12 @@ char *prefix;
*
***********************************************************************/
int
-forker(ncopies, mode, prefix)
-int ncopies;
-int mode; /* 0 - all childern of parent, 1 - only 1 direct child */
-char *prefix; /* if ! NULL, an message will be printed to stderr */
- /* if fork fails. The prefix (program name) will */
- /* preceed the message */
+forker(
+ int ncopies,
+ int mode, /* 0: all childern of parent, 1: only 1 direct child */
+ char *prefix) /* if ! NULL, an message will be printed to stderr */
+ /* if fork fails. The prefix (program name) will */
+ /* preceed the message */
{
int cnt;
int pid;
@@ -210,9 +209,7 @@ char *prefix; /* if ! NULL, an message will be printed to stderr */
*/
int
-main(argc, argv)
-int argc;
-char **argv;
+main(int argc, char **argv)
{
int ncopies=1;
int mode=0;
diff --git a/lib/pattern.c b/lib/pattern.c
index d622b935..20bbdc97 100644
--- a/lib/pattern.c
+++ b/lib/pattern.c
@@ -12,12 +12,7 @@
*/
int
-pattern_check(buf, buflen, pat, patlen, patshift)
-char *buf;
-int buflen;
-char *pat;
-int patlen;
-int patshift;
+pattern_check(char *buf, int buflen, char *pat, int patlen, int patshift)
{
int nb, ncmp, nleft;
char *cp;
@@ -79,12 +74,7 @@ int patshift;
}
int
-pattern_fill(buf, buflen, pat, patlen, patshift)
-char *buf;
-int buflen;
-char *pat;
-int patlen;
-int patshift;
+pattern_fill(char *buf, int buflen, char *pat, int patlen, int patshift)
{
int trans, ncopied, nleft;
char *cp;
diff --git a/lib/random_range.c b/lib/random_range.c
index 3fa01f0d..680bf71c 100644
--- a/lib/random_range.c
+++ b/lib/random_range.c
@@ -73,14 +73,14 @@ static int str_to_int();
static long long divider(long long, long long, long long, long long);
int
-parse_ranges(str, defmin, defmax, defmult, parse_func, rangeptr, errptr)
-char *str;
-int defmin;
-int defmax;
-int defmult;
-int (*parse_func)();
-char **rangeptr;
-char **errptr;
+parse_ranges(
+ char *str,
+ int defmin,
+ int defmax,
+ int defmult,
+ int (*parse_func)(),
+ char **rangeptr,
+ char **errptr)
{
int ncommas;
char *tmpstr, *cp, *tok, *n1str, *n2str, *multstr;
@@ -194,9 +194,7 @@ char **errptr;
*/
static int
-str_to_int(str, ip)
-char *str;
-int *ip;
+str_to_int(char *str, int *ip)
{
char c;
@@ -214,25 +212,19 @@ int *ip;
*/
int
-range_min(rbuf, r)
-char *rbuf;
-int r;
+range_min(char *rbuf, int r)
{
return ((struct range *)rbuf)[r].min;
}
int
-range_max(rbuf, r)
-char *rbuf;
-int r;
+range_max(char *rbuf, int r)
{
return ((struct range *)rbuf)[r].max;
}
int
-range_mult(rbuf, r)
-char *rbuf;
-int r;
+range_mult(char *rbuf, int r)
{
return ((struct range *)rbuf)[r].mult;
}
@@ -263,11 +255,7 @@ int r;
*****************************************************************************/
long
-random_range(min, max, mult, errp)
-int min;
-int max;
-int mult;
-char **errp;
+random_range(int min, int max, int mult, char **errp)
{
int r, nmults, orig_min, orig_max, orig_mult, tmp;
extern long lrand48();
@@ -333,11 +321,7 @@ char **errp;
* Just like random_range, but all values are longs.
*/
long
-random_rangel(min, max, mult, errp)
-long min;
-long max;
-long mult;
-char **errp;
+random_range1(long min, long max, long mult, char **errp)
{
long r, nmults, orig_min, orig_max, orig_mult, tmp;
extern long lrand48();
@@ -424,11 +408,7 @@ char **errp;
* Attempts to be just like random_range, but everything is long long (64 bit)
*/
long long
-random_rangell(min, max, mult, errp)
-long long min;
-long long max;
-long long mult;
-char **errp;
+random_rangell(long long min, long long max, long long mult, char **errp)
{
long long r, nmults, orig_min, orig_max, orig_mult, tmp;
long long randnum;
@@ -588,8 +568,7 @@ printf(" diff = %lld, half = %lld, med = %lld\n", diff, half, med);
*****************************************************************************/
void
-random_range_seed(s)
-long s;
+random_range_seed(long s)
{
extern void srand48();
@@ -652,9 +631,7 @@ random_bit(long mask)
/*
* The following is a unit test main function for random_bit().
*/
-main(argc, argv)
-int argc;
-char **argv;
+main(int argc, char **argv)
{
int ind;
int cnt, iter;
@@ -695,9 +672,7 @@ char **argv;
#define MEG 1024*1024*1024
#define GIG 1073741824
int
-main(argc, argv)
-int argc;
-char **argv;
+main(int argc, char **argv)
{
int ind;
int cnt, iter=10;
diff --git a/lib/str_to_bytes.c b/lib/str_to_bytes.c
index 89bc7d31..2586b006 100644
--- a/lib/str_to_bytes.c
+++ b/lib/str_to_bytes.c
@@ -42,8 +42,7 @@
#define T_MULT 1099511627776 /* tera or 2^40 */
int
-str_to_bytes(s)
-char *s;
+str_to_bytes(char *s)
{
char mult, junk;
int nconv;
@@ -77,8 +76,7 @@ char *s;
}
long
-str_to_lbytes(s)
-char *s;
+str_to_lbytes(char *s)
{
char mult, junk;
long nconv;
@@ -117,8 +115,7 @@ char *s;
*/
long long
-str_to_llbytes(s)
-char *s;
+str_to_llbytes(char *s)
{
char mult, junk;
long nconv;
diff --git a/lib/tlibio.c b/lib/tlibio.c
index ae936f41..17ab34ee 100644
--- a/lib/tlibio.c
+++ b/lib/tlibio.c
@@ -143,13 +143,13 @@ static int Debug_level = 0;
***********************************************************************/
int
-stride_bounds(offset, stride, nstrides, bytes_per_stride, min, max)
-int offset;
-int stride;
-int nstrides;
-int bytes_per_stride;
-int *min;
-int *max;
+stride_bounds(
+ int offset,
+ int stride,
+ int nstrides,
+ int bytes_per_stride,
+ int *min,
+ int *max)
{
int nbytes, min_byte, max_byte;
@@ -443,14 +443,14 @@ lio_random_methods(long curr_mask)
* (rrl 04/96)
***********************************************************************/
int
-lio_write_buffer(fd, method, buffer, size, sig, errmsg, wrd)
-int fd; /* open file descriptor */
-int method; /* contains io type and wait method bitmask */
-char *buffer; /* pointer to buffer */
-int size; /* the size of the io */
-int sig; /* signal to use if async io */
-char **errmsg; /* char pointer that will be updated to point to err message */
-long wrd; /* to allow future features, use zero for now */
+lio_write_buffer(
+ int fd, /* open file descriptor */
+ int method, /* contains io type and wait method bitmask */
+ char *buffer, /* pointer to buffer */
+ int size, /* the size of the io */
+ int sig, /* signal to use if async io */
+ char **errmsg, /* char pointer that will be updated to point to err message */
+ long wrd) /* to allow future features, use zero for now */
{
int ret = 0; /* syscall return or used to get random method */
#ifndef __linux__
@@ -640,14 +640,14 @@ long wrd; /* to allow future features, use zero for now */
* (rrl 04/96)
***********************************************************************/
int
-lio_read_buffer(fd, method, buffer, size, sig, errmsg, wrd)
-int fd; /* open file descriptor */
-int method; /* contains io type and wait method bitmask */
-char *buffer; /* pointer to buffer */
-int size; /* the size of the io */
-int sig; /* signal to use if async io */
-char **errmsg; /* char pointer that will be updated to point to err message */
-long wrd; /* to allow future features, use zero for now */
+lio_read_buffer(
+ int fd, /* open file descriptor */
+ int method, /* contains io type and wait method bitmask */
+ char *buffer, /* pointer to buffer */
+ int size, /* the size of the io */
+ int sig, /* signal to use if async io */
+ char **errmsg, /* char pointer that will be updated to point to err message */
+ long wrd) /* to allow future features, use zero for now */
{
int ret = 0; /* syscall return or used to get random method */
#ifndef __linux__
@@ -1031,9 +1031,7 @@ struct unit_info_t {
};
int
-main(argc, argv)
-int argc;
-char **argv;
+main(int argc, char **argv)
{
extern char *optarg;
extern int optind;
diff --git a/lib/write_log.c b/lib/write_log.c
index 7c58a95f..32567a1c 100644
--- a/lib/write_log.c
+++ b/lib/write_log.c
@@ -87,10 +87,7 @@ static int wlog_rec_unpack();
*/
int
-wlog_open(wfile, trunc, mode)
-struct wlog_file *wfile;
-int trunc;
-int mode;
+wlog_open(struct wlog_file *wfile, int trunc, int mode)
{
int omask, oflags;
@@ -138,8 +135,7 @@ int mode;
*/
int
-wlog_close(wfile)
-struct wlog_file *wfile;
+wlog_close(struct wlog_file *wfile)
{
close(wfile->w_afd);
close(wfile->w_rfd);
@@ -173,10 +169,7 @@ struct wlog_file *wfile;
*/
int
-wlog_record_write(wfile, wrec, offset)
-struct wlog_file *wfile;
-struct wlog_rec *wrec;
-long offset;
+wlog_record_write(struct wlog_file *wfile, struct wlog_rec *wrec, long offset)
{
int reclen;
char wbuf[WLOG_REC_MAX_SIZE + 2];
@@ -221,11 +214,11 @@ long offset;
*/
int
-wlog_scan_backward(wfile, nrecs, func, data)
-struct wlog_file *wfile;
-int nrecs;
-int (*func)();
-long data;
+wlog_scan_backward(
+ struct wlog_file *wfile,
+ int nrecs,
+ int (*func)(),
+ long data)
{
int fd, leftover, nbytes, offset, recnum, reclen;
char buf[BSIZE*32], *bufend, *cp, *bufstart;
@@ -351,10 +344,7 @@ long data;
*/
static int
-wlog_rec_pack(wrec, buf, flag)
-struct wlog_rec *wrec;
-char *buf;
-int flag;
+wlog_rec_pack(struct wlog_rec *wrec, char *buf, int flag)
{
char *file, *host, *pattern;
struct wlog_rec_disk *wrecd;
@@ -400,9 +390,7 @@ int flag;
}
static int
-wlog_rec_unpack(wrec, buf)
-struct wlog_rec *wrec;
-char *buf;
+wlog_rec_unpack(struct wlog_rec *wrec, char *buf)
{
char *file, *host, *pattern;
struct wlog_rec_disk *wrecd;
--
2.48.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 4/7] lib: fix empty arg function prototypes
2025-03-10 18:29 [PATCH 0/7 V2] fstests: enable sparse checking & fix fallout Eric Sandeen
` (2 preceding siblings ...)
2025-03-10 18:29 ` [PATCH 3/7] lib: Fix non-ANSI function declarations Eric Sandeen
@ 2025-03-10 18:29 ` Eric Sandeen
2025-03-10 18:29 ` [PATCH 5/7] lib: replace aiocb_t with struct aiocb Eric Sandeen
` (2 subsequent siblings)
6 siblings, 0 replies; 20+ messages in thread
From: Eric Sandeen @ 2025-03-10 18:29 UTC (permalink / raw)
To: fstests; +Cc: djwong, hch, Eric Sandeen, Christoph Hellwig
Several function prototypes used () when in fact they take
arguments. Fix those to make sparse happy.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
include/random_range.h | 2 +-
include/write_log.h | 2 +-
lib/random_range.c | 6 ++----
lib/string_to_tokens.c | 1 -
lib/tlibio.c | 2 +-
lib/write_log.c | 2 +-
6 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/include/random_range.h b/include/random_range.h
index b47aef9e..c352c5a9 100644
--- a/include/random_range.h
+++ b/include/random_range.h
@@ -6,7 +6,7 @@
#ifndef _RANDOM_RANGE_H_
#define _RANDOM_RANGE_H_
-int parse_ranges ( char *, int, int, int, int (*)(), char **, char ** );
+int parse_ranges ( char *, int, int, int, int (*)(char *, int *), char **, char ** );
int range_min ( char *, int );
int range_max ( char *, int );
int range_mult ( char *, int );
diff --git a/include/write_log.h b/include/write_log.h
index 6b088416..a7ad2ee4 100644
--- a/include/write_log.h
+++ b/include/write_log.h
@@ -125,7 +125,7 @@ extern int wlog_close(struct wlog_file *wfile);
extern int wlog_record_write(struct wlog_file *wfile,
struct wlog_rec *wrec, long offset);
extern int wlog_scan_backward(struct wlog_file *wfile, int nrecs,
- int (*func)(struct wlog_rec *rec),
+ int (*func)(struct wlog_rec *rec, long data),
long data);
#else
int wlog_open();
diff --git a/lib/random_range.c b/lib/random_range.c
index 680bf71c..0b38eb7f 100644
--- a/lib/random_range.c
+++ b/lib/random_range.c
@@ -69,7 +69,7 @@ struct range {
* parse_range() returns -1 on error, or the number of ranges parsed.
*/
-static int str_to_int();
+static int str_to_int(char *str, int *ip);
static long long divider(long long, long long, long long, long long);
int
@@ -78,7 +78,7 @@ parse_ranges(
int defmin,
int defmax,
int defmult,
- int (*parse_func)(),
+ int (*parse_func)(char *str, int *ip),
char **rangeptr,
char **errptr)
{
@@ -570,8 +570,6 @@ printf(" diff = %lld, half = %lld, med = %lld\n", diff, half, med);
void
random_range_seed(long s)
{
- extern void srand48();
-
srand48(s);
}
diff --git a/lib/string_to_tokens.c b/lib/string_to_tokens.c
index 08df9fcc..8383ed4c 100644
--- a/lib/string_to_tokens.c
+++ b/lib/string_to_tokens.c
@@ -54,7 +54,6 @@ int
string_to_tokens(char *arg_string, char *arg_array[], int array_size, char *separator)
{
int num_toks = 0; /* number of tokens found */
- char *strtok();
if ( arg_array == NULL || array_size <= 1 || separator == NULL )
return -1;
diff --git a/lib/tlibio.c b/lib/tlibio.c
index 17ab34ee..75f10cec 100644
--- a/lib/tlibio.c
+++ b/lib/tlibio.c
@@ -75,7 +75,7 @@
#ifndef __linux__
-static void lio_async_signal_handler();
+static void lio_async_signal_handler(int sig);
#endif
/*
diff --git a/lib/write_log.c b/lib/write_log.c
index 32567a1c..eb3fa2b3 100644
--- a/lib/write_log.c
+++ b/lib/write_log.c
@@ -217,7 +217,7 @@ int
wlog_scan_backward(
struct wlog_file *wfile,
int nrecs,
- int (*func)(),
+ int (*func)(struct wlog_rec *, long data),
long data)
{
int fd, leftover, nbytes, offset, recnum, reclen;
--
2.48.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 5/7] lib: replace aiocb_t with struct aiocb
2025-03-10 18:29 [PATCH 0/7 V2] fstests: enable sparse checking & fix fallout Eric Sandeen
` (3 preceding siblings ...)
2025-03-10 18:29 ` [PATCH 4/7] lib: fix empty arg function prototypes Eric Sandeen
@ 2025-03-10 18:29 ` Eric Sandeen
2025-03-10 18:29 ` [PATCH 6/7] lib: make a few symbols static Eric Sandeen
2025-03-10 18:29 ` [PATCH 7/7] lib: remove random.c Eric Sandeen
6 siblings, 0 replies; 20+ messages in thread
From: Eric Sandeen @ 2025-03-10 18:29 UTC (permalink / raw)
To: fstests; +Cc: djwong, hch, Eric Sandeen, Christoph Hellwig
aiocb_t isn't defined anywhere, use struct aiocb instead,
to make sparse happy.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
lib/tlibio.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/tlibio.c b/lib/tlibio.c
index 75f10cec..9d852ff0 100644
--- a/lib/tlibio.c
+++ b/lib/tlibio.c
@@ -42,6 +42,7 @@
*
*/
+#include <aio.h>
#include <stdio.h>
#include <ctype.h>
#include <fcntl.h>
@@ -810,7 +811,7 @@ lio_read_buffer(
* (rrl 04/96)
***********************************************************************/
int
-lio_check_asyncio(char *io_type, int size, aiocb_t *aiocbp, int method)
+lio_check_asyncio(char *io_type, int size, const struct aiocb *aiocbp, int method)
{
int ret;
int cnt = 1;
@@ -895,9 +896,10 @@ lio_check_asyncio(char *io_type, int size, aiocb_t *aiocbp, int method)
* (rrl 04/96)
***********************************************************************/
int
-lio_wait4asyncio(int method, int fd, aiocb_t *aiocbp)
+lio_wait4asyncio(int method, int fd, const struct aiocb *aiocbp)
{
- int cnt;
+ struct aiocb *const aioary[1];
+ int cnt, ret;
if ( (method & LIO_WAIT_RECALL)
|| ((method & LIO_WAIT_TYPES) == 0) ){
--
2.48.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 6/7] lib: make a few symbols static
2025-03-10 18:29 [PATCH 0/7 V2] fstests: enable sparse checking & fix fallout Eric Sandeen
` (4 preceding siblings ...)
2025-03-10 18:29 ` [PATCH 5/7] lib: replace aiocb_t with struct aiocb Eric Sandeen
@ 2025-03-10 18:29 ` Eric Sandeen
2025-03-10 18:29 ` [PATCH 7/7] lib: remove random.c Eric Sandeen
6 siblings, 0 replies; 20+ messages in thread
From: Eric Sandeen @ 2025-03-10 18:29 UTC (permalink / raw)
To: fstests; +Cc: djwong, hch, Eric Sandeen, Christoph Hellwig
There are a few symbols in lib/tlibio.c which should be static,
and sparse notices this so fix it.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
lib/tlibio.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/tlibio.c b/lib/tlibio.c
index 9d852ff0..73851fd8 100644
--- a/lib/tlibio.c
+++ b/lib/tlibio.c
@@ -82,6 +82,7 @@ static void lio_async_signal_handler(int sig);
/*
* Define the structure as used in lio_parse_arg1 and lio_help1
*/
+static
struct lio_info_type Lio_info1[] = {
{ "s", LIO_IO_SYNC, "sync i/o" },
{ "p", LIO_IO_ASYNC|LIO_WAIT_SIGACTIVE, "async i/o using a loop to wait for a signal" },
@@ -101,6 +102,7 @@ struct lio_info_type Lio_info1[] = {
/*
* Define the structure used by lio_parse_arg2 and lio_help2
*/
+static
struct lio_info_type Lio_info2[] = {
{ "sync", LIO_IO_SYNC, "sync i/o (read/write)"},
{ "async", LIO_IO_ASYNC, "async i/o (reada/writea/aio_read/aio_write)" },
@@ -120,7 +122,7 @@ struct lio_info_type Lio_info2[] = {
"all random i/o types and wait methods (except nowait)" },
};
-char Lio_SysCall[PATH_MAX]; /* string containing last i/o system call */
+static char Lio_SysCall[PATH_MAX]; /* string containing last i/o system call */
static volatile int Received_signal = 0; /* number of signals received */
static volatile int Rec_signal;
--
2.48.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH 7/7] lib: remove random.c
2025-03-10 18:29 [PATCH 0/7 V2] fstests: enable sparse checking & fix fallout Eric Sandeen
` (5 preceding siblings ...)
2025-03-10 18:29 ` [PATCH 6/7] lib: make a few symbols static Eric Sandeen
@ 2025-03-10 18:29 ` Eric Sandeen
2025-03-16 14:54 ` Zorro Lang
6 siblings, 1 reply; 20+ messages in thread
From: Eric Sandeen @ 2025-03-10 18:29 UTC (permalink / raw)
To: fstests; +Cc: djwong, hch, Eric Sandeen, Christoph Hellwig
sparse points out that lots of things in random.c could be static,
and upon doing so we realize that nothing in this file is used.
Which is unsurprising since these are all part of the standard
C library ... so just remove the file.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
lib/Makefile | 5 +-
lib/random.c | 224 ---------------------------------------------------
2 files changed, 2 insertions(+), 227 deletions(-)
delete mode 100644 lib/random.c
diff --git a/lib/Makefile b/lib/Makefile
index 53540ca7..ce4381a2 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -11,13 +11,12 @@ LT_REVISION = 0
LT_AGE = 0
#
-# Everything (except for random.c) copied directly from LTP.
+# Everything copied directly from LTP.
# Refer to http://ltp.sourceforge.net/ for complete source.
#
CFILES = dataascii.c databin.c datapid.c file_lock.c forker.c \
pattern.c open_flags.c random_range.c string_to_tokens.c \
- str_to_bytes.c tlibio.c write_log.c \
- random.c
+ str_to_bytes.c tlibio.c write_log.c
default: depend $(LTLIBRARY)
diff --git a/lib/random.c b/lib/random.c
deleted file mode 100644
index d5c81be8..00000000
--- a/lib/random.c
+++ /dev/null
@@ -1,224 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * random.c -- pseudo random number generator
- * Copyright (C) 1994 Chris Wallace (csw@bruce.cs.monash.edu.au)
- */
-
-#include <sys/types.h>
-
-/*
- * modified by dxm@sgi.com so that this file acts as a drop in replacement
- * for srandom and random.
- */
-
-/*
- * A random number generator called as a function by
- * random (iseed) or irandm (iseed)
- * The parameter should be a pointer to a 2-element int32_t vector.
- * The first function returns a double uniform in 0 .. 1.
- * The second returns a int32_t integer uniform in 0 .. 2**31-1
- * Both update iseed[] in exactly the same way.
- * iseed[] must be a 2-element integer vector.
- * The initial value of the second element may be anything.
- *
- * The period of the random sequence is 2**32 * (2**32-1)
- * The table mt[0:127] is defined by mt[i] = 69069 ** (128-i)
- */
-
-#define MASK ((int32_t) 593970775)
-/* or in hex, 23674657 */
-
-#define SCALE ((double) 1.0 / (1024.0 * 1024.0 * 1024.0 * 2.0))
-/* i.e. 2 to power -31 */
-
-static int32_t mt [128] = {
- 902906369,
- 2030498053,
- -473499623,
- 1640834941,
- 723406961,
- 1993558325,
- -257162999,
- -1627724755,
- 913952737,
- 278845029,
- 1327502073,
- -1261253155,
- 981676113,
- -1785280363,
- 1700077033,
- 366908557,
- -1514479167,
- -682799163,
- 141955545,
- -830150595,
- 317871153,
- 1542036469,
- -946413879,
- -1950779155,
- 985397153,
- 626515237,
- 530871481,
- 783087261,
- -1512358895,
- 1031357269,
- -2007710807,
- -1652747955,
- -1867214463,
- 928251525,
- 1243003801,
- -2132510467,
- 1874683889,
- -717013323,
- 218254473,
- -1628774995,
- -2064896159,
- 69678053,
- 281568889,
- -2104168611,
- -165128239,
- 1536495125,
- -39650967,
- 546594317,
- -725987007,
- 1392966981,
- 1044706649,
- 687331773,
- -2051306575,
- 1544302965,
- -758494647,
- -1243934099,
- -75073759,
- 293132965,
- -1935153095,
- 118929437,
- 807830417,
- -1416222507,
- -1550074071,
- -84903219,
- 1355292929,
- -380482555,
- -1818444007,
- -204797315,
- 170442609,
- -1636797387,
- 868931593,
- -623503571,
- 1711722209,
- 381210981,
- -161547783,
- -272740131,
- -1450066095,
- 2116588437,
- 1100682473,
- 358442893,
- -1529216831,
- 2116152005,
- -776333095,
- 1265240893,
- -482278607,
- 1067190005,
- 333444553,
- 86502381,
- 753481377,
- 39000101,
- 1779014585,
- 219658653,
- -920253679,
- 2029538901,
- 1207761577,
- -1515772851,
- -236195711,
- 442620293,
- 423166617,
- -1763648515,
- -398436623,
- -1749358155,
- -538598519,
- -652439379,
- 430550625,
- -1481396507,
- 2093206905,
- -1934691747,
- -962631983,
- 1454463253,
- -1877118871,
- -291917555,
- -1711673279,
- 201201733,
- -474645415,
- -96764739,
- -1587365199,
- 1945705589,
- 1303896393,
- 1744831853,
- 381957665,
- 2135332261,
- -55996615,
- -1190135011,
- 1790562961,
- -1493191723,
- 475559465,
- 69069
- };
-
-double
-_random (int32_t is [2])
-{
- int32_t it, leh, nit;
-
- it = is [0];
- leh = is [1];
- if (it <= 0)
- it = (it + it) ^ MASK;
- else
- it = it + it;
- nit = it - 1;
-/* to ensure all-ones pattern omitted */
- leh = leh * mt[nit & 127] + nit;
- is [0] = it; is [1] = leh;
- if (leh < 0) leh = ~leh;
- return (SCALE * ((int32_t) (leh | 1)));
-}
-
-
-
-int32_t
-_irandm (int32_t is [2])
-{
- int32_t it, leh, nit;
-
- it = is [0];
- leh = is [1];
- if (it <= 0)
- it = (it + it) ^ MASK;
- else
- it = it + it;
- nit = it - 1;
-/* to ensure all-ones pattern omitted */
- leh = leh * mt[nit & 127] + nit;
- is [0] = it; is [1] = leh;
- if (leh < 0) leh = ~leh;
- return (leh);
-}
-
-/*
- * make this a drop in replacement for random and srandom
- *
- * XXX not thread safe I guess.
- */
-
-static int32_t saved_seed[2];
-
-long random(void)
-{
- return _irandm(saved_seed);
-}
-
-void srandom(unsigned seed)
-{
- saved_seed[0]=seed;
- saved_seed[1]=0;
- _irandm(saved_seed);
-}
-
--
2.48.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 2/7] treewide: check for #ifdef __linux__ not linux
2025-03-10 18:29 ` [PATCH 2/7] treewide: check for #ifdef __linux__ not linux Eric Sandeen
@ 2025-03-11 7:37 ` Christoph Hellwig
2025-03-11 13:44 ` Eric Sandeen
2025-03-11 13:46 ` [PATCH 2/7 V3] " Eric Sandeen
1 sibling, 1 reply; 20+ messages in thread
From: Christoph Hellwig @ 2025-03-11 7:37 UTC (permalink / raw)
To: Eric Sandeen; +Cc: fstests, djwong, hch
On Mon, Mar 10, 2025 at 01:29:04PM -0500, Eric Sandeen wrote:
> There are several #ifdef linux guards in the code, which caused
> a few sparse warnings, because while gcc defines both linux
> and __linux__, sparse defines only __linux__. So, switch our
> guards to check for __linux__ which hch says "is the preferred
> version these days."
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Sorry for nitpicking, bu "he says" is usually not a good way to
write commit logs. Just state that __linux__ is also pre-defined
by sparse.
The changes themselves look good:
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 2/7] treewide: check for #ifdef __linux__ not linux
2025-03-11 7:37 ` Christoph Hellwig
@ 2025-03-11 13:44 ` Eric Sandeen
0 siblings, 0 replies; 20+ messages in thread
From: Eric Sandeen @ 2025-03-11 13:44 UTC (permalink / raw)
To: Christoph Hellwig, Eric Sandeen; +Cc: fstests, djwong
On 3/11/25 2:37 AM, Christoph Hellwig wrote:
> On Mon, Mar 10, 2025 at 01:29:04PM -0500, Eric Sandeen wrote:
>> There are several #ifdef linux guards in the code, which caused
>> a few sparse warnings, because while gcc defines both linux
>> and __linux__, sparse defines only __linux__. So, switch our
>> guards to check for __linux__ which hch says "is the preferred
>> version these days."
>>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>
> Sorry for nitpicking, bu "he says" is usually not a good way to
> write commit logs. Just state that __linux__ is also pre-defined
> by sparse.
>
> The changes themselves look good:
>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
Was an attempt to give you credit for your suggestion.
I will send V3 with a changed commit log.
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH 2/7 V3] treewide: check for #ifdef __linux__ not linux
2025-03-10 18:29 ` [PATCH 2/7] treewide: check for #ifdef __linux__ not linux Eric Sandeen
2025-03-11 7:37 ` Christoph Hellwig
@ 2025-03-11 13:46 ` Eric Sandeen
2025-03-11 15:25 ` Darrick J. Wong
1 sibling, 1 reply; 20+ messages in thread
From: Eric Sandeen @ 2025-03-11 13:46 UTC (permalink / raw)
To: Eric Sandeen, fstests; +Cc: djwong, hch
There are several #ifdef linux guards in the code, which caused
a few sparse warnings, because while gcc defines both linux
and __linux__, sparse defines only __linux__. So, switch our
guards to check for __linux__ which is defined by both gcc
and sparse.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
include/tlibio.h | 6 +++---
include/write_log.h | 2 +-
lib/str_to_bytes.c | 2 +-
lib/tlibio.c | 12 ++++++------
lib/write_log.c | 2 +-
ltp/doio.c | 8 ++++----
ltp/iogen.c | 6 +++---
7 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/include/tlibio.h b/include/tlibio.h
index 12649cf5..4f462ff1 100644
--- a/include/tlibio.h
+++ b/include/tlibio.h
@@ -11,7 +11,7 @@
#define LIO_IO_SYNCV 00020 /* single-buffer readv/writev */
#define LIO_IO_SYNCP 00040 /* pread/pwrite */
-#ifdef linux
+#ifdef __linux__
#define LIO_IO_TYPES 00021 /* all io types */
#endif /* linux */
@@ -21,14 +21,14 @@
#define LIO_WAIT_SIGPAUSE 00100000 /* call pause */
#define LIO_WAIT_SIGACTIVE 00200000 /* spin waiting for signal */
-#ifdef linux
+#ifdef __linux__
#define LIO_WAIT_TYPES 00300000 /* all wait types, except nowait */
#endif /* linux */
/* meta wait io */
/* 00 000 0000 */
-#ifdef linux
+#ifdef __linux__
/* all signal wait types */
#define LIO_WAIT_SIGTYPES (LIO_WAIT_SIGPAUSE)
#endif /* linux */
diff --git a/include/write_log.h b/include/write_log.h
index 025ebac0..6b088416 100644
--- a/include/write_log.h
+++ b/include/write_log.h
@@ -79,7 +79,7 @@ struct wlog_rec {
*/
struct wlog_rec_disk {
-#ifdef linux
+#ifdef __linux__
uint w_offset : 32; /* file offset */
uint w_extra0 : 32; /* EXTRA BITS IN WORD 0 */
#endif
diff --git a/lib/str_to_bytes.c b/lib/str_to_bytes.c
index 2f6b2b92..89bc7d31 100644
--- a/lib/str_to_bytes.c
+++ b/lib/str_to_bytes.c
@@ -31,7 +31,7 @@
*
****************************************************************************/
-#if linux
+#ifdef __linux__
#define B_MULT DEV_BSIZE /* block size */
#endif
diff --git a/lib/tlibio.c b/lib/tlibio.c
index 5b810059..ae936f41 100644
--- a/lib/tlibio.c
+++ b/lib/tlibio.c
@@ -74,7 +74,7 @@
#endif
-#ifndef linux
+#ifndef __linux__
static void lio_async_signal_handler();
#endif
@@ -351,7 +351,7 @@ lio_help2(char *prefix)
return;
}
-#ifndef linux
+#ifndef __linux__
/***********************************************************************
* This is an internal signal handler.
* If the handler is called, it will increment the Received_signal
@@ -453,7 +453,7 @@ char **errmsg; /* char pointer that will be updated to point to err message */
long wrd; /* to allow future features, use zero for now */
{
int ret = 0; /* syscall return or used to get random method */
-#ifndef linux
+#ifndef __linux__
int omethod = method;
int listio_cmd; /* Holds the listio/lio_listio cmd */
#endif
@@ -650,7 +650,7 @@ char **errmsg; /* char pointer that will be updated to point to err message */
long wrd; /* to allow future features, use zero for now */
{
int ret = 0; /* syscall return or used to get random method */
-#ifndef linux
+#ifndef __linux__
int listio_cmd; /* Holds the listio/lio_listio cmd */
int omethod = method;
#endif
@@ -797,7 +797,7 @@ long wrd; /* to allow future features, use zero for now */
} /* end of lio_read_buffer */
-#ifndef linux
+#ifndef __linux__
/***********************************************************************
* This function will check that async io was successful.
* It can also be used to check sync listio since it uses the
@@ -998,7 +998,7 @@ lio_wait4asyncio(int method, int fd, aiocb_t *aiocbp)
} /* end of lio_wait4asyncio */
-#endif /* ifndef linux */
+#endif /* ifndef __linux__ */
#if UNIT_TEST
/***********************************************************************
diff --git a/lib/write_log.c b/lib/write_log.c
index cdc72593..7c58a95f 100644
--- a/lib/write_log.c
+++ b/lib/write_log.c
@@ -49,7 +49,7 @@
#include "write_log.h"
#ifndef BSIZE
-#ifdef linux
+#ifdef __linux__
#define BSIZE DEV_BSIZE
#else
#define BSIZE BBSIZE
diff --git a/ltp/doio.c b/ltp/doio.c
index fd64df0f..ba080a0b 100644
--- a/ltp/doio.c
+++ b/ltp/doio.c
@@ -222,7 +222,7 @@ int parse_cmdline( int, char **, char * );
int lock_file_region( char *, int, int, int, int );
struct fd_cache *alloc_fdcache(char *, int);
int aio_register( int, int, int );
-#ifndef linux
+#ifndef __linux__
int aio_wait(int);
#endif
@@ -1990,7 +1990,7 @@ do_rw(req)
/*
* If the syscall was async, wait for I/O to complete
*/
-#ifndef linux
+#ifndef __linux__
if(sy->sy_flags & SY_ASYNC) {
for(i=0; i < nents; i++) {
aio_wait(s->aioid[i]);
@@ -2425,7 +2425,7 @@ int nbytes;
static int mturn = 0; /* which memory type to use */
struct memalloc *M;
char filename[255];
-#ifdef linux
+#ifdef __linux__
struct shmid_ds shm_ds;
bzero( &shm_ds, sizeof(struct shmid_ds) );
#endif
@@ -2997,7 +2997,7 @@ int aio_id;
return 0;
}
-#ifndef linux
+#ifndef __linux__
int
aio_wait(aio_id)
int aio_id;
diff --git a/ltp/iogen.c b/ltp/iogen.c
index 0c8b97e9..416dedbc 100644
--- a/ltp/iogen.c
+++ b/ltp/iogen.c
@@ -128,7 +128,7 @@ void startup_info(FILE *stream, int seed);
*/
struct strmap Aio_Strat_Map[] = {
-#ifndef linux
+#ifndef __linux__
{ "poll", A_POLL },
{ "signal", A_SIGNAL },
#else
@@ -1610,7 +1610,7 @@ FILE *stream;
{
usage(stream);
fprintf(stream, "\n");
-#ifndef linux
+#ifndef __linux__
fprintf(stream, "\t-a aio_type,... Async io completion types to choose. Supported types\n");
fprintf(stream, "\t are: poll, signal, suspend, and callback.\n");
fprintf(stream, "\t Default is all of the above.\n");
@@ -1643,7 +1643,7 @@ FILE *stream;
fprintf(stream, "\t-q Quiet mode. Normally iogen spits out info\n");
fprintf(stream, "\t about test files, options, etc. before starting.\n");
fprintf(stream, "\t-s syscall,... Syscalls to do. Supported syscalls are\n");
-#ifdef linux
+#ifdef __linux__
fprintf(stream, "\t read, write, pread, pwrite, readv, writev,\n");
fprintf(stream, "\t mmread, mmwrite, fsync2, fdatasync,\n");
fprintf(stream, "\t Default is 'read,write,readv,writev,mmread,mmwrite'.\n");
--
2.48.0
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH 2/7 V3] treewide: check for #ifdef __linux__ not linux
2025-03-11 13:46 ` [PATCH 2/7 V3] " Eric Sandeen
@ 2025-03-11 15:25 ` Darrick J. Wong
0 siblings, 0 replies; 20+ messages in thread
From: Darrick J. Wong @ 2025-03-11 15:25 UTC (permalink / raw)
To: Eric Sandeen; +Cc: Eric Sandeen, fstests, hch
On Tue, Mar 11, 2025 at 08:46:48AM -0500, Eric Sandeen wrote:
> There are several #ifdef linux guards in the code, which caused
> a few sparse warnings, because while gcc defines both linux
> and __linux__, sparse defines only __linux__. So, switch our
> guards to check for __linux__ which is defined by both gcc
> and sparse.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
Looks good to me,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> include/tlibio.h | 6 +++---
> include/write_log.h | 2 +-
> lib/str_to_bytes.c | 2 +-
> lib/tlibio.c | 12 ++++++------
> lib/write_log.c | 2 +-
> ltp/doio.c | 8 ++++----
> ltp/iogen.c | 6 +++---
> 7 files changed, 19 insertions(+), 19 deletions(-)
>
> diff --git a/include/tlibio.h b/include/tlibio.h
> index 12649cf5..4f462ff1 100644
> --- a/include/tlibio.h
> +++ b/include/tlibio.h
> @@ -11,7 +11,7 @@
> #define LIO_IO_SYNCV 00020 /* single-buffer readv/writev */
> #define LIO_IO_SYNCP 00040 /* pread/pwrite */
>
> -#ifdef linux
> +#ifdef __linux__
> #define LIO_IO_TYPES 00021 /* all io types */
> #endif /* linux */
>
> @@ -21,14 +21,14 @@
> #define LIO_WAIT_SIGPAUSE 00100000 /* call pause */
> #define LIO_WAIT_SIGACTIVE 00200000 /* spin waiting for signal */
>
> -#ifdef linux
> +#ifdef __linux__
> #define LIO_WAIT_TYPES 00300000 /* all wait types, except nowait */
> #endif /* linux */
>
> /* meta wait io */
> /* 00 000 0000 */
>
> -#ifdef linux
> +#ifdef __linux__
> /* all signal wait types */
> #define LIO_WAIT_SIGTYPES (LIO_WAIT_SIGPAUSE)
> #endif /* linux */
> diff --git a/include/write_log.h b/include/write_log.h
> index 025ebac0..6b088416 100644
> --- a/include/write_log.h
> +++ b/include/write_log.h
> @@ -79,7 +79,7 @@ struct wlog_rec {
> */
>
> struct wlog_rec_disk {
> -#ifdef linux
> +#ifdef __linux__
> uint w_offset : 32; /* file offset */
> uint w_extra0 : 32; /* EXTRA BITS IN WORD 0 */
> #endif
> diff --git a/lib/str_to_bytes.c b/lib/str_to_bytes.c
> index 2f6b2b92..89bc7d31 100644
> --- a/lib/str_to_bytes.c
> +++ b/lib/str_to_bytes.c
> @@ -31,7 +31,7 @@
> *
> ****************************************************************************/
>
> -#if linux
> +#ifdef __linux__
> #define B_MULT DEV_BSIZE /* block size */
> #endif
>
> diff --git a/lib/tlibio.c b/lib/tlibio.c
> index 5b810059..ae936f41 100644
> --- a/lib/tlibio.c
> +++ b/lib/tlibio.c
> @@ -74,7 +74,7 @@
> #endif
>
>
> -#ifndef linux
> +#ifndef __linux__
> static void lio_async_signal_handler();
> #endif
>
> @@ -351,7 +351,7 @@ lio_help2(char *prefix)
> return;
> }
>
> -#ifndef linux
> +#ifndef __linux__
> /***********************************************************************
> * This is an internal signal handler.
> * If the handler is called, it will increment the Received_signal
> @@ -453,7 +453,7 @@ char **errmsg; /* char pointer that will be updated to point to err message */
> long wrd; /* to allow future features, use zero for now */
> {
> int ret = 0; /* syscall return or used to get random method */
> -#ifndef linux
> +#ifndef __linux__
> int omethod = method;
> int listio_cmd; /* Holds the listio/lio_listio cmd */
> #endif
> @@ -650,7 +650,7 @@ char **errmsg; /* char pointer that will be updated to point to err message */
> long wrd; /* to allow future features, use zero for now */
> {
> int ret = 0; /* syscall return or used to get random method */
> -#ifndef linux
> +#ifndef __linux__
> int listio_cmd; /* Holds the listio/lio_listio cmd */
> int omethod = method;
> #endif
> @@ -797,7 +797,7 @@ long wrd; /* to allow future features, use zero for now */
> } /* end of lio_read_buffer */
>
>
> -#ifndef linux
> +#ifndef __linux__
> /***********************************************************************
> * This function will check that async io was successful.
> * It can also be used to check sync listio since it uses the
> @@ -998,7 +998,7 @@ lio_wait4asyncio(int method, int fd, aiocb_t *aiocbp)
>
> } /* end of lio_wait4asyncio */
>
> -#endif /* ifndef linux */
> +#endif /* ifndef __linux__ */
>
> #if UNIT_TEST
> /***********************************************************************
> diff --git a/lib/write_log.c b/lib/write_log.c
> index cdc72593..7c58a95f 100644
> --- a/lib/write_log.c
> +++ b/lib/write_log.c
> @@ -49,7 +49,7 @@
> #include "write_log.h"
>
> #ifndef BSIZE
> -#ifdef linux
> +#ifdef __linux__
> #define BSIZE DEV_BSIZE
> #else
> #define BSIZE BBSIZE
> diff --git a/ltp/doio.c b/ltp/doio.c
> index fd64df0f..ba080a0b 100644
> --- a/ltp/doio.c
> +++ b/ltp/doio.c
> @@ -222,7 +222,7 @@ int parse_cmdline( int, char **, char * );
> int lock_file_region( char *, int, int, int, int );
> struct fd_cache *alloc_fdcache(char *, int);
> int aio_register( int, int, int );
> -#ifndef linux
> +#ifndef __linux__
> int aio_wait(int);
> #endif
>
> @@ -1990,7 +1990,7 @@ do_rw(req)
> /*
> * If the syscall was async, wait for I/O to complete
> */
> -#ifndef linux
> +#ifndef __linux__
> if(sy->sy_flags & SY_ASYNC) {
> for(i=0; i < nents; i++) {
> aio_wait(s->aioid[i]);
> @@ -2425,7 +2425,7 @@ int nbytes;
> static int mturn = 0; /* which memory type to use */
> struct memalloc *M;
> char filename[255];
> -#ifdef linux
> +#ifdef __linux__
> struct shmid_ds shm_ds;
> bzero( &shm_ds, sizeof(struct shmid_ds) );
> #endif
> @@ -2997,7 +2997,7 @@ int aio_id;
> return 0;
> }
>
> -#ifndef linux
> +#ifndef __linux__
> int
> aio_wait(aio_id)
> int aio_id;
> diff --git a/ltp/iogen.c b/ltp/iogen.c
> index 0c8b97e9..416dedbc 100644
> --- a/ltp/iogen.c
> +++ b/ltp/iogen.c
> @@ -128,7 +128,7 @@ void startup_info(FILE *stream, int seed);
> */
>
> struct strmap Aio_Strat_Map[] = {
> -#ifndef linux
> +#ifndef __linux__
> { "poll", A_POLL },
> { "signal", A_SIGNAL },
> #else
> @@ -1610,7 +1610,7 @@ FILE *stream;
> {
> usage(stream);
> fprintf(stream, "\n");
> -#ifndef linux
> +#ifndef __linux__
> fprintf(stream, "\t-a aio_type,... Async io completion types to choose. Supported types\n");
> fprintf(stream, "\t are: poll, signal, suspend, and callback.\n");
> fprintf(stream, "\t Default is all of the above.\n");
> @@ -1643,7 +1643,7 @@ FILE *stream;
> fprintf(stream, "\t-q Quiet mode. Normally iogen spits out info\n");
> fprintf(stream, "\t about test files, options, etc. before starting.\n");
> fprintf(stream, "\t-s syscall,... Syscalls to do. Supported syscalls are\n");
> -#ifdef linux
> +#ifdef __linux__
> fprintf(stream, "\t read, write, pread, pwrite, readv, writev,\n");
> fprintf(stream, "\t mmread, mmwrite, fsync2, fdatasync,\n");
> fprintf(stream, "\t Default is 'read,write,readv,writev,mmread,mmwrite'.\n");
> --
> 2.48.0
>
>
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 7/7] lib: remove random.c
2025-03-10 18:29 ` [PATCH 7/7] lib: remove random.c Eric Sandeen
@ 2025-03-16 14:54 ` Zorro Lang
2025-03-16 15:48 ` Eric Sandeen
0 siblings, 1 reply; 20+ messages in thread
From: Zorro Lang @ 2025-03-16 14:54 UTC (permalink / raw)
To: Eric Sandeen; +Cc: fstests, djwong, hch, Christoph Hellwig
On Mon, Mar 10, 2025 at 01:29:09PM -0500, Eric Sandeen wrote:
> sparse points out that lots of things in random.c could be static,
> and upon doing so we realize that nothing in this file is used.
> Which is unsurprising since these are all part of the standard
> C library ... so just remove the file.
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> ---
Hi Eric,
When I did the fstests regression test this weekend, I found a regression
failure on generic/007 (diff output):
--- /dev/fd/63 2025-03-15 13:31:35.044534292 -0400
+++ generic/007.out.bad 2025-03-15 13:31:35.002455111 -0400
@@ -14,9 +14,9 @@
.........................................................................
.........................................................................
....................................................
-creates: 18736 OK, 18802 EEXIST ( 37538 total, 50% EEXIST)
-removes: 18675 OK, 19927 ENOENT ( 38602 total, 51% ENOENT)
-lookups: 12000 OK, 11860 ENOENT ( 23860 total, 49% ENOENT)
-total : 49411 OK, 50589 w/error (100000 total, 50% w/error)
+creates: 18839 OK, 18890 EEXIST ( 37729 total, 50% EEXIST)
+removes: 18783 OK, 19951 ENOENT ( 38734 total, 51% ENOENT)
+lookups: 11858 OK, 11679 ENOENT ( 23537 total, 49% ENOENT)
+total : 49480 OK, 50520 w/error (100000 total, 50% w/error)
-cleanup: 61 removes
+cleanup: 56 removes
By bisecting, the first failed commit is this patch. After removing
the fstests internal lib/random.c, the output of src/nametest.c is
changed too, that breaks the g/007 (xfs/188 maybe too) test.
It fails on all filesystems (e.g. xfs, ext2/3/4, btrfs, tmpfs, nfs,
cifs etc). I'll defer the release of this week (03.16), hope we can
fix this regression next week :)
Thanks,
Zorro
> lib/Makefile | 5 +-
> lib/random.c | 224 ---------------------------------------------------
> 2 files changed, 2 insertions(+), 227 deletions(-)
> delete mode 100644 lib/random.c
>
> diff --git a/lib/Makefile b/lib/Makefile
> index 53540ca7..ce4381a2 100644
> --- a/lib/Makefile
> +++ b/lib/Makefile
> @@ -11,13 +11,12 @@ LT_REVISION = 0
> LT_AGE = 0
>
> #
> -# Everything (except for random.c) copied directly from LTP.
> +# Everything copied directly from LTP.
> # Refer to http://ltp.sourceforge.net/ for complete source.
> #
> CFILES = dataascii.c databin.c datapid.c file_lock.c forker.c \
> pattern.c open_flags.c random_range.c string_to_tokens.c \
> - str_to_bytes.c tlibio.c write_log.c \
> - random.c
> + str_to_bytes.c tlibio.c write_log.c
>
> default: depend $(LTLIBRARY)
>
> diff --git a/lib/random.c b/lib/random.c
> deleted file mode 100644
> index d5c81be8..00000000
> --- a/lib/random.c
> +++ /dev/null
> @@ -1,224 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0+
> -/*
> - * random.c -- pseudo random number generator
> - * Copyright (C) 1994 Chris Wallace (csw@bruce.cs.monash.edu.au)
> - */
> -
> -#include <sys/types.h>
> -
> -/*
> - * modified by dxm@sgi.com so that this file acts as a drop in replacement
> - * for srandom and random.
> - */
> -
> -/*
> - * A random number generator called as a function by
> - * random (iseed) or irandm (iseed)
> - * The parameter should be a pointer to a 2-element int32_t vector.
> - * The first function returns a double uniform in 0 .. 1.
> - * The second returns a int32_t integer uniform in 0 .. 2**31-1
> - * Both update iseed[] in exactly the same way.
> - * iseed[] must be a 2-element integer vector.
> - * The initial value of the second element may be anything.
> - *
> - * The period of the random sequence is 2**32 * (2**32-1)
> - * The table mt[0:127] is defined by mt[i] = 69069 ** (128-i)
> - */
> -
> -#define MASK ((int32_t) 593970775)
> -/* or in hex, 23674657 */
> -
> -#define SCALE ((double) 1.0 / (1024.0 * 1024.0 * 1024.0 * 2.0))
> -/* i.e. 2 to power -31 */
> -
> -static int32_t mt [128] = {
> - 902906369,
> - 2030498053,
> - -473499623,
> - 1640834941,
> - 723406961,
> - 1993558325,
> - -257162999,
> - -1627724755,
> - 913952737,
> - 278845029,
> - 1327502073,
> - -1261253155,
> - 981676113,
> - -1785280363,
> - 1700077033,
> - 366908557,
> - -1514479167,
> - -682799163,
> - 141955545,
> - -830150595,
> - 317871153,
> - 1542036469,
> - -946413879,
> - -1950779155,
> - 985397153,
> - 626515237,
> - 530871481,
> - 783087261,
> - -1512358895,
> - 1031357269,
> - -2007710807,
> - -1652747955,
> - -1867214463,
> - 928251525,
> - 1243003801,
> - -2132510467,
> - 1874683889,
> - -717013323,
> - 218254473,
> - -1628774995,
> - -2064896159,
> - 69678053,
> - 281568889,
> - -2104168611,
> - -165128239,
> - 1536495125,
> - -39650967,
> - 546594317,
> - -725987007,
> - 1392966981,
> - 1044706649,
> - 687331773,
> - -2051306575,
> - 1544302965,
> - -758494647,
> - -1243934099,
> - -75073759,
> - 293132965,
> - -1935153095,
> - 118929437,
> - 807830417,
> - -1416222507,
> - -1550074071,
> - -84903219,
> - 1355292929,
> - -380482555,
> - -1818444007,
> - -204797315,
> - 170442609,
> - -1636797387,
> - 868931593,
> - -623503571,
> - 1711722209,
> - 381210981,
> - -161547783,
> - -272740131,
> - -1450066095,
> - 2116588437,
> - 1100682473,
> - 358442893,
> - -1529216831,
> - 2116152005,
> - -776333095,
> - 1265240893,
> - -482278607,
> - 1067190005,
> - 333444553,
> - 86502381,
> - 753481377,
> - 39000101,
> - 1779014585,
> - 219658653,
> - -920253679,
> - 2029538901,
> - 1207761577,
> - -1515772851,
> - -236195711,
> - 442620293,
> - 423166617,
> - -1763648515,
> - -398436623,
> - -1749358155,
> - -538598519,
> - -652439379,
> - 430550625,
> - -1481396507,
> - 2093206905,
> - -1934691747,
> - -962631983,
> - 1454463253,
> - -1877118871,
> - -291917555,
> - -1711673279,
> - 201201733,
> - -474645415,
> - -96764739,
> - -1587365199,
> - 1945705589,
> - 1303896393,
> - 1744831853,
> - 381957665,
> - 2135332261,
> - -55996615,
> - -1190135011,
> - 1790562961,
> - -1493191723,
> - 475559465,
> - 69069
> - };
> -
> -double
> -_random (int32_t is [2])
> -{
> - int32_t it, leh, nit;
> -
> - it = is [0];
> - leh = is [1];
> - if (it <= 0)
> - it = (it + it) ^ MASK;
> - else
> - it = it + it;
> - nit = it - 1;
> -/* to ensure all-ones pattern omitted */
> - leh = leh * mt[nit & 127] + nit;
> - is [0] = it; is [1] = leh;
> - if (leh < 0) leh = ~leh;
> - return (SCALE * ((int32_t) (leh | 1)));
> -}
> -
> -
> -
> -int32_t
> -_irandm (int32_t is [2])
> -{
> - int32_t it, leh, nit;
> -
> - it = is [0];
> - leh = is [1];
> - if (it <= 0)
> - it = (it + it) ^ MASK;
> - else
> - it = it + it;
> - nit = it - 1;
> -/* to ensure all-ones pattern omitted */
> - leh = leh * mt[nit & 127] + nit;
> - is [0] = it; is [1] = leh;
> - if (leh < 0) leh = ~leh;
> - return (leh);
> -}
> -
> -/*
> - * make this a drop in replacement for random and srandom
> - *
> - * XXX not thread safe I guess.
> - */
> -
> -static int32_t saved_seed[2];
> -
> -long random(void)
> -{
> - return _irandm(saved_seed);
> -}
> -
> -void srandom(unsigned seed)
> -{
> - saved_seed[0]=seed;
> - saved_seed[1]=0;
> - _irandm(saved_seed);
> -}
> -
> --
> 2.48.0
>
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 7/7] lib: remove random.c
2025-03-16 14:54 ` Zorro Lang
@ 2025-03-16 15:48 ` Eric Sandeen
2025-03-16 16:40 ` Darrick J. Wong
2025-03-16 16:42 ` Zorro Lang
0 siblings, 2 replies; 20+ messages in thread
From: Eric Sandeen @ 2025-03-16 15:48 UTC (permalink / raw)
To: Zorro Lang; +Cc: fstests, djwong, hch, Christoph Hellwig
On 3/16/25 9:54 AM, Zorro Lang wrote:
> On Mon, Mar 10, 2025 at 01:29:09PM -0500, Eric Sandeen wrote:
>> sparse points out that lots of things in random.c could be static,
>> and upon doing so we realize that nothing in this file is used.
>> Which is unsurprising since these are all part of the standard
>> C library ... so just remove the file.
>>
>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
>> Reviewed-by: Christoph Hellwig <hch@lst.de>
>> ---
>
> Hi Eric,
>
> When I did the fstests regression test this weekend, I found a regression
> failure on generic/007 (diff output):
>
> --- /dev/fd/63 2025-03-15 13:31:35.044534292 -0400
> +++ generic/007.out.bad 2025-03-15 13:31:35.002455111 -0400
> @@ -14,9 +14,9 @@
> .........................................................................
> .........................................................................
> ....................................................
> -creates: 18736 OK, 18802 EEXIST ( 37538 total, 50% EEXIST)
> -removes: 18675 OK, 19927 ENOENT ( 38602 total, 51% ENOENT)
> -lookups: 12000 OK, 11860 ENOENT ( 23860 total, 49% ENOENT)
> -total : 49411 OK, 50589 w/error (100000 total, 50% w/error)
> +creates: 18839 OK, 18890 EEXIST ( 37729 total, 50% EEXIST)
> +removes: 18783 OK, 19951 ENOENT ( 38734 total, 51% ENOENT)
> +lookups: 11858 OK, 11679 ENOENT ( 23537 total, 49% ENOENT)
> +total : 49480 OK, 50520 w/error (100000 total, 50% w/error)
>
> -cleanup: 61 removes
> +cleanup: 56 removes
>
> By bisecting, the first failed commit is this patch. After removing
> the fstests internal lib/random.c, the output of src/nametest.c is
> changed too, that breaks the g/007 (xfs/188 maybe too) test.
>
> It fails on all filesystems (e.g. xfs, ext2/3/4, btrfs, tmpfs, nfs,
> cifs etc). I'll defer the release of this week (03.16), hope we can
> fix this regression next week :)
Oh no, I'm sorry. I thought that if this stuff was never used it'd
be safe to just yank, but I clearly must have missed something.
It's probably best to just revert/remove this patch for now, so it
doesn't delay any release.
-Eric
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 7/7] lib: remove random.c
2025-03-16 15:48 ` Eric Sandeen
@ 2025-03-16 16:40 ` Darrick J. Wong
2025-03-16 18:06 ` Eric Sandeen
2025-03-16 16:42 ` Zorro Lang
1 sibling, 1 reply; 20+ messages in thread
From: Darrick J. Wong @ 2025-03-16 16:40 UTC (permalink / raw)
To: Eric Sandeen; +Cc: Zorro Lang, fstests, hch, Christoph Hellwig
On Sun, Mar 16, 2025 at 10:48:50AM -0500, Eric Sandeen wrote:
> On 3/16/25 9:54 AM, Zorro Lang wrote:
> > On Mon, Mar 10, 2025 at 01:29:09PM -0500, Eric Sandeen wrote:
> >> sparse points out that lots of things in random.c could be static,
> >> and upon doing so we realize that nothing in this file is used.
> >> Which is unsurprising since these are all part of the standard
> >> C library ... so just remove the file.
> >>
> >> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> >> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
> >> Reviewed-by: Christoph Hellwig <hch@lst.de>
> >> ---
> >
> > Hi Eric,
> >
> > When I did the fstests regression test this weekend, I found a regression
> > failure on generic/007 (diff output):
> >
> > --- /dev/fd/63 2025-03-15 13:31:35.044534292 -0400
> > +++ generic/007.out.bad 2025-03-15 13:31:35.002455111 -0400
> > @@ -14,9 +14,9 @@
> > .........................................................................
> > .........................................................................
> > ....................................................
> > -creates: 18736 OK, 18802 EEXIST ( 37538 total, 50% EEXIST)
> > -removes: 18675 OK, 19927 ENOENT ( 38602 total, 51% ENOENT)
> > -lookups: 12000 OK, 11860 ENOENT ( 23860 total, 49% ENOENT)
> > -total : 49411 OK, 50589 w/error (100000 total, 50% w/error)
> > +creates: 18839 OK, 18890 EEXIST ( 37729 total, 50% EEXIST)
> > +removes: 18783 OK, 19951 ENOENT ( 38734 total, 51% ENOENT)
> > +lookups: 11858 OK, 11679 ENOENT ( 23537 total, 49% ENOENT)
> > +total : 49480 OK, 50520 w/error (100000 total, 50% w/error)
> >
> > -cleanup: 61 removes
> > +cleanup: 56 removes
> >
> > By bisecting, the first failed commit is this patch. After removing
> > the fstests internal lib/random.c, the output of src/nametest.c is
> > changed too, that breaks the g/007 (xfs/188 maybe too) test.
> >
> > It fails on all filesystems (e.g. xfs, ext2/3/4, btrfs, tmpfs, nfs,
> > cifs etc). I'll defer the release of this week (03.16), hope we can
> > fix this regression next week :)
>
> Oh no, I'm sorry. I thought that if this stuff was never used it'd
> be safe to just yank, but I clearly must have missed something.
Ahahaha, it's linked into libtest.a, which is then linked into every
fstests binary. Therefore, any binary calling srandom and random get
this bespoke version instead of the one in the C library. From the
looks of it, the RNG code itself runs the same operations in the same
order every time, which is why you can pass a seed to fsx/fsstress to
get the exact same sequence of operations.
Maybe lib/random.c should have its comment updated? Clearly two
reviewers, myself, and the patch author missed this point:
/*
* modified by dxm@sgi.com so that this file acts as a drop in replacement
* for srandom and random.
*/
Because that doesn't really explain /why/ the code is needed as a drop
in replacement. How about:
/*
* modified by dxm@sgi.com so that this file acts as a drop in replacement
* for srandom and random. fstests programs rely on the exact sequence
* of integers generated by these functions for reproducibility and the
* golden output, which is why we override the C library.
*/
--D
> It's probably best to just revert/remove this patch for now, so it
> doesn't delay any release.
>
> -Eric
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 7/7] lib: remove random.c
2025-03-16 15:48 ` Eric Sandeen
2025-03-16 16:40 ` Darrick J. Wong
@ 2025-03-16 16:42 ` Zorro Lang
1 sibling, 0 replies; 20+ messages in thread
From: Zorro Lang @ 2025-03-16 16:42 UTC (permalink / raw)
To: Eric Sandeen; +Cc: fstests, djwong, hch, Christoph Hellwig
On Sun, Mar 16, 2025 at 10:48:50AM -0500, Eric Sandeen wrote:
> On 3/16/25 9:54 AM, Zorro Lang wrote:
> > On Mon, Mar 10, 2025 at 01:29:09PM -0500, Eric Sandeen wrote:
> >> sparse points out that lots of things in random.c could be static,
> >> and upon doing so we realize that nothing in this file is used.
> >> Which is unsurprising since these are all part of the standard
> >> C library ... so just remove the file.
> >>
> >> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> >> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
> >> Reviewed-by: Christoph Hellwig <hch@lst.de>
> >> ---
> >
> > Hi Eric,
> >
> > When I did the fstests regression test this weekend, I found a regression
> > failure on generic/007 (diff output):
> >
> > --- /dev/fd/63 2025-03-15 13:31:35.044534292 -0400
> > +++ generic/007.out.bad 2025-03-15 13:31:35.002455111 -0400
> > @@ -14,9 +14,9 @@
> > .........................................................................
> > .........................................................................
> > ....................................................
> > -creates: 18736 OK, 18802 EEXIST ( 37538 total, 50% EEXIST)
> > -removes: 18675 OK, 19927 ENOENT ( 38602 total, 51% ENOENT)
> > -lookups: 12000 OK, 11860 ENOENT ( 23860 total, 49% ENOENT)
> > -total : 49411 OK, 50589 w/error (100000 total, 50% w/error)
> > +creates: 18839 OK, 18890 EEXIST ( 37729 total, 50% EEXIST)
> > +removes: 18783 OK, 19951 ENOENT ( 38734 total, 51% ENOENT)
> > +lookups: 11858 OK, 11679 ENOENT ( 23537 total, 49% ENOENT)
> > +total : 49480 OK, 50520 w/error (100000 total, 50% w/error)
> >
> > -cleanup: 61 removes
> > +cleanup: 56 removes
> >
> > By bisecting, the first failed commit is this patch. After removing
> > the fstests internal lib/random.c, the output of src/nametest.c is
> > changed too, that breaks the g/007 (xfs/188 maybe too) test.
> >
> > It fails on all filesystems (e.g. xfs, ext2/3/4, btrfs, tmpfs, nfs,
> > cifs etc). I'll defer the release of this week (03.16), hope we can
> > fix this regression next week :)
>
> Oh no, I'm sorry. I thought that if this stuff was never used it'd
> be safe to just yank, but I clearly must have missed something.
>
> It's probably best to just revert/remove this patch for now, so it
> doesn't delay any release.
Sure, thanks Eric. Not only generic/007, generic/311 fails on this patch
too. I'll revert this patch, then release fstests.
>
> -Eric
>
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH 7/7] lib: remove random.c
2025-03-16 16:40 ` Darrick J. Wong
@ 2025-03-16 18:06 ` Eric Sandeen
0 siblings, 0 replies; 20+ messages in thread
From: Eric Sandeen @ 2025-03-16 18:06 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Zorro Lang, fstests, hch, Christoph Hellwig
On 3/16/25 11:40 AM, Darrick J. Wong wrote:
> On Sun, Mar 16, 2025 at 10:48:50AM -0500, Eric Sandeen wrote:
>> On 3/16/25 9:54 AM, Zorro Lang wrote:
>>> On Mon, Mar 10, 2025 at 01:29:09PM -0500, Eric Sandeen wrote:
>>>> sparse points out that lots of things in random.c could be static,
>>>> and upon doing so we realize that nothing in this file is used.
>>>> Which is unsurprising since these are all part of the standard
>>>> C library ... so just remove the file.
>>>>
>>>> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
>>>> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
>>>> Reviewed-by: Christoph Hellwig <hch@lst.de>
>>>> ---
>>>
>>> Hi Eric,
>>>
>>> When I did the fstests regression test this weekend, I found a regression
>>> failure on generic/007 (diff output):
>>>
>>> --- /dev/fd/63 2025-03-15 13:31:35.044534292 -0400
>>> +++ generic/007.out.bad 2025-03-15 13:31:35.002455111 -0400
>>> @@ -14,9 +14,9 @@
>>> .........................................................................
>>> .........................................................................
>>> ....................................................
>>> -creates: 18736 OK, 18802 EEXIST ( 37538 total, 50% EEXIST)
>>> -removes: 18675 OK, 19927 ENOENT ( 38602 total, 51% ENOENT)
>>> -lookups: 12000 OK, 11860 ENOENT ( 23860 total, 49% ENOENT)
>>> -total : 49411 OK, 50589 w/error (100000 total, 50% w/error)
>>> +creates: 18839 OK, 18890 EEXIST ( 37729 total, 50% EEXIST)
>>> +removes: 18783 OK, 19951 ENOENT ( 38734 total, 51% ENOENT)
>>> +lookups: 11858 OK, 11679 ENOENT ( 23537 total, 49% ENOENT)
>>> +total : 49480 OK, 50520 w/error (100000 total, 50% w/error)
>>>
>>> -cleanup: 61 removes
>>> +cleanup: 56 removes
>>>
>>> By bisecting, the first failed commit is this patch. After removing
>>> the fstests internal lib/random.c, the output of src/nametest.c is
>>> changed too, that breaks the g/007 (xfs/188 maybe too) test.
>>>
>>> It fails on all filesystems (e.g. xfs, ext2/3/4, btrfs, tmpfs, nfs,
>>> cifs etc). I'll defer the release of this week (03.16), hope we can
>>> fix this regression next week :)
>>
>> Oh no, I'm sorry. I thought that if this stuff was never used it'd
>> be safe to just yank, but I clearly must have missed something.
>
> Ahahaha, it's linked into libtest.a, which is then linked into every
> fstests binary. Therefore, any binary calling srandom and random get
> this bespoke version instead of the one in the C library. From the
> looks of it, the RNG code itself runs the same operations in the same
> order every time, which is why you can pass a seed to fsx/fsstress to
> get the exact same sequence of operations.
>
> Maybe lib/random.c should have its comment updated? Clearly two
> reviewers, myself, and the patch author missed this point:
>
> /*
> * modified by dxm@sgi.com so that this file acts as a drop in replacement
> * for srandom and random.
> */
>
> Because that doesn't really explain /why/ the code is needed as a drop
> in replacement. How about:
>
> /*
> * modified by dxm@sgi.com so that this file acts as a drop in replacement
> * for srandom and random. fstests programs rely on the exact sequence
> * of integers generated by these functions for reproducibility and the
> * golden output, which is why we override the C library.
> */
Yeah, I agree. We need a stable random.c copy for reproducibility on
tests that expect it. :( Sorry about that, it's my near-constant
reminder that even "trivial" changes need testing :(
And I'll figure out how to make sparse happier about it.
-Eric
> --D
>
>> It's probably best to just revert/remove this patch for now, so it
>> doesn't delay any release.
>>
>> -Eric
>>
>
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2025-03-16 18:06 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-10 18:29 [PATCH 0/7 V2] fstests: enable sparse checking & fix fallout Eric Sandeen
2025-03-10 18:29 ` [PATCH 1/7] fstests: enable sparse checking with make C=[12] Eric Sandeen
2025-03-10 18:29 ` [PATCH 2/7] treewide: check for #ifdef __linux__ not linux Eric Sandeen
2025-03-11 7:37 ` Christoph Hellwig
2025-03-11 13:44 ` Eric Sandeen
2025-03-11 13:46 ` [PATCH 2/7 V3] " Eric Sandeen
2025-03-11 15:25 ` Darrick J. Wong
2025-03-10 18:29 ` [PATCH 3/7] lib: Fix non-ANSI function declarations Eric Sandeen
2025-03-10 18:29 ` [PATCH 4/7] lib: fix empty arg function prototypes Eric Sandeen
2025-03-10 18:29 ` [PATCH 5/7] lib: replace aiocb_t with struct aiocb Eric Sandeen
2025-03-10 18:29 ` [PATCH 6/7] lib: make a few symbols static Eric Sandeen
2025-03-10 18:29 ` [PATCH 7/7] lib: remove random.c Eric Sandeen
2025-03-16 14:54 ` Zorro Lang
2025-03-16 15:48 ` Eric Sandeen
2025-03-16 16:40 ` Darrick J. Wong
2025-03-16 18:06 ` Eric Sandeen
2025-03-16 16:42 ` Zorro Lang
-- strict thread matches above, loose matches on Subject: below --
2025-02-06 21:19 [PATCH 0/7] fstests: enable sparse checking & fix fallout Eric Sandeen
2025-02-06 21:20 ` [PATCH 7/7] lib: remove random.c Eric Sandeen
2025-02-06 22:47 ` Darrick J. Wong
2025-02-07 5:01 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox