summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormcafee%netscape.com <devnull@localhost>1999-07-15 00:17:20 +0000
committermcafee%netscape.com <devnull@localhost>1999-07-15 00:17:20 +0000
commitb4185ed473620758ecfb6e0139216a48948494a5 (patch)
tree2b3aea51adcc5ff0da731fe90ede36756e769840
parente0b98c1e483ec6210697ecad609959e2a6e5c7b3 (diff)
downloadnss-hg-b4185ed473620758ecfb6e0139216a48948494a5.tar.gz
Fixing warning errors (9245)
-rw-r--r--dbm/include/extern.h4
-rw-r--r--dbm/include/hash.h6
-rw-r--r--dbm/src/h_bigkey.c10
-rw-r--r--dbm/src/h_page.c21
-rw-r--r--dbm/src/hash.c30
-rw-r--r--dbm/src/hash_buf.c4
-rw-r--r--dbm/src/nsres.c2
-rw-r--r--dbm/tests/lots.c8
8 files changed, 45 insertions, 40 deletions
diff --git a/dbm/include/extern.h b/dbm/include/extern.h
index cfb20b940..8eabc81fe 100644
--- a/dbm/include/extern.h
+++ b/dbm/include/extern.h
@@ -40,10 +40,10 @@ int __big_insert (HTAB *, BUFHEAD *, const DBT *, const DBT *);
int __big_keydata (HTAB *, BUFHEAD *, DBT *, DBT *, int);
int __big_return (HTAB *, BUFHEAD *, int, DBT *, int);
int __big_split (HTAB *, BUFHEAD *, BUFHEAD *, BUFHEAD *,
- int, uint32, SPLIT_RETURN *);
+ uint32, uint32, SPLIT_RETURN *);
int __buf_free (HTAB *, int, int);
void __buf_init (HTAB *, int);
-uint32 __call_hash (HTAB *, char *, int);
+uint32 __call_hash (HTAB *, char *, size_t);
int __delpair (HTAB *, BUFHEAD *, int);
int __expand_table (HTAB *);
int __find_bigpair (HTAB *, BUFHEAD *, int, char *, int);
diff --git a/dbm/include/hash.h b/dbm/include/hash.h
index b898fe048..70f93e938 100644
--- a/dbm/include/hash.h
+++ b/dbm/include/hash.h
@@ -183,7 +183,7 @@ typedef struct htab { /* Memory resident data structure */
#define OADDR_OF(S,O) ((uint32)((uint32)(S) << SPLITSHIFT) + (O))
#define BUCKET_TO_PAGE(B) \
- (B) + hashp->HDRPAGES + ((B) ? hashp->SPARES[__log2((B)+1)-1] : 0)
+ (B) + hashp->HDRPAGES + ((B) ? hashp->SPARES[__log2((uint32)((B)+1))-1] : 0)
#define OADDR_TO_PAGE(B) \
BUCKET_TO_PAGE ( (1 << SPLITNUM((B))) -1 ) + OPAGENUM((B));
@@ -311,10 +311,10 @@ extern uint32 (*__default_hash) (const void *, size_t);
void __buf_init(HTAB *hashp, int32 nbytes);
int __big_delete(HTAB *hashp, BUFHEAD *bufp);
BUFHEAD * __get_buf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp, int newpage);
-uint32 __call_hash(HTAB *hashp, char *k, int len);
+uint32 __call_hash(HTAB *hashp, char *k, size_t len);
#include "page.h"
extern int __big_split(HTAB *hashp, BUFHEAD *op,BUFHEAD *np,
-BUFHEAD *big_keyp,int addr,uint32 obucket, SPLIT_RETURN *ret);
+BUFHEAD *big_keyp,uint32 addr,uint32 obucket, SPLIT_RETURN *ret);
void __free_ovflpage(HTAB *hashp, BUFHEAD *obufp);
BUFHEAD * __add_ovflpage(HTAB *hashp, BUFHEAD *bufp);
int __big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val);
diff --git a/dbm/src/h_bigkey.c b/dbm/src/h_bigkey.c
index b482f440c..07c2f98ed 100644
--- a/dbm/src/h_bigkey.c
+++ b/dbm/src/h_bigkey.c
@@ -472,7 +472,7 @@ collect_data(
totlen = len + mylen;
if (hashp->tmp_buf)
free(hashp->tmp_buf);
- if ((hashp->tmp_buf = (char *)malloc(totlen)) == NULL)
+ if ((hashp->tmp_buf = (char *)malloc((size_t)totlen)) == NULL)
return (-1);
if (set) {
hashp->cndx = 1;
@@ -500,7 +500,7 @@ collect_data(
errno = EINVAL; /* Out of buffers. */
return (-1);
}
- memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], mylen);
+ memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], (size_t)mylen);
return (totlen);
}
@@ -547,7 +547,7 @@ collect_key(
if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) { /* End of Key. */
if (hashp->tmp_key != NULL)
free(hashp->tmp_key);
- if ((hashp->tmp_key = (char *)malloc(totlen)) == NULL)
+ if ((hashp->tmp_key = (char *)malloc((size_t)totlen)) == NULL)
return (-1);
if (__big_return(hashp, bufp, 1, val, set))
return (-1);
@@ -561,7 +561,7 @@ collect_key(
errno = EINVAL; /* MIS -- OUT OF BUFFERS */
return (-1);
}
- memmove(&hashp->tmp_key[len], (bufp->page) + bp[1], mylen);
+ memmove(&hashp->tmp_key[len], (bufp->page) + bp[1], (size_t)mylen);
return (totlen);
}
@@ -577,7 +577,7 @@ __big_split(
BUFHEAD *np, /* Pointer to new bucket page */
/* Pointer to first page containing the big key/data */
BUFHEAD *big_keyp,
- int addr, /* Address of big_keyp */
+ uint32 addr, /* Address of big_keyp */
uint32 obucket,/* Old Bucket */
SPLIT_RETURN *ret)
{
diff --git a/dbm/src/h_page.c b/dbm/src/h_page.c
index fbbf6d88d..e9b33f26c 100644
--- a/dbm/src/h_page.c
+++ b/dbm/src/h_page.c
@@ -159,7 +159,7 @@ long new_lseek(int fd, long offset, int origin)
memset(&buffer, 0, 1024);
while(len > 0)
{
- write(fd, (char*)&buffer, (1024 > len ? len : 1024));
+ write(fd, (char*)&buffer, (size_t)(1024 > len ? len : 1024));
len -= 1024;
}
return(lseek(fd, seek_pos, SEEK_SET));
@@ -285,7 +285,8 @@ __split_page(HTAB *hashp, uint32 obucket, uint32 nbucket)
DBT key, val;
uint16 n, ndx;
int retval;
- uint16 copyto, diff, off, moved;
+ uint16 copyto, diff, moved;
+ size_t off;
char *op;
copyto = (uint16)hashp->BSIZE;
@@ -684,8 +685,9 @@ __get_page(HTAB *hashp,
int is_disk,
int is_bitmap)
{
- register int fd, page, size;
- int rsize;
+ register int fd, page;
+ size_t size;
+ ssize_t rsize;
uint16 *bp;
fd = hashp->fp;
@@ -819,8 +821,9 @@ __get_page(HTAB *hashp,
extern int
__put_page(HTAB *hashp, char *p, uint32 bucket, int is_bucket, int is_bitmap)
{
- register int fd, page, size;
- int wsize;
+ register int fd, page;
+ size_t size;
+ ssize_t wsize;
size = hashp->BSIZE;
if ((hashp->fp == -1) && open_temp(hashp))
@@ -904,9 +907,9 @@ extern int
__ibitmap(HTAB *hashp, int pnum, int nbits, int ndx)
{
uint32 *ip;
- int clearbytes, clearints;
+ size_t clearbytes, clearints;
- if ((ip = (uint32 *)malloc(hashp->BSIZE)) == NULL)
+ if ((ip = (uint32 *)malloc((size_t)hashp->BSIZE)) == NULL)
return (1);
hashp->nmaps++;
clearints = ((nbits - 1) >> INT_BYTE_SHIFT) + 1;
@@ -1201,7 +1204,7 @@ fetch_bitmap(HTAB *hashp, uint32 ndx)
{
if (ndx >= hashp->nmaps)
return (NULL);
- if ((hashp->mapp[ndx] = (uint32 *)malloc(hashp->BSIZE)) == NULL)
+ if ((hashp->mapp[ndx] = (uint32 *)malloc((size_t)hashp->BSIZE)) == NULL)
return (NULL);
if (__get_page(hashp,
(char *)hashp->mapp[ndx], hashp->BITMAPS[ndx], 0, 1, 1)) {
diff --git a/dbm/src/hash.c b/dbm/src/hash.c
index b6b7d70ee..267ac0618 100644
--- a/dbm/src/hash.c
+++ b/dbm/src/hash.c
@@ -81,7 +81,7 @@ static int hash_delete __P((const DB *, const DBT *, uint));
static int hash_fd __P((const DB *));
static int hash_get __P((const DB *, const DBT *, DBT *, uint));
static int hash_put __P((const DB *, DBT *, const DBT *, uint));
-static void *hash_realloc __P((SEGMENT **, int, int));
+static void *hash_realloc __P((SEGMENT **, size_t, size_t));
static int hash_seq __P((const DB *, DBT *, DBT *, uint));
static int hash_sync __P((const DB *, uint));
static int hdestroy __P((HTAB *));
@@ -424,7 +424,7 @@ init_hash(HTAB *hashp, const char *file, HASHINFO *info)
if (hashp->BSIZE > MAX_BSIZE)
hashp->BSIZE = MAX_BSIZE;
#endif
- hashp->BSHIFT = __log2(hashp->BSIZE);
+ hashp->BSHIFT = __log2((uint32)hashp->BSIZE);
}
if (info) {
@@ -477,7 +477,7 @@ init_htab(HTAB *hashp, int nelem)
*/
nelem = (nelem - 1) / hashp->FFACTOR + 1;
- l2 = __log2(MAX(nelem, 2));
+ l2 = __log2((uint32)MAX(nelem, 2));
nbuckets = 1 << l2;
hashp->SPARES[l2] = l2 + 1;
@@ -486,7 +486,7 @@ init_htab(HTAB *hashp, int nelem)
hashp->LAST_FREED = 2;
/* First bitmap page is at: splitpoint l2 page offset 1 */
- if (__ibitmap(hashp, OADDR_OF(l2, 1), l2 + 1, 0))
+ if (__ibitmap(hashp, (int)OADDR_OF(l2, 1), l2 + 1, 0))
return (-1);
hashp->MAX_BUCKET = hashp->LOW_MASK = nbuckets - 1;
@@ -495,7 +495,7 @@ init_htab(HTAB *hashp, int nelem)
hashp->BSHIFT) + 1;
nsegs = (nbuckets - 1) / hashp->SGSIZE + 1;
- nsegs = 1 << __log2(nsegs);
+ nsegs = 1 << __log2((uint32)nsegs);
if (nsegs > hashp->DSIZE)
hashp->DSIZE = nsegs;
@@ -763,7 +763,8 @@ hash_access(
register BUFHEAD *rbufp;
BUFHEAD *bufp, *save_bufp;
register uint16 *bp;
- register long n, ndx, off, size;
+ register long n, ndx, off;
+ register size_t size;
register char *kp;
uint16 pageno;
uint32 ovfl_loop_count=0;
@@ -822,7 +823,7 @@ hash_access(
off = hashp->BSIZE;
} else if (bp[1] < REAL_KEY) {
if ((ndx =
- __find_bigpair(hashp, rbufp, ndx, kp, size)) > 0)
+ __find_bigpair(hashp, rbufp, ndx, kp, (int)size)) > 0)
goto found;
if (ndx == -2) {
bufp = rbufp;
@@ -998,7 +999,8 @@ extern int
__expand_table(HTAB *hashp)
{
uint32 old_bucket, new_bucket;
- int dirsize, new_segnum, spare_ndx;
+ int new_segnum, spare_ndx;
+ size_t dirsize;
#ifdef HASH_STATISTICS
hash_expansions++;
@@ -1019,7 +1021,7 @@ __expand_table(HTAB *hashp)
hashp->DSIZE = dirsize << 1;
}
if ((hashp->dir[new_segnum] =
- (SEGMENT)calloc(hashp->SGSIZE, sizeof(SEGMENT))) == NULL)
+ (SEGMENT)calloc((size_t)hashp->SGSIZE, sizeof(SEGMENT))) == NULL)
return (-1);
hashp->exsegs++;
hashp->nsegs++;
@@ -1029,7 +1031,7 @@ __expand_table(HTAB *hashp)
* * increases), we need to copy the current contents of the spare
* split bucket to the next bucket.
*/
- spare_ndx = __log2(hashp->MAX_BUCKET + 1);
+ 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;
@@ -1051,7 +1053,7 @@ __expand_table(HTAB *hashp)
static void *
hash_realloc(
SEGMENT **p_ptr,
- int oldsize, int newsize)
+ size_t oldsize, size_t newsize)
{
register void *p;
@@ -1065,7 +1067,7 @@ hash_realloc(
}
extern uint32
-__call_hash(HTAB *hashp, char *k, int len)
+__call_hash(HTAB *hashp, char *k, size_t len)
{
uint32 n, bucket;
@@ -1092,7 +1094,7 @@ alloc_segs(
int save_errno;
if ((hashp->dir =
- (SEGMENT *)calloc(hashp->DSIZE, sizeof(SEGMENT *))) == NULL) {
+ (SEGMENT *)calloc((size_t)hashp->DSIZE, sizeof(SEGMENT *))) == NULL) {
save_errno = errno;
(void)hdestroy(hashp);
errno = save_errno;
@@ -1100,7 +1102,7 @@ alloc_segs(
}
/* Allocate segments */
if ((store =
- (SEGMENT)calloc(nsegs << hashp->SSHIFT, sizeof(SEGMENT))) == NULL) {
+ (SEGMENT)calloc((size_t)nsegs << hashp->SSHIFT, sizeof(SEGMENT))) == NULL) {
save_errno = errno;
(void)hdestroy(hashp);
errno = save_errno;
diff --git a/dbm/src/hash_buf.c b/dbm/src/hash_buf.c
index f30bee32e..35968601b 100644
--- a/dbm/src/hash_buf.c
+++ b/dbm/src/hash_buf.c
@@ -216,7 +216,7 @@ newbuf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp)
*/
memset(bp, 0xff, sizeof(BUFHEAD));
- if ((bp->page = (char *)malloc(hashp->BSIZE)) == NULL) {
+ if ((bp->page = (char *)malloc((size_t)hashp->BSIZE)) == NULL) {
free(bp);
return (NULL);
}
@@ -224,7 +224,7 @@ newbuf(HTAB *hashp, uint32 addr, BUFHEAD *prev_bp)
/* this memset is supposedly unnecessary but lets add
* it anyways.
*/
- memset(bp->page, 0xff, hashp->BSIZE);
+ memset(bp->page, 0xff, (size_t)hashp->BSIZE);
if (hashp->nbufs)
hashp->nbufs--;
diff --git a/dbm/src/nsres.c b/dbm/src/nsres.c
index 1751b7c08..44b448cf7 100644
--- a/dbm/src/nsres.c
+++ b/dbm/src/nsres.c
@@ -49,7 +49,7 @@ int GenKeyData(const char *library, int32 id, DBT *key)
{
char idstr[10];
static char * strdata = NULL;
- int len;
+ size_t len;
if (strdata)
free (strdata);
diff --git a/dbm/tests/lots.c b/dbm/tests/lots.c
index c6781f6e8..e2c9cda04 100644
--- a/dbm/tests/lots.c
+++ b/dbm/tests/lots.c
@@ -134,9 +134,9 @@ DBT * MakeLargeKey(int32 num)
/* malloc a string low_bits wide */
size = low_bits*sizeof(char);
- string_rv = (char *)malloc(size);
+ string_rv = (char *)malloc((size_t)size);
- memset(string_rv, rep_char, size);
+ memset(string_rv, rep_char, (size_t)size);
rv.data = string_rv;
rv.size = size;
@@ -151,7 +151,7 @@ DBT * MakeSmallKey(int32 num)
rv.data = data_string;
- sprintf(data_string, "%ld", num);
+ sprintf(data_string, "%ld", (long)num);
rv.size = strlen(data_string);
return(&rv);
@@ -326,7 +326,7 @@ GenData(int32 num)
size = sizeof(int32)*(n+1);
- int32_array = (int32 *) malloc(size);
+ int32_array = (int32 *) malloc((size_t)size);
memcpy(&int32_array[0], &n, sizeof(int32));