From 0fd8da731a3ed7f6d21c416816e0a30822556bf0 Mon Sep 17 00:00:00 2001 From: Mark Borgerding Date: Thu, 26 Feb 2004 03:43:23 +0000 Subject: [PATCH] compiles clean with lots of -W switches --- test/Makefile | 8 +++++++- test/pstats.c | 9 ++++++--- test/pstats.h | 4 ++-- test/selftest.c | 9 ++++++--- test/selftest_short.c | 4 +++- test/test_real.c | 21 +++++++++++---------- 6 files changed, 35 insertions(+), 20 deletions(-) diff --git a/test/Makefile b/test/Makefile index 512702f..cf979e9 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,3 +1,9 @@ + +WARNINGS=-W -Wall -Wstrict-prototypes -Wmissing-prototypes -Waggregate-return \ + -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wbad-function-cast \ + -Wwrite-strings + + ifeq "$(NFFT)" "" NFFT=1800 endif @@ -42,7 +48,7 @@ tools: # for x86 pentium+ machines , these flags work well #CFLAGS=-Wall -O3 -pedantic -march=pentiumpro -ffast-math -fomit-frame-pointer -I.. -I../tools # If the above flags do not work, try the following -CFLAGS=-Wall -O3 -I.. -I../tools +CFLAGS=-Wall -O3 -I.. -I../tools $(WARNINGS) $(SELFTEST): $(SELFTESTSRC) $(SRCFILES) $(CC) -o $@ $(CFLAGS) $(TYPEFLAGS) -lm $+ diff --git a/test/pstats.c b/test/pstats.c index d37f26a..bb2244e 100644 --- a/test/pstats.c +++ b/test/pstats.c @@ -4,16 +4,19 @@ #include #include +#include "pstats.h" + static struct tms tms_beg; static struct tms tms_end; static int has_times = 0; -void pstats_init() + +void pstats_init(void) { has_times = times(&tms_beg) != -1; } -static void tms_report() +static void tms_report(void) { double cputime; if (! has_times ) @@ -25,7 +28,7 @@ static void tms_report() fprintf(stderr,"\tcputime=%.3f\n" , cputime); } -static void ps_report() +static void ps_report(void) { char buf[1024]; #ifdef __APPLE__ /* MAC OS X */ diff --git a/test/pstats.h b/test/pstats.h index 0a09bfd..71ff02a 100644 --- a/test/pstats.h +++ b/test/pstats.h @@ -1,7 +1,7 @@ #ifndef PSTATS_H #define PSTATS_H -void pstats_init(); -void pstats_report(); +void pstats_init(void); +void pstats_report(void); #endif diff --git a/test/selftest.c b/test/selftest.c index 6427811..b5ca04b 100644 --- a/test/selftest.c +++ b/test/selftest.c @@ -4,6 +4,7 @@ #define xstr(s) str(s) #define str(s) #s +static double snr_compare( kiss_fft_cpx * test_vec_out,kiss_fft_cpx * testbuf, int n) { int k; @@ -28,10 +29,11 @@ double snr_compare( kiss_fft_cpx * test_vec_out,kiss_fft_cpx * testbuf, int n) return snr; } -int test_stride(); -int test2d(); +int test_stride(void ); +int test2d(void ); -int main() { int exit_code=0; +int main(void) { + int exit_code=0; #define NFFT 10 { @@ -143,6 +145,7 @@ int main() { int exit_code=0; return exit_code; } + int test_stride() { #define SKIP_FACTOR 7 diff --git a/test/selftest_short.c b/test/selftest_short.c index 94d8bf0..17fc17f 100644 --- a/test/selftest_short.c +++ b/test/selftest_short.c @@ -2,6 +2,8 @@ #define xstr(s) str(s) #define str(s) #s + +static double snr_compare( kiss_fft_cpx * test_vec_out,kiss_fft_cpx * testbuf, int n) { int k; @@ -26,7 +28,7 @@ double snr_compare( kiss_fft_cpx * test_vec_out,kiss_fft_cpx * testbuf, int n) return snr; } -int main() { int exit_code=0; +int main(void) { int exit_code=0; #define NFFT 10 { diff --git a/test/test_real.c b/test/test_real.c index 77933a9..6eadcde 100644 --- a/test/test_real.c +++ b/test/test_real.c @@ -4,13 +4,14 @@ #include #include -static double cputime() +static double cputime(void) { struct tms t; times(&t); return (double)(t.tms_utime + t.tms_stime)/ sysconf(_SC_CLK_TCK) ; } +static double snr_compare( kiss_fft_cpx * vec1,kiss_fft_cpx * vec2, int n) { int k; @@ -52,12 +53,12 @@ double snr_compare( kiss_fft_cpx * vec1,kiss_fft_cpx * vec2, int n) #endif -int main() +int main(void) { double ts,tfft,trfft; int i; kiss_fft_cpx cin[NFFT]; - kiss_fft_scalar sin[NFFT] = {0.309655,0.815653,0.768570,0.591841,0.404767,0.637617,0.007803,0.012665}; + kiss_fft_scalar rin[NFFT] = {0.309655,0.815653,0.768570,0.591841,0.404767,0.637617,0.007803,0.012665}; kiss_fft_cpx cout[NFFT]; kiss_fft_cpx sout[NFFT]; @@ -68,16 +69,16 @@ int main() for (i=0;i