From c7201a0f3969a8944f07e02e6d165eba0d3036c4 Mon Sep 17 00:00:00 2001 From: lukem Date: Thu, 12 Feb 2009 06:35:54 +0000 Subject: [PATCH] fix -Wsign-compare issues --- lib/libc/db/btree/bt_put.c | 8 ++++---- lib/libc/db/btree/bt_split.c | 6 +++--- lib/libc/db/hash/hash.c | 15 ++++++++------- 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/lib/libc/db/btree/bt_put.c b/lib/libc/db/btree/bt_put.c index bd58c21c1611..37630b819acc 100644 --- a/lib/libc/db/btree/bt_put.c +++ b/lib/libc/db/btree/bt_put.c @@ -1,4 +1,4 @@ -/* $NetBSD: bt_put.c,v 1.18 2008/09/11 12:58:00 joerg Exp $ */ +/* $NetBSD: bt_put.c,v 1.19 2009/02/12 06:40:14 lukem Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -37,7 +37,7 @@ #endif #include -__RCSID("$NetBSD: bt_put.c,v 1.18 2008/09/11 12:58:00 joerg Exp $"); +__RCSID("$NetBSD: bt_put.c,v 1.19 2009/02/12 06:40:14 lukem Exp $"); #include "namespace.h" #include @@ -202,7 +202,7 @@ delete: if (__bt_dleaf(t, key, h, (u_int)idx) == RET_ERROR) { * into the offset array, shift the pointers up. */ nbytes = NBLEAFDBT(key->size, data->size); - if (h->upper - h->lower < nbytes + sizeof(indx_t)) { + if ((uint32_t)h->upper - (uint32_t)h->lower < nbytes + sizeof(indx_t)) { if ((status = __bt_split(t, h, key, data, dflags, nbytes, (u_int)idx)) != RET_SUCCESS) return (status); @@ -283,7 +283,7 @@ bt_fast(BTREE *t, const DBT *key, const DBT *data, int *exactp) * have to search to get split stack. */ nbytes = NBLEAFDBT(key->size, data->size); - if (h->upper - h->lower < nbytes + sizeof(indx_t)) + if ((uint32_t)h->upper - (uint32_t)h->lower < nbytes + sizeof(indx_t)) goto miss; if (t->bt_order == FORWARD) { diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c index 8ef58b338120..506cc397a39d 100644 --- a/lib/libc/db/btree/bt_split.c +++ b/lib/libc/db/btree/bt_split.c @@ -1,4 +1,4 @@ -/* $NetBSD: bt_split.c,v 1.17 2008/09/11 12:58:00 joerg Exp $ */ +/* $NetBSD: bt_split.c,v 1.18 2009/02/12 06:41:40 lukem Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -37,7 +37,7 @@ #endif #include -__RCSID("$NetBSD: bt_split.c,v 1.17 2008/09/11 12:58:00 joerg Exp $"); +__RCSID("$NetBSD: bt_split.c,v 1.18 2009/02/12 06:41:40 lukem Exp $"); #include "namespace.h" #include @@ -215,7 +215,7 @@ __bt_split(BTREE *t, PAGE *sp, const DBT *key, const DBT *data, int flags, } /* Split the parent page if necessary or shift the indices. */ - if (h->upper - h->lower < nbytes + sizeof(indx_t)) { + if ((uint32_t)h->upper - (uint32_t)h->lower < nbytes + sizeof(indx_t)) { sp = h; h = h->pgno == P_ROOT ? bt_root(t, h, &l, &r, &skip, nbytes) : diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c index cce6e1b548d6..358a0719a896 100644 --- a/lib/libc/db/hash/hash.c +++ b/lib/libc/db/hash/hash.c @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.30 2008/09/11 12:58:00 joerg Exp $ */ +/* $NetBSD: hash.c,v 1.31 2009/02/12 06:35:54 lukem Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -37,7 +37,7 @@ #endif #include -__RCSID("$NetBSD: hash.c,v 1.30 2008/09/11 12:58:00 joerg Exp $"); +__RCSID("$NetBSD: hash.c,v 1.31 2009/02/12 06:35:54 lukem Exp $"); #include "namespace.h" #include @@ -161,7 +161,8 @@ __hash_open(const char *file, int flags, mode_t mode, const HASHINFO *info, if (hashp->VERSION != HASHVERSION && hashp->VERSION != OLDHASHVERSION) RETURN_ERROR(EFTYPE, error1); - if (hashp->hash(CHARKEY, sizeof(CHARKEY)) != hashp->H_CHARKEY) + if (hashp->hash(CHARKEY, sizeof(CHARKEY)) != + (uint32_t)hashp->H_CHARKEY) RETURN_ERROR(EFTYPE, error1); /* * Figure out how many segments we need. Max_Bucket is the @@ -377,7 +378,7 @@ init_htab(HTAB *hashp, size_t nelem) nsegs = (nbuckets - 1) / hashp->SGSIZE + 1; nsegs = 1 << __log2(nsegs); - if (nsegs > hashp->DSIZE) + if (nsegs > (uint32_t)hashp->DSIZE) hashp->DSIZE = nsegs; return (alloc_segs(hashp, (int)nsegs)); } @@ -601,7 +602,7 @@ hash_access(HTAB *hashp, ACTION action, DBT *key, DBT *val) for (bp = (uint16_t *)(void *)rbufp->page, n = *bp++, ndx = 1; ndx < n;) if (bp[1] >= REAL_KEY) { /* Real key/data pair */ - if (size == off - *bp && + if (size == (size_t)(off - *bp) && memcmp(kp, rbufp->page + *bp, size) == 0) goto found; off = bp[1]; @@ -726,7 +727,7 @@ hash_seq(const DB *dbp, DBT *key, DBT *data, uint32_t flag) for (bp = NULL; !bp || !bp[0]; ) { if (!(bufp = hashp->cpage)) { for (bucket = hashp->cbucket; - bucket <= hashp->MAX_BUCKET; + bucket <= (uint32_t)hashp->MAX_BUCKET; bucket++, hashp->cndx = 1) { bufp = __get_buf(hashp, bucket, NULL, 0); if (!bufp) @@ -831,7 +832,7 @@ __expand_table(HTAB *hashp) hashp->OVFL_POINT = spare_ndx; } - if (new_bucket > hashp->HIGH_MASK) { + if (new_bucket > (uint32_t)hashp->HIGH_MASK) { /* Starting a new doubling */ hashp->LOW_MASK = hashp->HIGH_MASK; hashp->HIGH_MASK = new_bucket | hashp->LOW_MASK;