fstests: enable sparse checking & fix fallout
Subsystems (2)
v2 cover fstests: enable sparse checking & fix fallout
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
PATCH v2 1/7 fstests: enable sparse checking with make C=[12]
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.
--- Makefile | 14 ++++++++++++++ include/buildrules | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+)
Makefile +14 -0
@@ -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 = .
include/buildrules +19 -0
@@ -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)
Signature · 1 line
2.48.0
PATCH v2 2/7 treewide: check for #ifdef __linux__ not linux
In reply to Eric SandeenThere 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."
--- 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(-)
include/tlibio.h +3 -3
@@ -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 */
include/write_log.h +1 -1
@@ -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
lib/str_to_bytes.c +1 -1
@@ -31,7 +31,7 @@* ****************************************************************************/ -#if linux +#ifdef __linux__#define B_MULT DEV_BSIZE/* block size */ #endif
lib/tlibio.c +6 -6
@@ -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 /***********************************************************************
lib/write_log.c +1 -1
@@ -49,7 +49,7 @@#include "write_log.h" #ifndef BSIZE -#ifdef linux +#ifdef __linux__#define BSIZE DEV_BSIZE#else #define BSIZE BBSIZE
ltp/doio.c +4 -4
@@ -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;
ltp/iogen.c +3 -3
@@ -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" );
Signature · 1 line
2.48.0
Re: [PATCH 2/7] treewide: check for #ifdef __linux__ not linux
Quoted 7 lines · 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 <[email protected]>
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:
Re: [PATCH 2/7] treewide: check for #ifdef __linux__ not linux
Quoted 9 lines · Christoph Hellwig
Quoted 7 lines · 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 <[email protected]>
Quoted 7 lines
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 <[email protected]>
Was an attempt to give you credit for your suggestion.
I will send V3 with a changed commit log.
PATCH v3 2/7 treewide: check for #ifdef __linux__ not linux
In reply to Eric SandeenThere 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.
--- 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(-)
include/tlibio.h +3 -3
@@ -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 */
include/write_log.h +1 -1
@@ -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
lib/str_to_bytes.c +1 -1
@@ -31,7 +31,7 @@* ****************************************************************************/ -#if linux +#ifdef __linux__#define B_MULT DEV_BSIZE/* block size */ #endif
lib/tlibio.c +6 -6
@@ -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 /***********************************************************************
lib/write_log.c +1 -1
@@ -49,7 +49,7 @@#include "write_log.h" #ifndef BSIZE -#ifdef linux +#ifdef __linux__#define BSIZE DEV_BSIZE#else #define BSIZE BBSIZE
ltp/doio.c +4 -4
@@ -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;
ltp/iogen.c +3 -3
@@ -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" );
Signature · 1 line
2.48.0
Re: [PATCH 2/7 V3] treewide: check for #ifdef __linux__ not linux
Quoted 8 lines · 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 is defined by both gcc and sparse.Signed-off-by Eric Sandeen <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>
Looks good to me,
--D
Quoted 213 lines
--- 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(-)include/tlibio.h +3
-3@@ -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 */ include/write_log.h +1
-1@@ -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 lib/str_to_bytes.c +1
-1@@ -31,7 +31,7 @@* ****************************************************************************/ -#if linux +#ifdef __linux__#define B_MULT DEV_BSIZE/* block size */ #endif lib/tlibio.c +6
-6@@ -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 /*********************************************************************** lib/write_log.c +1
-1@@ -49,7 +49,7 @@#include "write_log.h" #ifndef BSIZE -#ifdef linux +#ifdef __linux__#define BSIZE DEV_BSIZE#else #define BSIZE BBSIZEltp/doio.c +4
-4@@ -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;ltp/iogen.c +3
-3@@ -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" );Signature · 1 line
2.48.0
PATCH v2 3/7 lib: Fix non-ANSI function declarations
In reply to Eric Sandeenlib/ was full of non-ANSI function declarations, fix them to make sparse happier.
--- 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(-)
lib/dataascii.c +28 -31
@@ -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" );
lib/databin.c +13 -15
@@ -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 ;
lib/datapid.c +11 -21
@@ -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" );
lib/file_lock.c +2 -10
@@ -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) { registerint 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) { registerint cmd, ret;struct flock flocks;
lib/forker.c +8 -11
@@ -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 ;
lib/pattern.c +2 -12
@@ -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;
lib/random_range.c +18 -43
125 lines not on this page · raw message
lib/str_to_bytes.c +3 -6
@@ -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;
lib/tlibio.c +24 -26
74 lines not on this page · raw message
lib/write_log.c +10 -22
@@ -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;
Signature · 1 line
2.48.0
PATCH v2 4/7 lib: fix empty arg function prototypes
In reply to Eric SandeenSeveral function prototypes used () when in fact they take arguments. Fix those to make sparse happy.
--- 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(-)
include/random_range.h +1 -1
@@ -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 );
include/write_log.h +1 -1
@@ -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 ();
lib/random_range.c +2 -4
@@ -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); }
lib/string_to_tokens.c +0 -1
@@ -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 ;
lib/tlibio.c +1 -1
@@ -75,7 +75,7 @@#ifndef __linux__ -static void lio_async_signal_handler (); +static void lio_async_signal_handler (int sig);#endif /*
lib/write_log.c +1 -1
@@ -217,7 +217,7 @@ intwlog_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;
Signature · 1 line
2.48.0
PATCH v2 5/7 lib: replace aiocb_t with struct aiocb
In reply to Eric Sandeenaiocb_t isn't defined anywhere, use struct aiocb instead, to make sparse happy.
--- lib/tlibio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
lib/tlibio.c +5 -3
@@ -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 ) ){
Signature · 1 line
2.48.0
PATCH v2 6/7 lib: make a few symbols static
In reply to Eric SandeenThere are a few symbols in lib/tlibio.c which should be static, and sparse notices this so fix it.
--- lib/tlibio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/tlibio.c +3 -1
@@ -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;
Signature · 1 line
2.48.0
PATCH v2 7/7 lib: remove random.c
In reply to Eric Sandeensparse 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.
--- lib/Makefile | 5 +- lib/random.c | 224 --------------------------------------------------- 2 files changed, 2 insertions(+), 227 deletions(-) delete mode 100644 lib/random.c
lib/Makefile +2 -3
@@ -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)
lib/random.c deleted +0 -224
224 lines not on this page · raw message
Signature · 1 line
2.48.0
Re: [PATCH 7/7] lib: remove random.c
Quoted 9 lines · Eric Sandeen
sparse points out that lots of things in
random.ccould 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 <[email protected]>Reviewed-by "Darrick J. Wong" <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>---
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
Quoted 259 lines
lib/Makefile | 5 +- lib/random.c | 224 --------------------------------------------------- 2 files changed, 2 insertions(+), 227 deletions(-) delete mode 100644 lib/random.clib/Makefile +2
-3@@ -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)lib/random.c deleted +0
-224@@ -1,224 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* -* random.c -- pseudo random number generator -* Copyright (C) 1994 Chris Wallace ([email protected]) -*/ - -#include <sys/types.h> - -/* -* modified by [email protected] 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); -} -Signature · 1 line
2.48.0
Re: [PATCH 7/7] lib: remove random.c
Quoted 34 lines · Zorro Lang
Quoted 9 lines · Eric Sandeen
sparse points out that lots of things in
random.ccould 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 <[email protected]>Reviewed-by "Darrick J. Wong" <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>---
Hi Eric,
When I did the fstests regression test this weekend, I found a regression failure on generic/007 (diff output):
---
/dev/fd/632025-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
Quoted 7 lines
By bisecting, the first failed commit is this patch. After removing the fstests internal
lib/random.c, the output ofsrc/nametest.cis 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
Re: [PATCH 7/7] lib: remove random.c
Quoted 39 lines · Eric Sandeen
Quoted 38 lines · Zorro Lang
Quoted 9 lines · Eric Sandeen
sparse points out that lots of things in
random.ccould 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 <[email protected]>Reviewed-by "Darrick J. Wong" <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>---
Hi Eric,
When I did the fstests regression test this weekend, I found a regression failure on generic/007 (diff output):
---
/dev/fd/632025-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 removesBy bisecting, the first failed commit is this patch. After removing the fstests internal
lib/random.c, the output ofsrc/nametest.cis changed too, that breaks the g/007 (xfs/188 maybe too) test.
Quoted 6 lines
Quoted 3 lines
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 [email protected] 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 [email protected] 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
Quoted 5 lines
It's probably best to just revert/remove this patch for now, so it doesn't delay any release.
-Eric
Re: [PATCH 7/7] lib: remove random.c
Quoted 65 lines · Darrick J. Wong
Quoted 39 lines · Eric Sandeen
Quoted 38 lines · Zorro Lang
Quoted 9 lines · Eric Sandeen
sparse points out that lots of things in
random.ccould 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 <[email protected]>Reviewed-by "Darrick J. Wong" <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>---
Hi Eric,
When I did the fstests regression test this weekend, I found a regression failure on generic/007 (diff output):
---
/dev/fd/632025-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 removesBy bisecting, the first failed commit is this patch. After removing the fstests internal
lib/random.c, the output ofsrc/nametest.cis changed too, that breaks the g/007 (xfs/188 maybe too) test.Quoted 6 lines
Quoted 3 lines
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.cshould have its comment updated? Clearly two reviewers, myself, and the patch author missed this point:/*
* modified by [email protected] 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:
Quoted 6 lines
/*
* modified by [email protected] 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
Quoted 8 lines
--D
Quoted 5 lines
It's probably best to just revert/remove this patch for now, so it doesn't delay any release.
-Eric
Re: [PATCH 7/7] lib: remove random.c
In reply to Eric SandeenQuoted 43 lines · Eric Sandeen
Quoted 34 lines · Zorro Lang
Quoted 9 lines · Eric Sandeen
sparse points out that lots of things in
random.ccould 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 <[email protected]>Reviewed-by "Darrick J. Wong" <[email protected]>Reviewed-by Christoph Hellwig <[email protected]>---
Hi Eric,
When I did the fstests regression test this weekend, I found a regression failure on generic/007 (diff output):
---
/dev/fd/632025-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 removesQuoted 7 lines
By bisecting, the first failed commit is this patch. After removing the fstests internal
lib/random.c, the output ofsrc/nametest.cis 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 :)
Quoted 5 lines
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.
Quoted 3 lines
-Eric