From 17d47efc07365403688d5c8f3cb9d571c0a593cd Mon Sep 17 00:00:00 2001 From: Sascha Wildner Date: Sat, 19 Nov 2005 20:46:32 +0000 Subject: [PATCH] - Fix several compilation warnings. - Put individual function parameter comments into a general comment to make the definition look better. Submitted-by: Alexey Slynko --- lib/libc/db/btree/bt_split.c | 10 +++++++--- lib/libc/db/hash/hash_bigkey.c | 24 +++++++++++++----------- lib/libc/db/hash/hash_buf.c | 12 +++++++----- lib/libc/db/hash/hash_func.c | 8 ++++---- lib/libc/db/hash/hash_log2.c | 5 ++++- lib/libc/db/hash/hash_page.c | 15 ++++++++------- lib/libc/db/mpool/mpool.c | 10 ++++------ lib/libc/db/recno/rec_close.c | 5 +++-- lib/libc/db/recno/rec_delete.c | 12 ++++++------ lib/libc/db/recno/rec_open.c | 4 +++- lib/libc/db/recno/rec_put.c | 20 ++++++++++---------- 11 files changed, 69 insertions(+), 56 deletions(-) diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c index 447935bf57..d00320460a 100644 --- a/lib/libc/db/btree/bt_split.c +++ b/lib/libc/db/btree/bt_split.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * @(#)bt_split.c 8.9 (Berkeley) 7/26/94 - * $DragonFly: src/lib/libc/db/btree/bt_split.c,v 1.7 2005/11/12 23:01:54 swildner Exp $ + * $DragonFly: src/lib/libc/db/btree/bt_split.c,v 1.8 2005/11/19 20:46:32 swildner Exp $ */ #include @@ -88,6 +88,9 @@ __bt_split(BTREE *t, PAGE *sp, const DBT *key, const DBT *data, int flags, int parentsplit; char *dest; + bi = NULL; + bl = NULL; + nksize = 0; /* * Split the page into two pages, l and r. The split routines return * a pointer to the page into which the key should be inserted and with @@ -600,6 +603,7 @@ bt_psplit(BTREE *t, PAGE *h, PAGE *l, PAGE *r, indx_t *pskip, size_t ilen) u_int32_t nbytes; int bigkeycnt, isbigkey; + src = NULL; /* * Split the data to the left and right pages. Leave the skip index * open. Additionally, make some effort not to split on an overflow @@ -647,8 +651,8 @@ bt_psplit(BTREE *t, PAGE *h, PAGE *l, PAGE *r, indx_t *pskip, size_t ilen) * where we decide to try and copy too much onto the left page. * Make sure that doesn't happen. */ - if (skip <= off && - used + nbytes + sizeof(indx_t) >= full || nxt == top - 1) { + if ((skip <= off && + used + nbytes + sizeof(indx_t) >= full) || nxt == top - 1) { --off; break; } diff --git a/lib/libc/db/hash/hash_bigkey.c b/lib/libc/db/hash/hash_bigkey.c index 90f81f38b3..c964c7f041 100644 --- a/lib/libc/db/hash/hash_bigkey.c +++ b/lib/libc/db/hash/hash_bigkey.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * @(#)hash_bigkey.c 8.3 (Berkeley) 5/31/94 - * $DragonFly: src/lib/libc/db/hash/hash_bigkey.c,v 1.8 2005/11/12 23:01:55 swildner Exp $ + * $DragonFly: src/lib/libc/db/hash/hash_bigkey.c,v 1.9 2005/11/19 20:46:32 swildner Exp $ */ /* @@ -113,7 +113,7 @@ __big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val) if (!bufp) return (-1); n = p[0]; - if (!key_size) + if (!key_size) { if (FREESPACE(p)) { move_bytes = MIN(FREESPACE(p), val_size); off = OFFSET(p) - move_bytes; @@ -126,6 +126,7 @@ __big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val) OFFSET(p) = off; } else p[n - 2] = FULL_KEY; + } p = (u_int16_t *)bufp->page; cp = bufp->page; bufp->flags |= BUF_MOD; @@ -527,18 +528,19 @@ collect_key(HTAB *hashp, BUFHEAD *bufp, int len, DBT *val, int set) } /* + * Parameters: + * op: Pointer to where to put keys that go in old bucket + * np: Pointer to new bucket page + * big_keyp: Pointer to first page containing the big key/data + * addr: Address of big_keyp + * obucket: Old Bucket * Returns: - * 0 => OK - * -1 => error + * 0 => OK + * -1 => error */ extern int -__big_split(HTAB *hashp, - BUFHEAD *op, /* Pointer to where to put keys that go in old bucket */ - BUFHEAD *np, /* Pointer to new bucket page */ - BUFHEAD *big_keyp, /* Pointer to first page containing the big key/data */ - int addr, /* Address of big_keyp */ - u_int32_t obucket, /* Old Bucket */ - SPLIT_RETURN *ret) +__big_split(HTAB *hashp, BUFHEAD *op, BUFHEAD *np, BUFHEAD *big_keyp, + int addr, u_int32_t obucket, SPLIT_RETURN *ret) { BUFHEAD *tmpp; u_int16_t *tp; diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c index 0a34375fa1..e3ce22bc19 100644 --- a/lib/libc/db/hash/hash_buf.c +++ b/lib/libc/db/hash/hash_buf.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/db/hash/hash_buf.c,v 1.4.8.1 2001/03/05 07:38:05 obrien Exp $ - * $DragonFly: src/lib/libc/db/hash/hash_buf.c,v 1.6 2005/11/12 23:01:55 swildner Exp $ + * $DragonFly: src/lib/libc/db/hash/hash_buf.c,v 1.7 2005/11/19 20:46:32 swildner Exp $ * * @(#)hash_buf.c 8.5 (Berkeley) 7/15/94 */ @@ -96,12 +96,12 @@ static BUFHEAD *newbuf (HTAB *, u_int32_t, BUFHEAD *); * CAVEAT: The buffer header accessed via prev_bp's ovfl field may no longer * be valid. Therefore, you must always verify that its address matches the * address you are seeking. + * + * Parameters: + * newpage: If prev_bp set, indicates a new overflow page */ extern BUFHEAD * -__get_buf(HTAB *hashp, - u_int32_t addr, - BUFHEAD *prev_bp, - int newpage) /* If prev_bp set, indicates a new overflow page. */ +__get_buf(HTAB *hashp, u_int32_t addr, BUFHEAD *prev_bp, int newpage) { BUFHEAD *bp; u_int32_t is_disk_mask; @@ -110,6 +110,8 @@ __get_buf(HTAB *hashp, is_disk = 0; is_disk_mask = 0; + segment_ndx = 0; + segp = NULL; if (prev_bp) { bp = prev_bp->ovfl; if (!bp || (bp->addr != addr)) diff --git a/lib/libc/db/hash/hash_func.c b/lib/libc/db/hash/hash_func.c index 0833665ffd..95567b2bb9 100644 --- a/lib/libc/db/hash/hash_func.c +++ b/lib/libc/db/hash/hash_func.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * @(#)hash_func.c 8.2 (Berkeley) 2/21/94 - * $DragonFly: src/lib/libc/db/hash/hash_func.c,v 1.7 2005/11/12 23:01:55 swildner Exp $ + * $DragonFly: src/lib/libc/db/hash/hash_func.c,v 1.8 2005/11/19 20:46:32 swildner Exp $ */ #include @@ -40,9 +40,9 @@ #include "page.h" #include "extern.h" -static u_int32_t hash1 (const void *, size_t); -static u_int32_t hash2 (const void *, size_t); -static u_int32_t hash3 (const void *, size_t); +static u_int32_t hash1 (const void *, size_t) __unused; +static u_int32_t hash2 (const void *, size_t) __unused; +static u_int32_t hash3 (const void *, size_t) __unused; static u_int32_t hash4 (const void *, size_t); /* Global default hash function */ diff --git a/lib/libc/db/hash/hash_log2.c b/lib/libc/db/hash/hash_log2.c index df57cae257..ace9c3a417 100644 --- a/lib/libc/db/hash/hash_log2.c +++ b/lib/libc/db/hash/hash_log2.c @@ -30,12 +30,15 @@ * SUCH DAMAGE. * * @(#)hash_log2.c 8.2 (Berkeley) 5/31/94 - * $DragonFly: src/lib/libc/db/hash/hash_log2.c,v 1.5 2005/11/12 23:01:55 swildner Exp $ + * $DragonFly: src/lib/libc/db/hash/hash_log2.c,v 1.6 2005/11/19 20:46:32 swildner Exp $ */ #include #include +#include "hash.h" +#include "page.h" +#include "extern.h" u_int32_t __log2(u_int32_t num) diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c index 1260877f13..6a6b85dce4 100644 --- a/lib/libc/db/hash/hash_page.c +++ b/lib/libc/db/hash/hash_page.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/db/hash/hash_page.c,v 1.5 2000/01/27 23:06:08 jasone Exp $ - * $DragonFly: src/lib/libc/db/hash/hash_page.c,v 1.7 2005/11/12 23:01:55 swildner Exp $ + * $DragonFly: src/lib/libc/db/hash/hash_page.c,v 1.8 2005/11/19 20:46:32 swildner Exp $ * * @(#)hash_page.c 8.7 (Berkeley) 8/16/94 */ @@ -261,17 +261,17 @@ __split_page(HTAB *hashp, u_int32_t obucket, u_int32_t nbucket) * page or it might be a big key/data pair in which case we need to fix the * big key/data pair. * + * Parameters: + * obucket - Same as __split_page + * copyto - First byte on page which contains key/data values + * moved - Number of pairs moved to new page * Returns: * 0 ==> success * -1 ==> failure */ static int -ugly_split(HTAB *hashp, - u_int32_t obucket, /* Same as __split_page. */ - BUFHEAD *old_bufp, - BUFHEAD *new_bufp, - int copyto, /* First byte on page which contains key/data values. */ - int moved) /* Number of pairs moved to new page. */ +ugly_split(HTAB *hashp, u_int32_t obucket, BUFHEAD *old_bufp, + BUFHEAD *new_bufp, int copyto, int moved) { BUFHEAD *bufp; /* Buffer header for ino */ u_int16_t *ino; /* Page keys come off of */ @@ -648,6 +648,7 @@ overflow_page(HTAB *hashp) #ifdef DEBUG2 int tmp1, tmp2; #endif + freep = NULL; splitnum = hashp->OVFL_POINT; max_free = hashp->SPARES[splitnum]; diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c index f807b48b33..1a6433d6e5 100644 --- a/lib/libc/db/mpool/mpool.c +++ b/lib/libc/db/mpool/mpool.c @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/lib/libc/db/mpool/mpool.c,v 1.5.2.1 2001/03/05 23:05:01 obrien Exp $ - * $DragonFly: src/lib/libc/db/mpool/mpool.c,v 1.6 2005/11/12 23:01:55 swildner Exp $ + * $DragonFly: src/lib/libc/db/mpool/mpool.c,v 1.7 2005/11/19 20:46:32 swildner Exp $ * * @(#)mpool.c 8.5 (Berkeley) 7/26/94 */ @@ -58,7 +58,7 @@ static int mpool_write (MPOOL *, BKT *); * Initialize a memory pool. */ MPOOL * -mpool_open(void *key, int fd, pgno_t pagesize, pgno_t maxcache) +mpool_open(void *key __unused, int fd, pgno_t pagesize, pgno_t maxcache) { struct stat sb; MPOOL *mp; @@ -141,9 +141,7 @@ mpool_new(MPOOL *mp, pgno_t *pgnoaddr) * Get a page. */ void * -mpool_get(MPOOL *mp, - pgno_t pgno, - u_int flags) /* XXX not used? */ +mpool_get(MPOOL *mp, pgno_t pgno, u_int flags __unused) { struct _hqh *head; BKT *bp; @@ -225,7 +223,7 @@ mpool_get(MPOOL *mp, * Return a page. */ int -mpool_put(MPOOL *mp, void *page, u_int flags) +mpool_put(MPOOL *mp __unused, void *page, u_int flags) { BKT *bp; diff --git a/lib/libc/db/recno/rec_close.c b/lib/libc/db/recno/rec_close.c index 393c4e332d..94290f68c1 100644 --- a/lib/libc/db/recno/rec_close.c +++ b/lib/libc/db/recno/rec_close.c @@ -28,7 +28,7 @@ * * @(#)rec_close.c 8.6 (Berkeley) 8/18/94 * $FreeBSD: src/lib/libc/db/recno/rec_close.c,v 1.4 2000/01/27 23:06:11 jasone Exp $ - * $DragonFly: src/lib/libc/db/recno/rec_close.c,v 1.5 2005/11/12 23:01:55 swildner Exp $ + * $DragonFly: src/lib/libc/db/recno/rec_close.c,v 1.6 2005/11/19 20:46:32 swildner Exp $ */ #include "namespace.h" @@ -76,13 +76,14 @@ __rec_close(DB *dbp) if (F_ISSET(t, R_MEMMAPPED) && munmap(t->bt_smap, t->bt_msize)) status = RET_ERROR; - if (!F_ISSET(t, R_INMEM)) + if (!F_ISSET(t, R_INMEM)) { if (F_ISSET(t, R_CLOSEFP)) { if (fclose(t->bt_rfp)) status = RET_ERROR; } else if (_close(t->bt_rfd)) status = RET_ERROR; + } if (__bt_close(dbp) == RET_ERROR) status = RET_ERROR; diff --git a/lib/libc/db/recno/rec_delete.c b/lib/libc/db/recno/rec_delete.c index f869c9a058..4a224e3ece 100644 --- a/lib/libc/db/recno/rec_delete.c +++ b/lib/libc/db/recno/rec_delete.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * @(#)rec_delete.c 8.7 (Berkeley) 7/14/94 - * $DragonFly: src/lib/libc/db/recno/rec_delete.c,v 1.5 2005/11/12 23:01:55 swildner Exp $ + * $DragonFly: src/lib/libc/db/recno/rec_delete.c,v 1.6 2005/11/19 20:46:32 swildner Exp $ */ #include @@ -135,13 +135,13 @@ rec_rdelete(BTREE *t, recno_t nrec) * * Parameters: * t: tree - * index: index on current page to delete + * idx: index on current page to delete * * Returns: * RET_SUCCESS, RET_ERROR. */ int -__rec_dleaf(BTREE *t, PAGE *h, u_int32_t index) +__rec_dleaf(BTREE *t, PAGE *h, u_int32_t idx) { RLEAF *rl; indx_t *ip, cnt, offset; @@ -159,7 +159,7 @@ __rec_dleaf(BTREE *t, PAGE *h, u_int32_t index) * down, overwriting the deleted record and its index. If the record * uses overflow pages, make them available for reuse. */ - to = rl = GETRLEAF(h, index); + to = rl = GETRLEAF(h, idx); if (rl->flags & P_BIGDATA && __ovfl_delete(t, rl->bytes) == RET_ERROR) return (RET_ERROR); nbytes = NRLEAF(rl); @@ -172,8 +172,8 @@ __rec_dleaf(BTREE *t, PAGE *h, u_int32_t index) memmove(from + nbytes, from, (char *)to - from); h->upper += nbytes; - offset = h->linp[index]; - for (cnt = &h->linp[index] - (ip = &h->linp[0]); cnt--; ++ip) + offset = h->linp[idx]; + for (cnt = &h->linp[idx] - (ip = &h->linp[0]); cnt--; ++ip) if (ip[0] < offset) ip[0] += nbytes; for (cnt = &h->linp[NEXTINDEX(h)] - ip; --cnt; ++ip) diff --git a/lib/libc/db/recno/rec_open.c b/lib/libc/db/recno/rec_open.c index 9ae739ffd8..e1421d5c66 100644 --- a/lib/libc/db/recno/rec_open.c +++ b/lib/libc/db/recno/rec_open.c @@ -31,7 +31,7 @@ * * @(#)rec_open.c 8.10 (Berkeley) 9/1/94 * $FreeBSD: src/lib/libc/db/recno/rec_open.c,v 1.4 2000/01/27 23:06:11 jasone Exp $ - * $DragonFly: src/lib/libc/db/recno/rec_open.c,v 1.5 2005/11/12 23:01:55 swildner Exp $ + * $DragonFly: src/lib/libc/db/recno/rec_open.c,v 1.6 2005/11/19 20:46:32 swildner Exp $ */ #include "namespace.h" @@ -61,6 +61,8 @@ __rec_open(const char *fname, int flags, int mode, const RECNOINFO *openinfo, struct stat sb; int rfd, sverrno; + rfd = 0; + /* Open the user's file -- if this fails, we're done. */ if (fname != NULL && (rfd = _open(fname, flags, mode)) < 0) return (NULL); diff --git a/lib/libc/db/recno/rec_put.c b/lib/libc/db/recno/rec_put.c index 50316de37b..2ce35c8e43 100644 --- a/lib/libc/db/recno/rec_put.c +++ b/lib/libc/db/recno/rec_put.c @@ -28,7 +28,7 @@ * * @(#)rec_put.c 8.7 (Berkeley) 8/18/94 * $FreeBSD: src/lib/libc/db/recno/rec_put.c,v 1.4.6.1 2001/01/02 05:13:25 peter Exp $ - * $DragonFly: src/lib/libc/db/recno/rec_put.c,v 1.4 2005/11/12 23:01:55 swildner Exp $ + * $DragonFly: src/lib/libc/db/recno/rec_put.c,v 1.5 2005/11/19 20:46:32 swildner Exp $ */ #include @@ -189,7 +189,7 @@ __rec_iput(BTREE *t, recno_t nrec, const DBT *data, u_int flags) DBT tdata; EPG *e; PAGE *h; - indx_t index, nxtindex; + indx_t curindex, nxtindex; pgno_t pg; u_int32_t nbytes; int dflags, status; @@ -220,7 +220,7 @@ __rec_iput(BTREE *t, recno_t nrec, const DBT *data, u_int flags) return (RET_ERROR); h = e->page; - index = e->index; + curindex = e->index; /* * Add the specified key/data pair to the tree. The R_IAFTER and @@ -230,13 +230,13 @@ __rec_iput(BTREE *t, recno_t nrec, const DBT *data, u_int flags) */ switch (flags) { case R_IAFTER: - ++index; + ++curindex; break; case R_IBEFORE: break; default: if (nrec < t->bt_nrecs && - __rec_dleaf(t, h, index) == RET_ERROR) { + __rec_dleaf(t, h, curindex) == RET_ERROR) { mpool_put(t->bt_mp, h, 0); return (RET_ERROR); } @@ -250,18 +250,18 @@ __rec_iput(BTREE *t, recno_t nrec, const DBT *data, u_int flags) */ nbytes = NRLEAFDBT(data->size); if (h->upper - h->lower < nbytes + sizeof(indx_t)) { - status = __bt_split(t, h, NULL, data, dflags, nbytes, index); + status = __bt_split(t, h, NULL, data, dflags, nbytes, curindex); if (status == RET_SUCCESS) ++t->bt_nrecs; return (status); } - if (index < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + index + 1, h->linp + index, - (nxtindex - index) * sizeof(indx_t)); + if (curindex < (nxtindex = NEXTINDEX(h))) + memmove(h->linp + curindex + 1, h->linp + curindex, + (nxtindex - curindex) * sizeof(indx_t)); h->lower += sizeof(indx_t); - h->linp[index] = h->upper -= nbytes; + h->linp[curindex] = h->upper -= nbytes; dest = (char *)h + h->upper; WR_RLEAF(dest, data, dflags); -- 2.41.0