Clean up many pointer alignment warnings by casting through (void *).
Clean up many signed-unsigned comparison warnings by casting to
unsigned types or redeclaring variables as unsigned types as
appropriate.
indx_t idx = 0;
db_pgno_t pgno;
recno_t nextpg, prevpg;
- int exact, level;
+ int exact;
+ unsigned int level;
/*
* Find the first occurrence of the key in the tree. Toss the
* into the offset array, shift the pointers up.
*/
nbytes = NBLEAFDBT(key->size, data->size);
- if (h->upper - h->lower < nbytes + sizeof(indx_t)) {
+ if ((u_int32_t)h->upper - (u_int32_t)h->lower
+ < nbytes + sizeof(indx_t)) {
if ((status = __bt_split(t, h, key,
data, dflags, nbytes, idx)) != RET_SUCCESS)
return (status);
* have to search to get split stack.
*/
nbytes = NBLEAFDBT(key->size, data->size);
- if (h->upper - h->lower < nbytes + sizeof(indx_t))
+ if ((u_int32_t)h->upper - (u_int32_t)h->lower < nbytes + sizeof(indx_t))
goto miss;
if (t->bt_order == FORWARD) {
EPGNO *parent;
indx_t idx = 0;
db_pgno_t pgno;
- int level;
+ unsigned int level;
/*
* Get the next page. The key is either an exact
EPGNO *parent;
indx_t idx = 0;
db_pgno_t pgno;
- int level;
+ unsigned int level;
/*
* Get the previous page. The key is either an exact
}
/* Split the parent page if necessary or shift the indices. */
- if (h->upper - h->lower < nbytes + sizeof(indx_t)) {
+ if ((u_int32_t)h->upper - (u_int32_t)h->lower
+ < nbytes + sizeof(indx_t)) {
sp = h;
h = h->pgno == P_ROOT ?
bt_root(t, h, &l, &r, &skip, nbytes) :
h->linp[skip] = h->upper -= nbytes;
dest = (char *)h + h->linp[skip];
memmove(dest, bi, nbytes);
- ((BINTERNAL *)dest)->pgno = rchild->pgno;
+ ((BINTERNAL *)(void *)dest)->pgno = rchild->pgno;
break;
case P_BLEAF:
h->linp[skip] = h->upper -= nbytes;
dest = (char *)h + h->linp[skip - 1];
else
dest = (char *)l + l->linp[NEXTINDEX(l) - 1];
- ((RINTERNAL *)dest)->nrecs = rec_total(lchild);
- ((RINTERNAL *)dest)->pgno = lchild->pgno;
+ ((RINTERNAL *)(void *)dest)->nrecs = rec_total(lchild);
+ ((RINTERNAL *)(void *)dest)->pgno = lchild->pgno;
/* Update the right page count. */
h->linp[skip] = h->upper -= nbytes;
dest = (char *)h + h->linp[skip];
- ((RINTERNAL *)dest)->nrecs = rec_total(rchild);
- ((RINTERNAL *)dest)->pgno = rchild->pgno;
+ ((RINTERNAL *)(void *)dest)->nrecs = rec_total(rchild);
+ ((RINTERNAL *)(void *)dest)->pgno = rchild->pgno;
break;
case P_RLEAF:
/*
dest = (char *)h + h->linp[skip - 1];
else
dest = (char *)l + l->linp[NEXTINDEX(l) - 1];
- ((RINTERNAL *)dest)->nrecs = NEXTINDEX(lchild);
- ((RINTERNAL *)dest)->pgno = lchild->pgno;
+ ((RINTERNAL *)(void *)dest)->nrecs = NEXTINDEX(lchild);
+ ((RINTERNAL *)(void *)dest)->pgno = lchild->pgno;
/* Update the right page count. */
h->linp[skip] = h->upper -= nbytes;
dest = (char *)h + h->linp[skip];
- ((RINTERNAL *)dest)->nrecs = NEXTINDEX(rchild);
- ((RINTERNAL *)dest)->pgno = rchild->pgno;
+ ((RINTERNAL *)(void *)dest)->nrecs = NEXTINDEX(rchild);
+ ((RINTERNAL *)(void *)dest)->pgno = rchild->pgno;
break;
default:
abort();
h->linp[1] = h->upper -= nbytes;
dest = (char *)h + h->upper;
memmove(dest, bi, nbytes);
- ((BINTERNAL *)dest)->pgno = r->pgno;
+ ((BINTERNAL *)(void *)dest)->pgno = r->pgno;
break;
default:
abort();
/* Get the page's BINTERNAL structure at index indx. */
#define GETBINTERNAL(pg, indx) \
- ((BINTERNAL *)((char *)(pg) + (pg)->linp[indx]))
+ ((BINTERNAL *)(void *)((char *)(pg) + (pg)->linp[indx]))
/* Get the number of bytes in the entry. */
#define NBINTERNAL(len) \
/* Copy a BINTERNAL entry to the page. */
#define WR_BINTERNAL(p, size, pgno, flags) { \
- *(u_int32_t *)p = size; \
+ *(u_int32_t *)(void *)p = size; \
p += sizeof(u_int32_t); \
- *(db_pgno_t *)p = pgno; \
+ *(db_pgno_t *)(void *)p = pgno; \
p += sizeof(db_pgno_t); \
*(u_char *)p = flags; \
p += sizeof(u_char); \
/* Get the page's RINTERNAL structure at index indx. */
#define GETRINTERNAL(pg, indx) \
- ((RINTERNAL *)((char *)(pg) + (pg)->linp[indx]))
+ ((RINTERNAL *)(void *)((char *)(void *)(pg) + (pg)->linp[indx]))
/* Get the number of bytes in the entry. */
#define NRINTERNAL \
/* Copy a RINTERAL entry to the page. */
#define WR_RINTERNAL(p, nrecs, pgno) { \
- *(recno_t *)p = nrecs; \
+ *(recno_t *)(void *)p = nrecs; \
p += sizeof(recno_t); \
- *(db_pgno_t *)p = pgno; \
+ *(db_pgno_t *)(void *)p = pgno; \
}
/* For the btree leaf pages, the item is a key and data pair. */
/* Get the page's BLEAF structure at index indx. */
#define GETBLEAF(pg, indx) \
- ((BLEAF *)((char *)(pg) + (pg)->linp[indx]))
+ ((BLEAF *)(void *)((char *)(pg) + (pg)->linp[indx]))
/* Get the number of bytes in the entry. */
#define NBLEAF(p) NBLEAFDBT((p)->ksize, (p)->dsize)
/* Copy a BLEAF entry to the page. */
#define WR_BLEAF(p, key, data, flags) { \
- *(u_int32_t *)p = key->size; \
+ *(u_int32_t *)(void *)p = key->size; \
p += sizeof(u_int32_t); \
- *(u_int32_t *)p = data->size; \
+ *(u_int32_t *)(void *)p = data->size; \
p += sizeof(u_int32_t); \
*(u_char *)p = flags; \
p += sizeof(u_char); \
/* Get the page's RLEAF structure at index indx. */
#define GETRLEAF(pg, indx) \
- ((RLEAF *)((char *)(pg) + (pg)->linp[indx]))
+ ((RLEAF *)(void *)((char *)(pg) + (pg)->linp[indx]))
/* Get the number of bytes in the entry. */
#define NRLEAF(p) NRLEAFDBT((p)->dsize)
/* Copy a RLEAF entry to the page. */
#define WR_RLEAF(p, data, flags) { \
- *(u_int32_t *)p = data->size; \
+ *(u_int32_t *)(void *)p = data->size; \
p += sizeof(u_int32_t); \
*(u_char *)p = flags; \
p += sizeof(u_char); \
int8_t *k;
int32_t len;
{
- int32_t n, bucket;
+ u_int32_t n, bucket;
n = hashp->hash(k, len);
bucket = n & hashp->hdr.high_mask;
int32_t magic; /* Magic NO for hash tables */
int32_t version; /* Version ID */
int32_t lorder; /* Byte Order */
- int32_t bsize; /* Bucket/Page Size */
+ u_int32_t bsize; /* Bucket/Page Size */
int32_t bshift; /* Bucket shift */
int32_t ovfl_point; /* Where overflow pages are being allocated */
- int32_t last_freed; /* Last overflow page freed */
- int32_t max_bucket; /* ID of Maximum bucket in use */
- int32_t high_mask; /* Mask to modulo into entire table */
- int32_t low_mask; /* Mask to modulo into lower half of table */
- int32_t ffactor; /* Fill factor */
+ u_int32_t last_freed; /* Last overflow page freed */
+ u_int32_t max_bucket; /* ID of Maximum bucket in use */
+ u_int32_t high_mask; /* Mask to modulo into entire table */
+ u_int32_t low_mask; /* Mask to modulo into lower half of table */
+ u_int32_t ffactor; /* Fill factor */
int32_t nkeys; /* Number of keys in hash table */
- int32_t hdrpages; /* Size of table header */
- int32_t h_charkey; /* value of hash(CHARKEY) */
+ u_int32_t hdrpages; /* Size of table header */
+ u_int32_t h_charkey; /* value of hash(CHARKEY) */
#define NCACHED 32 /* number of bit maps and spare points */
- int32_t spares[NCACHED];/* spare pages for overflow */
+ u_int32_t spares[NCACHED];/* spare pages for overflow */
u_int16_t bitmaps[NCACHED]; /* address of overflow page bitmaps */
} HASHHDR;
indx_t ndx;
indx_t pgndx;
u_int8_t status;
- int32_t seek_size;
+ u_int32_t seek_size;
db_pgno_t seek_found_page;
indx_t key_off;
indx_t data_off;
{
u_int16_t *pagep, n, off;
- pagep = (PAGE16 *)p;
+ pagep = (PAGE16 *)(void *)p;
/* Items on the page are 0-indexed. */
n = NUM_ENT(pagep);
if (is_bitmap_pgno(hashp, pgno)) {
max = hashp->hdr.bsize >> 2; /* divide by 4 bytes */
for (i = 0; i < max; i++)
- M_32_SWAP(((int32_t *)pagep)[i]);
+ M_32_SWAP(((int32_t *)(void *)pagep)[i]);
} else
swap_page_header_in(pagep);
}
if (is_bitmap_pgno(hashp, pgno)) {
max = hashp->hdr.bsize >> 2; /* divide by 4 bytes */
for (i = 0; i < max; i++)
- M_32_SWAP(((int32_t *)pagep)[i]);
+ M_32_SWAP(((int32_t *)(void *)pagep)[i]);
} else
swap_page_header_out(pagep);
}
/* make a new bitmap page */
if (__new_page(hashp, pnum, A_BITMAP) != 0)
return (1);
- if (!(ip = (u_int32_t *)__get_page(hashp, pnum, A_BITMAP)))
+ if (!(ip = (u_int32_t *)(void *)__get_page(hashp, pnum, A_BITMAP)))
return (1);
hashp->nmaps++;
clearints = ((nbits - 1) >> INT32_T_BYTE_SHIFT) + 1;
HTAB *hashp;
{
u_int32_t *freep;
- int32_t bit, first_page, free_bit, free_page, i, in_use_bits, j;
- int32_t max_free, offset, splitnum;
+ u_int32_t bit, first_page, free_bit, free_page, i, in_use_bits, j;
+ u_int32_t max_free, offset, splitnum;
u_int16_t addr;
#ifdef DEBUG2
int32_t tmp1, tmp2;
PAGE16 *pagep;
{
u_int32_t *freep;
- int32_t bit_address, free_page, free_bit;
+ u_int32_t bit_address, free_page, free_bit;
u_int16_t addr, ndx;
addr = page_to_oaddr(hashp, ADDR(pagep));
if (ndx >= hashp->nmaps)
return (NULL);
if (!hashp->mapp[ndx])
- hashp->mapp[ndx] = (u_int32_t *)__get_page(hashp,
+ hashp->mapp[ndx] = (u_int32_t *)(void *)__get_page(hashp,
hashp->hdr.bitmaps[ndx], A_BITMAP);
return (hashp->mapp[ndx]);
#define PAIR_OVERHEAD ((sizeof(indx_t) << 1))
/* Use this macro to extract a value of type T from page P at offset O. */
-#define REFERENCE(P, T, O) (((T *)((u_int8_t *)(P) + O))[0])
+#define REFERENCE(P, T, O) (((T *)(void *)((u_int8_t *)(void *)(P) + O))[0])
/*
* Use these macros to access fields on a page; P is a PAGE16 *.
struct _hqh *head;
BKT *bp;
- bp = (BKT *)((char *)page - sizeof(BKT));
+ bp = (void *)((char *)page - sizeof(BKT));
#ifdef DEBUG
if (!(bp->flags & MPOOL_PINNED)) {
if (lseek(mp->fd, off, SEEK_SET) != off)
return (NULL);
- if ((nr = read(mp->fd, bp->page, mp->pagesize)) != mp->pagesize) {
+ if ((nr = read(mp->fd, bp->page, mp->pagesize)) !=
+ (ssize_t)mp->pagesize) {
if (nr > 0) {
/* A partial read is definitely bad. */
errno = EINVAL;
#ifdef STATISTICS
++mp->pageput;
#endif
- bp = (BKT *)((char *)page - sizeof(BKT));
+ bp = (void *)((char *)page - sizeof(BKT));
#ifdef DEBUG
if (!(bp->flags & MPOOL_PINNED)) {
(void)fprintf(stderr,
}
if (lseek(mp->fd, off, SEEK_SET) != off)
return (RET_ERROR);
- if (write(mp->fd, bp->page, mp->pagesize) != mp->pagesize)
+ if (write(mp->fd, bp->page, mp->pagesize) !=
+ (ssize_t)mp->pagesize)
return (RET_ERROR);
/*
*/
status = (dbp->seq)(dbp, &key, &data, R_FIRST);
while (status == RET_SUCCESS) {
- if (write(t->bt_rfd, data.data, data.size) != data.size)
+ if (write(t->bt_rfd, data.data, data.size) !=
+ (ssize_t)data.size)
return (RET_ERROR);
status = (dbp->seq)(dbp, &key, &data, R_NEXT);
}
while (status == RET_SUCCESS) {
iov[0].iov_base = data.data;
iov[0].iov_len = data.size;
- if (writev(t->bt_rfd, iov, 2) != data.size + 1)
+ if (writev(t->bt_rfd, iov, 2) != (ssize_t)data.size + 1)
return (RET_ERROR);
status = (dbp->seq)(dbp, &key, &data, R_NEXT);
}
return (RET_ERROR);
tdata.data = db;
tdata.size = NOVFLSIZE;
- *(db_pgno_t *)db = pg;
- *(u_int32_t *)(db + sizeof(db_pgno_t)) = data->size;
+ memcpy(db, &pg, sizeof(pg));
+ *(u_int32_t *)(void *)(db + sizeof(db_pgno_t)) = data->size;
dflags = P_BIGDATA;
data = &tdata;
} else
* the offset array, shift the pointers up.
*/
nbytes = NRLEAFDBT(data->size);
- if (h->upper - h->lower < nbytes + sizeof(indx_t)) {
+ if ((u_int32_t)h->upper - (u_int32_t)h->lower
+ < nbytes + sizeof(indx_t)) {
status = __bt_split(t, h, NULL, data, dflags, nbytes, idx);
if (status == RET_SUCCESS)
++t->bt_nrecs;