Here's a patch for memtest that fixes an uninitialized variable bug. It also should now work on 64-bit machines, though I don't have one to try it on.
Other minor changes include compile flags, printing pointers in hex, and getting rid of a couple compiler warnings. --Mike diff -Naur memtest-1.0.1-dist/CREDITS memtest-1.0.1/CREDITS --- memtest-1.0.1-dist/CREDITS Sat May 25 11:52:55 1996 +++ memtest-1.0.1/CREDITS Wed Dec 8 23:10:31 1999 @@ -1,3 +1,8 @@ Written by Adrian Powell ([EMAIL PROTECTED]) Please email me with problems, comments. + + + +(1999-12-08) bug fix and extension to 64-bit + Mike Coleman ([EMAIL PROTECTED]) diff -Naur memtest-1.0.1-dist/Makefile memtest-1.0.1/Makefile --- memtest-1.0.1-dist/Makefile Fri Jul 4 20:13:48 1997 +++ memtest-1.0.1/Makefile Sun Dec 5 17:06:36 1999 @@ -1,5 +1,5 @@ CC = cc -CFLAGS = -v +CFLAGS = -Wall -O -g REMOVE = rm MEMTEST_SRC = memtest.c diff -Naur memtest-1.0.1-dist/memtest.c memtest-1.0.1/memtest.c --- memtest-1.0.1-dist/memtest.c Sun Nov 1 13:48:46 1998 +++ memtest-1.0.1/memtest.c Sun Dec 5 17:28:49 1999 @@ -1,4 +1,5 @@ #include <stdio.h> +#include <stdlib.h> #include <malloc.h> #include <errno.h> @@ -6,37 +7,38 @@ #define PASSES 5 /* Test patterns */ -#define ALL_ONES 037777777777 -#define ALL_ZEROS 0 -#define ONE_ZERO 025252525252 -#define ZERO_ONE 012525252525 +#define ALL_ONES ((int) 0xFFFFFFFFFFFFFFFF) +#define ALL_ZEROS ((int) 0x0000000000000000) +#define ONE_ZERO ((int) 0xAAAAAAAAAAAAAAAA) +#define ZERO_ONE ((int) 0x5555555555555555) /* Increase as new tests are added. */ #define TESTS 8 -main(argc,argv) -int argc; -char *argv[]; -{ +static int check(int *b, int pattern, int pass, int s); + +int main(int argc, char *argv[]) +{ int *a; - int i,j; - int error,pass_error,passes,pass,tpass; - int words,success,size; + int i; + int error,pass_error=0,passes,pass,tpass; + int size; switch (argc) { case 1: size=SIZE; tpass=PASSES; break; case 2: size=atoi(argv[1]); tpass=1; break; default: size=atoi(argv[1]); tpass=atoi(argv[2]); } - printf ("Using a memory size of %d 32 bit words (%d Bytes) and %d passes.\n",size,size*sizeof(int),tpass); + printf ("Using a memory size of %d %d bit words (%d Bytes) and %d passes.\n", + size,8*sizeof(int),size*sizeof(int),tpass); if ((a = (int *)calloc(size, sizeof(int))) == NULL) { printf ("calloc() failed errno %d\n", errno); exit(1); } error=pass=0; - printf (" Array a starts at %d\n",&a[0]); + printf (" Array a starts at %p\n",&a[0]); for (passes=0; passes<tpass; passes++) { /* Write forwards */ @@ -81,12 +83,9 @@ return(0); } -int check(b,pattern,pass,s) -int *b; -long pattern; -int pass,s; +static int check(int *b, int pattern, int pass, int s) { - int z , errors; + int z, errors; /* Put any test corruption here */ @@ -100,10 +99,10 @@ errors=0; for (z=0;z<s;z++) if (b[z]!=pattern) { - printf ("Error at address %d subscript %d, actual %d expected %d\n",&b[z],z,b[z],pattern); + printf ("Error at address %p subscript %d, actual %x expected %x diff %x\n", + &b[z],z,b[z],pattern,b[z]^pattern); errors++; } if (errors) printf ("***^ End of pass %d ^*********\n",pass); return (errors); } -