* [PATCH 0/7] fstests: enable sparse checking & fix fallout
@ 2025-02-06 21:19 Eric Sandeen
2025-02-06 21:19 ` [PATCH 1/7] fstests: enable sparse checking with make C=[12] Eric Sandeen
` (6 more replies)
0 siblings, 7 replies; 26+ messages in thread
From: Eric Sandeen @ 2025-02-06 21:19 UTC (permalink / raw)
To: fstests
After the endian bug last week, hch asked whether we should enable
sparse checking in xfstests.
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.
Thanks,
-Eric
^ permalink raw reply [flat|nested] 26+ messages in thread* [PATCH 1/7] fstests: enable sparse checking with make C=[12] 2025-02-06 21:19 [PATCH 0/7] fstests: enable sparse checking & fix fallout Eric Sandeen @ 2025-02-06 21:19 ` Eric Sandeen 2025-02-06 22:36 ` Darrick J. Wong 2025-02-07 4:56 ` Christoph Hellwig 2025-02-06 21:19 ` [PATCH 2/7] builddefs: define linux Eric Sandeen ` (5 subsequent siblings) 6 siblings, 2 replies; 26+ messages in thread From: Eric Sandeen @ 2025-02-06 21:19 UTC (permalink / raw) To: fstests; +Cc: Eric Sandeen 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> --- Makefile | 14 ++++++++++++++ include/buildrules | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/Makefile b/Makefile index f6f91a4d..79779d5e 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] 26+ messages in thread
* Re: [PATCH 1/7] fstests: enable sparse checking with make C=[12] 2025-02-06 21:19 ` [PATCH 1/7] fstests: enable sparse checking with make C=[12] Eric Sandeen @ 2025-02-06 22:36 ` Darrick J. Wong 2025-02-07 4:56 ` Christoph Hellwig 1 sibling, 0 replies; 26+ messages in thread From: Darrick J. Wong @ 2025-02-06 22:36 UTC (permalink / raw) To: Eric Sandeen; +Cc: fstests On Thu, Feb 06, 2025 at 03:19:56PM -0600, Eric Sandeen wrote: > 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> Looks just like the one in xfsprogs and the kernel! Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > --- > Makefile | 14 ++++++++++++++ > include/buildrules | 19 +++++++++++++++++++ > 2 files changed, 33 insertions(+) > > diff --git a/Makefile b/Makefile > index f6f91a4d..79779d5e 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 [flat|nested] 26+ messages in thread
* Re: [PATCH 1/7] fstests: enable sparse checking with make C=[12] 2025-02-06 21:19 ` [PATCH 1/7] fstests: enable sparse checking with make C=[12] Eric Sandeen 2025-02-06 22:36 ` Darrick J. Wong @ 2025-02-07 4:56 ` Christoph Hellwig 1 sibling, 0 replies; 26+ messages in thread From: Christoph Hellwig @ 2025-02-07 4:56 UTC (permalink / raw) To: Eric Sandeen; +Cc: fstests Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 2/7] builddefs: define linux 2025-02-06 21:19 [PATCH 0/7] fstests: enable sparse checking & fix fallout Eric Sandeen 2025-02-06 21:19 ` [PATCH 1/7] fstests: enable sparse checking with make C=[12] Eric Sandeen @ 2025-02-06 21:19 ` Eric Sandeen 2025-02-06 22:39 ` Darrick J. Wong 2025-02-06 21:19 ` [PATCH 3/7] lib: Fix non-ANSI function declarations Eric Sandeen ` (4 subsequent siblings) 6 siblings, 1 reply; 26+ messages in thread From: Eric Sandeen @ 2025-02-06 21:19 UTC (permalink / raw) To: fstests; +Cc: Eric Sandeen There are several #ifdef linux guards in the code, but nothing defined it. This caused several sparse warnings, so define it when building on linux. Signed-off-by: Eric Sandeen <sandeen@redhat.com> --- include/builddefs.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/builddefs.in b/include/builddefs.in index 7274cde8..00dec0ea 100644 --- a/include/builddefs.in +++ b/include/builddefs.in @@ -78,7 +78,7 @@ HAVE_FICLONE = @have_ficlone@ GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall ifeq ($(PKG_PLATFORM),linux) -PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(GCCFLAGS) +PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -Dlinux $(GCCFLAGS) endif ifeq ($(PKG_PLATFORM),darwin) PCFLAGS = -traditional-cpp $(GCCFLAGS) -- 2.48.0 ^ permalink raw reply related [flat|nested] 26+ messages in thread
* Re: [PATCH 2/7] builddefs: define linux 2025-02-06 21:19 ` [PATCH 2/7] builddefs: define linux Eric Sandeen @ 2025-02-06 22:39 ` Darrick J. Wong 2025-02-07 1:09 ` Eric Sandeen 0 siblings, 1 reply; 26+ messages in thread From: Darrick J. Wong @ 2025-02-06 22:39 UTC (permalink / raw) To: Eric Sandeen; +Cc: fstests On Thu, Feb 06, 2025 at 03:19:57PM -0600, Eric Sandeen wrote: > There are several #ifdef linux guards in the code, but nothing > defined it. This caused several sparse warnings, so define it > when building on linux. cpp in gcc 12.2 defines this: $ touch /tmp/moo.h ; cpp -dM /tmp/moo.h | grep define.linux #define linux 1 --D > Signed-off-by: Eric Sandeen <sandeen@redhat.com> > --- > include/builddefs.in | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/include/builddefs.in b/include/builddefs.in > index 7274cde8..00dec0ea 100644 > --- a/include/builddefs.in > +++ b/include/builddefs.in > @@ -78,7 +78,7 @@ HAVE_FICLONE = @have_ficlone@ > GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall > > ifeq ($(PKG_PLATFORM),linux) > -PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(GCCFLAGS) > +PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -Dlinux $(GCCFLAGS) > endif > ifeq ($(PKG_PLATFORM),darwin) > PCFLAGS = -traditional-cpp $(GCCFLAGS) > -- > 2.48.0 > > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 2/7] builddefs: define linux 2025-02-06 22:39 ` Darrick J. Wong @ 2025-02-07 1:09 ` Eric Sandeen 2025-02-07 2:01 ` Darrick J. Wong 0 siblings, 1 reply; 26+ messages in thread From: Eric Sandeen @ 2025-02-07 1:09 UTC (permalink / raw) To: Darrick J. Wong, Eric Sandeen; +Cc: fstests On 2/6/25 4:39 PM, Darrick J. Wong wrote: > On Thu, Feb 06, 2025 at 03:19:57PM -0600, Eric Sandeen wrote: >> There are several #ifdef linux guards in the code, but nothing >> defined it. This caused several sparse warnings, so define it >> when building on linux. > > cpp in gcc 12.2 defines this: > > $ touch /tmp/moo.h ; cpp -dM /tmp/moo.h | grep define.linux > #define linux 1 Huh, on my test box too. And yet without this sparse coughs up lots of things for me: tlibio.c:90:20: error: undefined identifier 'LIO_IO_TYPES' tlibio.c:90:33: error: undefined identifier 'LIO_WAIT_TYPES' tlibio.c:92:20: error: undefined identifier 'LIO_IO_TYPES' tlibio.c:92:33: error: undefined identifier 'LIO_WAIT_TYPES' tlibio.c:118:20: error: undefined identifier 'LIO_IO_TYPES' tlibio.c:118:33: error: undefined identifier 'LIO_WAIT_TYPES' because i.e.: #ifdef linux #define LIO_IO_TYPES 00021 /* all io types */ #endif /* linux */ make V=1 shows: /bin/sh ../libtool --quiet --tag=CC --mode=compile gcc -g -O2 -g -O2 -DDEBUG -I../include -DVERSION=\"1.1.1\" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -funsigned-char -fno-strict-aliasing -Wall -c tlibio.c so not sure what's going on here ? > --D > >> Signed-off-by: Eric Sandeen <sandeen@redhat.com> >> --- >> include/builddefs.in | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/include/builddefs.in b/include/builddefs.in >> index 7274cde8..00dec0ea 100644 >> --- a/include/builddefs.in >> +++ b/include/builddefs.in >> @@ -78,7 +78,7 @@ HAVE_FICLONE = @have_ficlone@ >> GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall >> >> ifeq ($(PKG_PLATFORM),linux) >> -PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(GCCFLAGS) >> +PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -Dlinux $(GCCFLAGS) >> endif >> ifeq ($(PKG_PLATFORM),darwin) >> PCFLAGS = -traditional-cpp $(GCCFLAGS) >> -- >> 2.48.0 >> >> > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 2/7] builddefs: define linux 2025-02-07 1:09 ` Eric Sandeen @ 2025-02-07 2:01 ` Darrick J. Wong 2025-02-07 4:57 ` Christoph Hellwig 0 siblings, 1 reply; 26+ messages in thread From: Darrick J. Wong @ 2025-02-07 2:01 UTC (permalink / raw) To: Eric Sandeen; +Cc: Eric Sandeen, fstests On Thu, Feb 06, 2025 at 07:09:21PM -0600, Eric Sandeen wrote: > On 2/6/25 4:39 PM, Darrick J. Wong wrote: > > On Thu, Feb 06, 2025 at 03:19:57PM -0600, Eric Sandeen wrote: > >> There are several #ifdef linux guards in the code, but nothing > >> defined it. This caused several sparse warnings, so define it > >> when building on linux. > > > > cpp in gcc 12.2 defines this: > > > > $ touch /tmp/moo.h ; cpp -dM /tmp/moo.h | grep define.linux > > #define linux 1 > > Huh, on my test box too. > And yet without this sparse coughs up lots of things for me: > > tlibio.c:90:20: error: undefined identifier 'LIO_IO_TYPES' > tlibio.c:90:33: error: undefined identifier 'LIO_WAIT_TYPES' > tlibio.c:92:20: error: undefined identifier 'LIO_IO_TYPES' > tlibio.c:92:33: error: undefined identifier 'LIO_WAIT_TYPES' > tlibio.c:118:20: error: undefined identifier 'LIO_IO_TYPES' > tlibio.c:118:33: error: undefined identifier 'LIO_WAIT_TYPES' > > because i.e.: > > #ifdef linux > #define LIO_IO_TYPES 00021 /* all io types */ > #endif /* linux */ > > make V=1 shows: > > /bin/sh ../libtool --quiet --tag=CC --mode=compile gcc -g -O2 -g -O2 -DDEBUG -I../include -DVERSION=\"1.1.1\" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -funsigned-char -fno-strict-aliasing -Wall -c tlibio.c > > so not sure what's going on here ? sparse doesn't define linux by default: $ cat > /tmp/a.c << ENDL #ifdef linux # warning not #else # warning me #endif ENDL $ gcc -o /tmp/a.o /tmp/a.c /tmp/a.c:2:3: warning: #warning not [-Wcpp] 2 | # warning not | ^~~~~~~ /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/12/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status $ sparse /tmp/a.c /tmp/a.c:4:3: warning: me $ sparse /tmp/a.c -Dlinux /tmp/a.c:2:3: warning: not --D > > > --D > > > >> Signed-off-by: Eric Sandeen <sandeen@redhat.com> > >> --- > >> include/builddefs.in | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >> > >> diff --git a/include/builddefs.in b/include/builddefs.in > >> index 7274cde8..00dec0ea 100644 > >> --- a/include/builddefs.in > >> +++ b/include/builddefs.in > >> @@ -78,7 +78,7 @@ HAVE_FICLONE = @have_ficlone@ > >> GCCFLAGS = -funsigned-char -fno-strict-aliasing -Wall > >> > >> ifeq ($(PKG_PLATFORM),linux) > >> -PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 $(GCCFLAGS) > >> +PCFLAGS = -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -Dlinux $(GCCFLAGS) > >> endif > >> ifeq ($(PKG_PLATFORM),darwin) > >> PCFLAGS = -traditional-cpp $(GCCFLAGS) > >> -- > >> 2.48.0 > >> > >> > > > ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 2/7] builddefs: define linux 2025-02-07 2:01 ` Darrick J. Wong @ 2025-02-07 4:57 ` Christoph Hellwig 2025-02-07 5:06 ` Darrick J. Wong 0 siblings, 1 reply; 26+ messages in thread From: Christoph Hellwig @ 2025-02-07 4:57 UTC (permalink / raw) To: Darrick J. Wong; +Cc: Eric Sandeen, Eric Sandeen, fstests On Thu, Feb 06, 2025 at 06:01:36PM -0800, Darrick J. Wong wrote: > sparse doesn't define linux by default: Does it define __linux__? That's really the preferred version these days and we should probably switch over to that. ^ permalink raw reply [flat|nested] 26+ messages in thread
* Re: [PATCH 2/7] builddefs: define linux 2025-02-07 4:57 ` Christoph Hellwig @ 2025-02-07 5:06 ` Darrick J. Wong 0 siblings, 0 replies; 26+ messages in thread From: Darrick J. Wong @ 2025-02-07 5:06 UTC (permalink / raw) To: Christoph Hellwig; +Cc: Eric Sandeen, Eric Sandeen, fstests On Thu, Feb 06, 2025 at 08:57:54PM -0800, Christoph Hellwig wrote: > On Thu, Feb 06, 2025 at 06:01:36PM -0800, Darrick J. Wong wrote: > > sparse doesn't define linux by default: > > Does it define __linux__? That's really the preferred version these > days and we should probably switch over to that. It seems to do so, yes. --D ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 3/7] lib: Fix non-ANSI function declarations 2025-02-06 21:19 [PATCH 0/7] fstests: enable sparse checking & fix fallout Eric Sandeen 2025-02-06 21:19 ` [PATCH 1/7] fstests: enable sparse checking with make C=[12] Eric Sandeen 2025-02-06 21:19 ` [PATCH 2/7] builddefs: define linux Eric Sandeen @ 2025-02-06 21:19 ` Eric Sandeen 2025-02-06 22:39 ` Darrick J. Wong 2025-02-07 4:59 ` Christoph Hellwig 2025-02-06 21:19 ` [PATCH 4/7] lib: fix empty arg function prototypes Eric Sandeen ` (3 subsequent siblings) 6 siblings, 2 replies; 26+ messages in thread From: Eric Sandeen @ 2025-02-06 21:19 UTC (permalink / raw) To: fstests; +Cc: Eric Sandeen lib/ was full of non-ANSI function declarations, fix them to make sparse happier. Signed-off-by: Eric Sandeen <sandeen@redhat.com> --- 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 2f6b2b92..20cd2a0f 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 f7259734..3c23bf4d 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 cdc72593..c82cc1f4 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] 26+ messages in thread
* Re: [PATCH 3/7] lib: Fix non-ANSI function declarations 2025-02-06 21:19 ` [PATCH 3/7] lib: Fix non-ANSI function declarations Eric Sandeen @ 2025-02-06 22:39 ` Darrick J. Wong 2025-02-07 4:59 ` Christoph Hellwig 1 sibling, 0 replies; 26+ messages in thread From: Darrick J. Wong @ 2025-02-06 22:39 UTC (permalink / raw) To: Eric Sandeen; +Cc: fstests On Thu, Feb 06, 2025 at 03:19:58PM -0600, Eric Sandeen wrote: > lib/ was full of non-ANSI function declarations, fix them to make > sparse happier. > > Signed-off-by: Eric Sandeen <sandeen@redhat.com> K&R, you mean? "databingen", hah. Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > --- > 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 2f6b2b92..20cd2a0f 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 f7259734..3c23bf4d 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 cdc72593..c82cc1f4 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 [flat|nested] 26+ messages in thread
* Re: [PATCH 3/7] lib: Fix non-ANSI function declarations 2025-02-06 21:19 ` [PATCH 3/7] lib: Fix non-ANSI function declarations Eric Sandeen 2025-02-06 22:39 ` Darrick J. Wong @ 2025-02-07 4:59 ` Christoph Hellwig 1 sibling, 0 replies; 26+ messages in thread From: Christoph Hellwig @ 2025-02-07 4:59 UTC (permalink / raw) To: Eric Sandeen; +Cc: fstests On Thu, Feb 06, 2025 at 03:19:58PM -0600, Eric Sandeen wrote: > lib/ was full of non-ANSI function declarations, fix them to make > sparse happier. Oh fun. Great to get this fixed up. The path also seems to have a few formatting fixups in the area, but I'm not going to nitpick on this code.. Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 4/7] lib: fix empty arg function prototypes 2025-02-06 21:19 [PATCH 0/7] fstests: enable sparse checking & fix fallout Eric Sandeen ` (2 preceding siblings ...) 2025-02-06 21:19 ` [PATCH 3/7] lib: Fix non-ANSI function declarations Eric Sandeen @ 2025-02-06 21:19 ` Eric Sandeen 2025-02-06 22:45 ` Darrick J. Wong 2025-02-07 4:59 ` Christoph Hellwig 2025-02-06 21:20 ` [PATCH 5/7] lib: replace aiocb_t with struct aiocb Eric Sandeen ` (2 subsequent siblings) 6 siblings, 2 replies; 26+ messages in thread From: Eric Sandeen @ 2025-02-06 21:19 UTC (permalink / raw) To: fstests; +Cc: Eric Sandeen Several function prototypes used () when in fact they take arguments. Fix those to make sparse happy. Signed-off-by: Eric Sandeen <sandeen@redhat.com> --- 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 025ebac0..d02f898a 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 3c23bf4d..19192b38 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 c82cc1f4..e04fed4b 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] 26+ messages in thread
* Re: [PATCH 4/7] lib: fix empty arg function prototypes 2025-02-06 21:19 ` [PATCH 4/7] lib: fix empty arg function prototypes Eric Sandeen @ 2025-02-06 22:45 ` Darrick J. Wong 2025-02-07 4:59 ` Christoph Hellwig 1 sibling, 0 replies; 26+ messages in thread From: Darrick J. Wong @ 2025-02-06 22:45 UTC (permalink / raw) To: Eric Sandeen; +Cc: fstests On Thu, Feb 06, 2025 at 03:19:59PM -0600, Eric Sandeen wrote: > Several function prototypes used () when in fact they take > arguments. Fix those to make sparse happy. > > Signed-off-by: Eric Sandeen <sandeen@redhat.com> > --- > 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 025ebac0..d02f898a 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), This is a very similar version to what's in testcases/kernel/fs/doio/write_log.c in the LTP source. Maybe it's time to clean up both versions? Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > 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 3c23bf4d..19192b38 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 c82cc1f4..e04fed4b 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 [flat|nested] 26+ messages in thread
* Re: [PATCH 4/7] lib: fix empty arg function prototypes 2025-02-06 21:19 ` [PATCH 4/7] lib: fix empty arg function prototypes Eric Sandeen 2025-02-06 22:45 ` Darrick J. Wong @ 2025-02-07 4:59 ` Christoph Hellwig 1 sibling, 0 replies; 26+ messages in thread From: Christoph Hellwig @ 2025-02-07 4:59 UTC (permalink / raw) To: Eric Sandeen; +Cc: fstests Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 5/7] lib: replace aiocb_t with struct aiocb 2025-02-06 21:19 [PATCH 0/7] fstests: enable sparse checking & fix fallout Eric Sandeen ` (3 preceding siblings ...) 2025-02-06 21:19 ` [PATCH 4/7] lib: fix empty arg function prototypes Eric Sandeen @ 2025-02-06 21:20 ` Eric Sandeen 2025-02-06 22:46 ` Darrick J. Wong 2025-02-07 5:00 ` Christoph Hellwig 2025-02-06 21:20 ` [PATCH 6/7] lib: make a few symbols static Eric Sandeen 2025-02-06 21:20 ` [PATCH 7/7] lib: remove random.c Eric Sandeen 6 siblings, 2 replies; 26+ messages in thread From: Eric Sandeen @ 2025-02-06 21:20 UTC (permalink / raw) To: fstests; +Cc: Eric Sandeen aiocb_t isn't defined anywhere, use struct aiocb instead, to make sparse happy. Signed-off-by: Eric Sandeen <sandeen@redhat.com> --- lib/tlibio.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/tlibio.c b/lib/tlibio.c index 19192b38..22ff1adc 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] 26+ messages in thread
* Re: [PATCH 5/7] lib: replace aiocb_t with struct aiocb 2025-02-06 21:20 ` [PATCH 5/7] lib: replace aiocb_t with struct aiocb Eric Sandeen @ 2025-02-06 22:46 ` Darrick J. Wong 2025-02-07 5:00 ` Christoph Hellwig 1 sibling, 0 replies; 26+ messages in thread From: Darrick J. Wong @ 2025-02-06 22:46 UTC (permalink / raw) To: Eric Sandeen; +Cc: fstests On Thu, Feb 06, 2025 at 03:20:00PM -0600, Eric Sandeen wrote: > aiocb_t isn't defined anywhere, use struct aiocb instead, > to make sparse happy. > > Signed-off-by: Eric Sandeen <sandeen@redhat.com> libaio<shudder> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > --- > lib/tlibio.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) > > diff --git a/lib/tlibio.c b/lib/tlibio.c > index 19192b38..22ff1adc 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 [flat|nested] 26+ messages in thread
* Re: [PATCH 5/7] lib: replace aiocb_t with struct aiocb 2025-02-06 21:20 ` [PATCH 5/7] lib: replace aiocb_t with struct aiocb Eric Sandeen 2025-02-06 22:46 ` Darrick J. Wong @ 2025-02-07 5:00 ` Christoph Hellwig 1 sibling, 0 replies; 26+ messages in thread From: Christoph Hellwig @ 2025-02-07 5:00 UTC (permalink / raw) To: Eric Sandeen; +Cc: fstests Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 6/7] lib: make a few symbols static 2025-02-06 21:19 [PATCH 0/7] fstests: enable sparse checking & fix fallout Eric Sandeen ` (4 preceding siblings ...) 2025-02-06 21:20 ` [PATCH 5/7] lib: replace aiocb_t with struct aiocb Eric Sandeen @ 2025-02-06 21:20 ` Eric Sandeen 2025-02-06 22:46 ` Darrick J. Wong 2025-02-07 5:00 ` Christoph Hellwig 2025-02-06 21:20 ` [PATCH 7/7] lib: remove random.c Eric Sandeen 6 siblings, 2 replies; 26+ messages in thread From: Eric Sandeen @ 2025-02-06 21:20 UTC (permalink / raw) To: fstests; +Cc: Eric Sandeen 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> --- lib/tlibio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/tlibio.c b/lib/tlibio.c index 22ff1adc..2aa8175b 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] 26+ messages in thread
* Re: [PATCH 6/7] lib: make a few symbols static 2025-02-06 21:20 ` [PATCH 6/7] lib: make a few symbols static Eric Sandeen @ 2025-02-06 22:46 ` Darrick J. Wong 2025-02-07 5:00 ` Christoph Hellwig 1 sibling, 0 replies; 26+ messages in thread From: Darrick J. Wong @ 2025-02-06 22:46 UTC (permalink / raw) To: Eric Sandeen; +Cc: fstests On Thu, Feb 06, 2025 at 03:20:01PM -0600, Eric Sandeen wrote: > 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> Yep, that's pretty straightforward. Reviewed-by: "Darrick J. Wong" <djwong@kernel.org> --D > --- > lib/tlibio.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/lib/tlibio.c b/lib/tlibio.c > index 22ff1adc..2aa8175b 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 [flat|nested] 26+ messages in thread
* Re: [PATCH 6/7] lib: make a few symbols static 2025-02-06 21:20 ` [PATCH 6/7] lib: make a few symbols static Eric Sandeen 2025-02-06 22:46 ` Darrick J. Wong @ 2025-02-07 5:00 ` Christoph Hellwig 1 sibling, 0 replies; 26+ messages in thread From: Christoph Hellwig @ 2025-02-07 5:00 UTC (permalink / raw) To: Eric Sandeen; +Cc: fstests Looks good: Reviewed-by: Christoph Hellwig <hch@lst.de> ^ permalink raw reply [flat|nested] 26+ messages in thread
* [PATCH 7/7] lib: remove random.c 2025-02-06 21:19 [PATCH 0/7] fstests: enable sparse checking & fix fallout Eric Sandeen ` (5 preceding siblings ...) 2025-02-06 21:20 ` [PATCH 6/7] lib: make a few symbols static Eric Sandeen @ 2025-02-06 21:20 ` Eric Sandeen 2025-02-06 22:47 ` Darrick J. Wong 2025-02-07 5:01 ` Christoph Hellwig 6 siblings, 2 replies; 26+ 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] 26+ 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; 26+ 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] 26+ 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; 26+ 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] 26+ 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 3/7] lib: Fix non-ANSI function declarations Eric Sandeen 0 siblings, 1 reply; 26+ 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] 26+ 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 ` Eric Sandeen 0 siblings, 0 replies; 26+ 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] 26+ messages in thread
end of thread, other threads:[~2025-03-10 18:30 UTC | newest] Thread overview: 26+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-02-06 21:19 [PATCH 0/7] fstests: enable sparse checking & fix fallout Eric Sandeen 2025-02-06 21:19 ` [PATCH 1/7] fstests: enable sparse checking with make C=[12] Eric Sandeen 2025-02-06 22:36 ` Darrick J. Wong 2025-02-07 4:56 ` Christoph Hellwig 2025-02-06 21:19 ` [PATCH 2/7] builddefs: define linux Eric Sandeen 2025-02-06 22:39 ` Darrick J. Wong 2025-02-07 1:09 ` Eric Sandeen 2025-02-07 2:01 ` Darrick J. Wong 2025-02-07 4:57 ` Christoph Hellwig 2025-02-07 5:06 ` Darrick J. Wong 2025-02-06 21:19 ` [PATCH 3/7] lib: Fix non-ANSI function declarations Eric Sandeen 2025-02-06 22:39 ` Darrick J. Wong 2025-02-07 4:59 ` Christoph Hellwig 2025-02-06 21:19 ` [PATCH 4/7] lib: fix empty arg function prototypes Eric Sandeen 2025-02-06 22:45 ` Darrick J. Wong 2025-02-07 4:59 ` Christoph Hellwig 2025-02-06 21:20 ` [PATCH 5/7] lib: replace aiocb_t with struct aiocb Eric Sandeen 2025-02-06 22:46 ` Darrick J. Wong 2025-02-07 5:00 ` Christoph Hellwig 2025-02-06 21:20 ` [PATCH 6/7] lib: make a few symbols static Eric Sandeen 2025-02-06 22:46 ` Darrick J. Wong 2025-02-07 5:00 ` Christoph Hellwig 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 -- strict thread matches above, loose matches on Subject: below -- 2025-03-10 18:29 [PATCH 0/7 V2] fstests: enable sparse checking & fix fallout Eric Sandeen 2025-03-10 18:29 ` [PATCH 3/7] lib: Fix non-ANSI function declarations Eric Sandeen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox