Checked in the proposed fixes for bug 104645 and bug 105173 on the DBM_1_6_BRANCH
authorwtc%netscape.com
Wed, 17 Oct 2001 17:28:57 +0000
branchDBM_1_6_BRANCH
changeset 2163 c59e23e03218eebe069b13c338fb9b19b16668c4
parent 2155 bac3fb48cf6f5090d2c0860efcb41e97032f9e08
child 2168 b47c2ebf3dd4cd35d8bfe648fa2a449cca98faa5
push idunknown
push userunknown
push dateunknown
bugs104645, 105173
Checked in the proposed fixes for bug 104645 and bug 105173 on the DBM_1_6_BRANCH, ready for testing. Modified files: include/mcom_db.h macbuild/DBMConfig.h src/Makefile.win src/h_page.c src/hash.c tests/lots.c
dbm/include/mcom_db.h
dbm/macbuild/DBMConfig.h
dbm/src/Makefile.win
dbm/src/h_page.c
dbm/src/hash.c
dbm/tests/lots.c
--- a/dbm/include/mcom_db.h
+++ b/dbm/include/mcom_db.h
@@ -69,49 +69,56 @@
  * SUCH DAMAGE.
  *
  *	@(#)db.h	8.7 (Berkeley) 6/16/94
  */
 
 #ifndef _DB_H_
 #define	_DB_H_
 
+#ifndef macintosh
+#include <sys/types.h>
+#endif
+#include "prtypes.h"
+
+#include <limits.h>
+
+#ifdef __DBINTERFACE_PRIVATE
+
 #ifdef HAVE_SYS_CDEFS_H
 #include <sys/cdefs.h>
 #else
 #include "cdefs.h"
 #endif
-#include "prtypes.h"
 
 #ifdef HAVE_SYS_BYTEORDER_H
-#include <sys/types.h>
 #include <sys/byteorder.h>
 #endif
 
 #if defined(__linux) || defined(__BEOS__)
 #include <endian.h>
 #ifndef BYTE_ORDER
 #define BYTE_ORDER    __BYTE_ORDER
 #define BIG_ENDIAN    __BIG_ENDIAN
 #define LITTLE_ENDIAN __LITTLE_ENDIAN
 #endif
 #endif /* __linux */
 
 #ifdef __sgi
 #define BYTE_ORDER BIG_ENDIAN
 #define BIG_ENDIAN      4321
 #define LITTLE_ENDIAN   1234            /* LSB first: i386, vax, all NT risc */
-#define	__BIT_TYPES_DEFINED__
 #endif
 
 #ifdef __sun
 #define BIG_ENDIAN      4321
 #define LITTLE_ENDIAN   1234            /* LSB first: i386, vax, all NT risc */
 
-#ifdef HAVE_COMPAT_H
+#ifndef SVR4
+/* compat.h is only in 4.1.3 machines. - dp */
 #include <compat.h>
 #endif
 
 /* XXX - dp
  * Need to find a general way of defining endian-ness in SunOS 5.3
  * SunOS 5.4 defines _BIG_ENDIAN and _LITTLE_ENDIAN
  * SunOS 5.3 does nothing like this.
  */
@@ -131,48 +138,90 @@
 #define BYTE_ORDER BIG_ENDIAN
 #else
 #define BYTE_ORDER LITTLE_ENDIAN
 #endif
 
 #endif /* !BYTE_ORDER */
 #endif /* __sun */
 
+#if defined(__hpux) || defined(__hppa)
+#define BYTE_ORDER BIG_ENDIAN
+#define BIG_ENDIAN      4321
+#define LITTLE_ENDIAN   1234            /* LSB first: i386, vax, all NT risc */
+#endif
+
+#if defined(AIXV3) || defined(AIX)
+/* BYTE_ORDER, LITTLE_ENDIAN, BIG_ENDIAN are all defined here */
+#include <sys/machine.h>
+#endif
+
+/* Digital Unix */
+#ifdef __osf__
+#include <machine/endian.h>
+#endif
+
+#ifdef __alpha
+#ifndef WIN32
+#else
+/* Alpha NT */
+#define BYTE_ORDER LITTLE_ENDIAN
+#define BIG_ENDIAN      4321
+#define LITTLE_ENDIAN   1234 
+#endif
+#endif
+
 #ifdef NCR
 #include <sys/endian.h>
 #endif
 
 #ifdef __QNX__
 #define LITTLE_ENDIAN	1234
 #define BIG_ENDIAN	4321
 #define BYTE_ORDER	LITTLE_ENDIAN
 #endif
 
-#ifdef SCO
-#include <sys/bitypes.h>
-#define MAXPATHLEN 	1024              
-#endif
-
 #ifdef SNI
 /* #include <sys/hetero.h> */
 #define BYTE_ORDER BIG_ENDIAN
 #define BIG_ENDIAN      4321
 #define LITTLE_ENDIAN   1234
 #endif
 
+#if defined(_WINDOWS) || defined(XP_OS2)
+#ifdef BYTE_ORDER
+#undef BYTE_ORDER
+#endif
+
+#define BYTE_ORDER LITTLE_ENDIAN
+#define LITTLE_ENDIAN   1234            /* LSB first: i386, vax, all NT risc */
+#define BIG_ENDIAN      4321
+#endif
+
+#ifdef macintosh
+#define BIG_ENDIAN 4321
+#define LITTLE_ENDIAN 1234
+#define BYTE_ORDER BIG_ENDIAN
+#endif
+
+#endif  /* __DBINTERFACE_PRIVATE */
+
+#ifdef SCO
+#define MAXPATHLEN 	1024              
+#endif
+
 #ifdef macintosh
 #include <unix.h>
 #else
 #include <fcntl.h>
 #endif
 
 #if defined(_WINDOWS) || defined(XP_OS2)
 #include <stdio.h>
 #include <io.h>
-#include <limits.h>
 
 #ifndef XP_OS2 
 #define MAXPATHLEN 	1024               
 #else
 #include <dirent.h>
 #endif
 
 #define	EFTYPE		EINVAL		/* POSIX 1003.1 format errno. */
@@ -181,89 +230,53 @@
 #define	STDIN_FILENO	0		/* ANSI C #defines */
 #define	STDOUT_FILENO	1
 #define	STDERR_FILENO	2
 #endif
 
 #ifndef O_ACCMODE			/* POSIX 1003.1 access mode mask. */
 #define	O_ACCMODE	(O_RDONLY|O_WRONLY|O_RDWR)
 #endif
-
-#ifdef BYTE_ORDER
-#undef BYTE_ORDER
 #endif
 
-#define BYTE_ORDER LITTLE_ENDIAN
-#define LITTLE_ENDIAN   1234            /* LSB first: i386, vax, all NT risc */
-#define BIG_ENDIAN      4321
-#endif
-
-#if defined(_WINDOWS) && !defined(_WIN32)
-/* 16 bit windows defines */
-#define	MAX_PAGE_NUMBER	0xffffffff	/* >= # of pages in a file */
-#endif
-
-
 #ifdef macintosh
 #include <stdio.h>
 #include "xp_mcom.h"
-#define BIG_ENDIAN 4321
-#define LITTLE_ENDIAN 1234
-#define BYTE_ORDER BIG_ENDIAN
 #define O_ACCMODE       3       /* Mask for file access modes */
 #define EFTYPE 2000
 XP_BEGIN_PROTOS
 int mkstemp(const char *path);
 XP_END_PROTOS
 #endif	/* MACINTOSH */
 
-#if defined(XP_OS2)
-/* #include <xp_mcom.h> */
-/* XP_BEGIN_PROTOS */
-/* int mkstemp(char *path); */
-/* XP_END_PROTOS */
-#endif
-
-#ifndef macintosh
-#include <sys/types.h>
-#endif
-
 #if !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2)
 #include <sys/stat.h>
 #include <errno.h>
 #endif
 
-#ifndef _WINDOWS  /* included above to prevent spurious warnings chouck 12-Sep-95 */
-#include <limits.h>
+/* define EFTYPE since most don't */
+#ifndef EFTYPE
+#define EFTYPE      EINVAL      /* POSIX 1003.1 format errno. */
 #endif
 
 #define	RET_ERROR	-1		/* Return values. */
 #define	RET_SUCCESS	 0
 #define	RET_SPECIAL	 1
 
-#if defined(__386BSD__) || defined(SCO)
-#define	__BIT_TYPES_DEFINED__
-#endif
-
 #define	MAX_PAGE_NUMBER	0xffffffff	/* >= # of pages in a file */
 
 #ifndef __sgi
 typedef uint32	pgno_t;
 #endif
 
 #define	MAX_PAGE_OFFSET	65535		/* >= # of bytes in a page */
 typedef uint16	indx_t;
 #define	MAX_REC_NUMBER	0xffffffff	/* >= # of records in a tree */
 typedef uint32	recno_t;
 
-/* define EFTYPE since most don't */
-#ifndef EFTYPE
-#define EFTYPE      EINVAL      /* POSIX 1003.1 format errno. */
-#endif
-
 /* Key/data structure -- a Data-Base Thang. */
 typedef struct {
 	void	*data;			/* data */
 	size_t	 size;			/* data length */
 } DBT;
 
 /* Routine flags. */
 #define	R_CURSOR	1		/* del, put, seq */
@@ -359,17 +372,17 @@ typedef struct {
 	uint	cachesize;	/* bytes to cache */
 	uint	psize;		/* page size */
 	int	lorder;		/* byte order */
 	size_t	reclen;		/* record length (fixed-length records) */
 	uint8	bval;		/* delimiting byte (variable-length records */
 	char	*bfname;	/* btree file name */ 
 } RECNOINFO;
 
-/* #ifdef __DBINTERFACE_PRIVATE */
+#ifdef __DBINTERFACE_PRIVATE
 /*
  * Little endian <==> big endian 32-bit swap macros.
  *	M_32_SWAP	swap a memory location
  *	P_32_SWAP	swap a referenced memory location
  *	P_32_COPY	swap from one location to another
  */
 #define	M_32_SWAP(a) {							\
 	uint32 _tmp = a;						\
@@ -407,59 +420,33 @@ typedef struct {
 	uint16 _tmp = *(uint16 *)a;				\
 	((char *)a)[0] = ((char *)&_tmp)[1];				\
 	((char *)a)[1] = ((char *)&_tmp)[0];				\
 }
 #define	P_16_COPY(a, b) {						\
 	((char *)&(b))[0] = ((char *)&(a))[1];				\
 	((char *)&(b))[1] = ((char *)&(a))[0];				\
 }
-/* #endif */
+#endif
 
-__BEGIN_DECLS
+PR_BEGIN_EXTERN_C
 #if defined(__WATCOMC__) || defined(__WATCOM_CPLUSPLUS__)
 extern DB *
 #else
 PR_EXTERN(DB *)
 #endif
 dbopen (const char *, int, int, DBTYPE, const void *);
 
 /* set or unset a global lock flag to disable the
  * opening of any DBM file
  */
 void dbSetOrClearDBLock(DBLockFlagEnum type);
 
-/* #ifdef __DBINTERFACE_PRIVATE */
+#ifdef __DBINTERFACE_PRIVATE
 DB	*__bt_open (const char *, int, int, const BTREEINFO *, int);
 DB	*__hash_open (const char *, int, int, const HASHINFO *, int);
 DB	*__rec_open (const char *, int, int, const RECNOINFO *, int);
 void	 __dbpanic (DB *dbp);
-/* #endif */
-
-__END_DECLS
-
-#if defined(__hpux) || defined(__hppa)
-#define BYTE_ORDER BIG_ENDIAN
-#define BIG_ENDIAN      4321
-#define LITTLE_ENDIAN   1234            /* LSB first: i386, vax, all NT risc */
-#endif
-
-#if defined(AIXV3) || defined(AIX)
-/* BYTE_ORDER, LITTLE_ENDIAN, BIG_ENDIAN are all defined here */
-#include <sys/machine.h>
 #endif
 
-/* Digital Unix */
-#ifdef __osf__
-#include <machine/endian.h>
-#endif
-
-#ifdef __alpha
-#ifndef WIN32
-#else
-/* Alpha NT */
-#define BYTE_ORDER LITTLE_ENDIAN
-#define BIG_ENDIAN      4321
-#define LITTLE_ENDIAN   1234 
-#endif
-#endif
+PR_END_EXTERN_C
 
 #endif /* !_DB_H_ */
--- a/dbm/macbuild/DBMConfig.h
+++ b/dbm/macbuild/DBMConfig.h
@@ -15,9 +15,9 @@
  * The Initial Developer of the Original Code is Netscape
  * Communications Corporation.  Portions created by Netscape are
  * Copyright (C) 1998 Netscape Communications Corporation. All
  * Rights Reserved.
  *
  * Contributor(s): 
  */
 
-/* Nothing to do here. If you need DBM-specific defines, put them here */
+#define __DBINTERFACE_PRIVATE 1
--- a/dbm/src/Makefile.win
+++ b/dbm/src/Makefile.win
@@ -83,14 +83,14 @@ LINCS = -I..\include
 
 #//------------------------------------------------------------------------
 #//
 #// Include the common makefile rules
 #//
 #//------------------------------------------------------------------------
 include <$(DEPTH)/config/rules.mak>
 
-CFLAGS = $(CFLAGS) -DMOZILLA_CLIENT
+CFLAGS = $(CFLAGS) -DMOZILLA_CLIENT -D__DBINTERFACE_PRIVATE
 
 install:: $(LIBRARY)
     $(MAKE_INSTALL) $(LIBRARY) $(DIST)\lib
 
 
--- a/dbm/src/h_page.c
+++ b/dbm/src/h_page.c
@@ -287,18 +287,17 @@ extern int
 {
 	register BUFHEAD *new_bufp, *old_bufp;
 	register uint16 *ino;
 	register uint16 *tmp_uint16_array;
 	register char *np;
 	DBT key, val;
     uint16 n, ndx;
 	int retval;
-	uint16 copyto, diff, moved;
-	size_t off;
+	uint16 copyto, diff, off, moved;
 	char *op;
 
 	copyto = (uint16)hashp->BSIZE;
 	off = (uint16)hashp->BSIZE;
 	old_bufp = __get_buf(hashp, obucket, NULL, 0);
 	if (old_bufp == NULL)
 		return (-1);
 	new_bufp = __get_buf(hashp, nbucket, NULL, 0);
@@ -339,17 +338,17 @@ extern int
 #endif
 
 		if (__call_hash(hashp, (char *)key.data, key.size) == obucket) {
 			/* Don't switch page */
 			diff = copyto - off;
 			if (diff) {
 				copyto = ino[n + 1] + diff;
 				memmove(op + copyto, op + ino[n + 1],
-				    off - ino[n + 1]);
+				    (size_t)(off - ino[n + 1]));
 				ino[ndx] = copyto + ino[n] - ino[n + 1];
 				ino[ndx + 1] = copyto;
 			} else
 				copyto = ino[n + 1];
 			ndx += 2;
 		} else {
 			/* Switch page */
 			val.data = (uint8 *)op + ino[n + 1];
@@ -687,41 +686,40 @@ extern BUFHEAD *
 extern int
 __get_page(HTAB *hashp,
 	char * p,
 	uint32 bucket, 
 	int is_bucket, 
 	int is_disk, 
 	int is_bitmap)
 {
-	register int fd, page;
-	size_t size;
+	register int fd, page, size;
 	int rsize;
 	uint16 *bp;
 
 	fd = hashp->fp;
 	size = hashp->BSIZE;
 
 	if ((fd == -1) || !is_disk) {
 		PAGE_INIT(p);
 		return (0);
 	}
 	if (is_bucket)
 		page = BUCKET_TO_PAGE(bucket);
 	else
 		page = OADDR_TO_PAGE(bucket);
 	if ((MY_LSEEK(fd, (off_t)page << hashp->BSHIFT, SEEK_SET) == -1) ||
-	    ((rsize = read(fd, p, size)) == -1))
+	    ((rsize = read(fd, p, (size_t)size)) == -1))
 		return (-1);
 
 	bp = (uint16 *)p;
 	if (!rsize)
 		bp[0] = 0;	/* We hit the EOF, so initialize a new page */
 	else
-		if ((unsigned)rsize != size) {
+		if (rsize != size) {
 			errno = EFTYPE;
 			return (-1);
 		}
 
 	if (!is_bitmap && !bp[0]) {
 		PAGE_INIT(p);
 	} else {
 
@@ -752,17 +750,17 @@ extern int
 			} else {
 				M_16_SWAP(bp[0]);
 				max = bp[0] + 2;
 
 	    		/* bound the size of max by
 	     		 * the maximum number of entries
 	     		 * in the array
 	     		 */
-				if((unsigned)max > (size / sizeof(uint16)))
+				if(max > (size / (int)sizeof(uint16)))
 					return(DATABASE_CORRUPTED_ERROR);
 
 				/* do the byte order swap
 				 */
 				for (i = 1; i <= max; i++)
 					M_16_SWAP(bp[i]);
 			}
 		}
@@ -823,18 +821,17 @@ extern int
  *
  * Returns:
  *	 0 ==> OK
  *	-1 ==>failure
  */
 extern int
 __put_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_bitmap)
 {
-	register int fd, page;
-	size_t size;
+	register int fd, page, size;
 	int wsize;
 	off_t offset;
 
 	size = hashp->BSIZE;
 	if ((hashp->fp == -1) && open_temp(hashp))
 		return (-1);
 	fd = hashp->fp;
 
@@ -848,35 +845,35 @@ extern int
 				M_32_SWAP(((int *)p)[i]);
 		} else {
 			max = ((uint16 *)p)[0] + 2;
 
             /* bound the size of max by
              * the maximum number of entries
              * in the array
              */
-            if((unsigned)max > (size / sizeof(uint16)))
+            if(max > (size / (int)sizeof(uint16)))
                 return(DATABASE_CORRUPTED_ERROR);
 
 			for (i = 0; i <= max; i++)
 				M_16_SWAP(((uint16 *)p)[i]);
 
 		}
 	}
 
 	if (is_bucket)
 		page = BUCKET_TO_PAGE(bucket);
 	else
 		page = OADDR_TO_PAGE(bucket);
 	offset = (off_t)page << hashp->BSHIFT;
 	if ((MY_LSEEK(fd, offset, SEEK_SET) == -1) ||
-	    ((wsize = write(fd, p, size)) == -1))
+	    ((wsize = write(fd, p, (size_t)size)) == -1))
 		/* Errno is set */
 		return (-1);
-	if ((unsigned)wsize != size) {
+	if (wsize != size) {
 		errno = EFTYPE;
 		return (-1);
 	}
 #if defined(_WIN32) || defined(_WINDOWS) 
 	if (offset + size > hashp->file_size) {
 		hashp->updateEOF = 1;
 	}
 #endif
@@ -952,39 +949,39 @@ first_free(uint32 map)
 }
 
 static uint16
 overflow_page(HTAB *hashp)
 {
 	register uint32 *freep=NULL;
 	register int max_free, offset, splitnum;
 	uint16 addr;
-	uint32 i;
+	int i;
 	int bit, first_page, free_bit, free_page, in_use_bits, j;
 #ifdef DEBUG2
 	int tmp1, tmp2;
 #endif
 	splitnum = hashp->OVFL_POINT;
 	max_free = hashp->SPARES[splitnum];
 
 	free_page = (max_free - 1) >> (hashp->BSHIFT + BYTE_SHIFT);
 	free_bit = (max_free - 1) & ((hashp->BSIZE << BYTE_SHIFT) - 1);
 
 	/* Look through all the free maps to find the first free block */
 	first_page = hashp->LAST_FREED >>(hashp->BSHIFT + BYTE_SHIFT);
-	for ( i = first_page; i <= (unsigned)free_page; i++ ) {
+	for ( i = first_page; i <= free_page; i++ ) {
 		if (!(freep = (uint32 *)hashp->mapp[i]) &&
-		    !(freep = fetch_bitmap(hashp, i)))
+		    !(freep = fetch_bitmap(hashp, (uint32)i)))
 			return (0);
-		if (i == (unsigned)free_page)
+		if (i == free_page)
 			in_use_bits = free_bit;
 		else
 			in_use_bits = (hashp->BSIZE << BYTE_SHIFT) - 1;
 		
-		if (i == (unsigned)first_page) {
+		if (i == first_page) {
 			bit = hashp->LAST_FREED &
 			    ((hashp->BSIZE << BYTE_SHIFT) - 1);
 			j = bit / BITS_PER_MAP;
 			bit = bit & ~(BITS_PER_MAP - 1);
 		} else {
 			bit = 0;
 			j = 0;
 		}
@@ -1083,17 +1080,17 @@ found:
 	 * beginning at 1. Bit is a bit addressnumber, so we need to increment
 	 * it to convert it to a page number.
 	 */
 	bit = 1 + bit + (i * (hashp->BSIZE << BYTE_SHIFT));
 	if (bit >= hashp->LAST_FREED)
 		hashp->LAST_FREED = bit - 1;
 
 	/* Calculate the split number for this page */
-	for (i = 0; (i < (unsigned)splitnum) && (bit > hashp->SPARES[i]); i++) {}
+	for (i = 0; (i < splitnum) && (bit > hashp->SPARES[i]); i++) {}
 	offset = (i ? bit - hashp->SPARES[i - 1] : bit);
 	if (offset >= SPLITMASK)
 		return (0);	/* Out of overflow pages */
 	addr = OADDR_OF(i, offset);
 #ifdef DEBUG2
 	(void)fprintf(stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n",
 	    addr, tmp1, tmp2);
 #endif
@@ -1118,17 +1115,17 @@ extern void
 
 	addr = obufp->addr;
 #ifdef DEBUG1
 	(void)fprintf(stderr, "Freeing %d\n", addr);
 #endif
 	ndx = (((uint16)addr) >> SPLITSHIFT);
 	bit_address =
 	    (ndx ? hashp->SPARES[ndx - 1] : 0) + (addr & SPLITMASK) - 1;
-	 if (bit_address < (unsigned)hashp->LAST_FREED)
+	if (bit_address < (uint32)hashp->LAST_FREED)
 		hashp->LAST_FREED = bit_address;
 	free_page = (bit_address >> (hashp->BSHIFT + BYTE_SHIFT));
 	free_bit = bit_address & ((hashp->BSIZE << BYTE_SHIFT) - 1);
 
 	if (!(freep = hashp->mapp[free_page])) 
 		freep = fetch_bitmap(hashp, free_page);
 
 #ifdef DEBUG
--- a/dbm/src/hash.c
+++ b/dbm/src/hash.c
@@ -863,17 +863,17 @@ hash_access(
 
 	/* Pin the bucket chain */
 	rbufp->flags |= BUF_PIN;
 	for (bp = (uint16 *)rbufp->page, n = *bp++, ndx = 1; ndx < n;)
 	{
 
 		if (bp[1] >= REAL_KEY) {
 			/* Real key/data pair */
-			if (size == (unsigned)(off - *bp) &&
+			if (size == (size_t)(off - *bp) &&
 			    memcmp(kp, rbufp->page + *bp, size) == 0)
 				goto found;
 			off = bp[1];
 #ifdef HASH_STATISTICS
 			hash_collisions++;
 #endif
 			bp += 2;
 			ndx += 2;
@@ -1007,17 +1007,17 @@ hash_seq(
 		hashp->cbucket = 0;
 		hashp->cndx = 1;
 		hashp->cpage = NULL;
 	}
 
 	for (bp = NULL; !bp || !bp[0]; ) {
 		if (!(bufp = hashp->cpage)) {
 			for (bucket = hashp->cbucket;
-			    bucket <= (unsigned)hashp->MAX_BUCKET;
+			    bucket <= (uint32)hashp->MAX_BUCKET;
 			    bucket++, hashp->cndx = 1) {
 				bufp = __get_buf(hashp, bucket, NULL, 0);
 				if (!bufp)
 					return (DBM_ERROR);
 				hashp->cpage = bufp;
 				bp = (uint16 *)bufp->page;
 				if (bp[0])
 					break;
@@ -1111,17 +1111,17 @@ extern int
 	 * split bucket to the next bucket.
 	 */
 	spare_ndx = __log2((uint32)(hashp->MAX_BUCKET + 1));
 	if (spare_ndx > hashp->OVFL_POINT) {
 		hashp->SPARES[spare_ndx] = hashp->SPARES[hashp->OVFL_POINT];
 		hashp->OVFL_POINT = spare_ndx;
 	}
 
-	if (new_bucket > (unsigned)hashp->HIGH_MASK) {
+	if (new_bucket > (uint32)hashp->HIGH_MASK) {
 		/* Starting a new doubling */
 		hashp->LOW_MASK = hashp->HIGH_MASK;
 		hashp->HIGH_MASK = new_bucket | hashp->LOW_MASK;
 	}
 	/* Relocate records to the new bucket */
 	return (__split_page(hashp, old_bucket, new_bucket));
 }
 
@@ -1147,17 +1147,17 @@ hash_realloc(
 
 extern uint32
 __call_hash(HTAB *hashp, char *k, size_t len)
 {
 	uint32 n, bucket;
 
 	n = hashp->hash(k, len);
 	bucket = n & hashp->HIGH_MASK;
-	if (bucket > (unsigned)hashp->MAX_BUCKET)
+	if (bucket > (uint32)hashp->MAX_BUCKET)
 		bucket = bucket & hashp->LOW_MASK;
 	return (bucket);
 }
 
 /*
  * Allocate segment table.  On error, destroy the table and set errno.
  *
  * Returns 0 on success
--- a/dbm/tests/lots.c
+++ b/dbm/tests/lots.c
@@ -134,34 +134,34 @@ ReportError(char *string, ...)
 }
 
 DBT * MakeLargeKey(int32 num)
 {
 	int32 low_bits;
 	static DBT rv;
 	static char *string_rv=0;
 	int rep_char;
-	int32 size;
+	size_t size;
 
 	if(string_rv)
 		free(string_rv);
 
 	/* generate a really large text key derived from
 	 * an int32
 	 */
 	low_bits = (num % 10000) + 1;
 
 	/* get the repeat char from the low 26 */
 	rep_char = (char) ((low_bits % 26) + 'a');
 
 	/* malloc a string low_bits wide */
 	size = low_bits*sizeof(char);
-	string_rv = (char *)malloc((size_t)size);
+	string_rv = (char *)malloc(size);
 
-	memset(string_rv, rep_char, (size_t)size);
+	memset(string_rv, rep_char, size);
 
 	rv.data = string_rv;
 	rv.size = size;
 
 	return(&rv);
 }
 
 DBT * MakeSmallKey(int32 num)
@@ -218,17 +218,17 @@ SeqDatabase()
 
 	return(status);
 }
 
 int 
 VerifyData(DBT *data, int32 num, key_type_enum key_type)
 {
 	int32 count, compare_num;
-	uint32 size;
+	size_t size;
 	int32 *int32_array;
 
 	/* The first int32 is count 
 	 * The other n entries should
 	 * all equal num
 	 */
 	if(data->size < sizeof(int32))
 	  {
@@ -322,17 +322,17 @@ VerifyRange(int32 low, int32 high, int32
 }
 
 DBT *
 GenData(int32 num)
 {
 	int32 n;
 	static DBT *data=0;
 	int32 *int32_array;
-	int32 size;
+	size_t size;
 
 	if(!data)
 	  {
 		data = (DBT*)malloc(sizeof(DBT));
 		data->size = 0;
 		data->data = 0;
 	  }
 	else if(data->data)
@@ -341,17 +341,17 @@ GenData(int32 num)
 	  }
 
 	n = rand();
 
 	n = n % 512;  /* bound to a 2K size */
 
 	
 	size = sizeof(int32)*(n+1);
-	int32_array = (int32 *) malloc((size_t)size);
+	int32_array = (int32 *) malloc(size);
 
 	memcpy(&int32_array[0], &n, sizeof(int32));
 
 	for(; n > 0; n--)
 	  {
 		memcpy(&int32_array[n], &num, sizeof(int32));
 	  }