diff options
author | Keith Bostic <keith@wiredtiger.com> | 2009-09-08 23:39:50 +1000 |
---|---|---|
committer | Keith Bostic <keith@wiredtiger.com> | 2009-09-08 23:39:50 +1000 |
commit | 1029bbf349f26b30b75a40898e6ec036abf4f23b (patch) | |
tree | 5004acd6ec610467ce20398608d8fe5dbeb75ee6 | |
parent | 144cede55e4f03390c18a5024c2ffce1ebb4bca1 (diff) | |
download | mongo-1029bbf349f26b30b75a40898e6ec036abf4f23b.tar.gz |
The WT_ERR, WT_RET and WT_TRET macros don't need an extra level of parenthesis
at the moment.
--HG--
branch : keith
44 files changed, 438 insertions, 437 deletions
diff --git a/btree/bt_bulk.c b/btree/bt_bulk.c index 28d85fb7b10..3c52e20570b 100644 --- a/btree/bt_bulk.c +++ b/btree/bt_bulk.c @@ -29,7 +29,7 @@ __wt_db_bulk_load(WT_TOC *toc) WT_ITEM_OVFL key_ovfl, data_ovfl; WT_PAGE *page, *next; u_int32_t dup_count, dup_space, len; - int ret, tret; + int ret; env = toc->env; @@ -52,7 +52,7 @@ __wt_db_bulk_load(WT_TOC *toc) * case we would allocate page 0 as an overflow page, which is, for * lack of a better phrase, "bad". */ - WT_RET((__wt_bt_page_alloc(db, 1, &page))); + WT_RET(__wt_bt_page_alloc(db, 1, &page)); page->hdr->type = WT_PAGE_LEAF; while ((ret = cb(db, &key, &data)) == 0) { @@ -120,11 +120,11 @@ skip_read: */ if (LF_ISSET(WT_DUPLICATES)) { lastkey = &lastkey_ovfl; - WT_ERR((__wt_bt_dbt_copy(env, key, lastkey))); + WT_ERR(__wt_bt_dbt_copy(env, key, lastkey)); } key_ovfl.len = key->size; - WT_ERR((__wt_bt_ovfl_write(db, key, &key_ovfl.addr))); + WT_ERR(__wt_bt_ovfl_write(db, key, &key_ovfl.addr)); key->data = &key_ovfl; key->size = sizeof(key_ovfl); @@ -136,7 +136,7 @@ skip_read: if (data->size > db->leafitemsize) { data_ovfl.len = data->size; - WT_ERR((__wt_bt_ovfl_write(db, data, &data_ovfl.addr))); + WT_ERR(__wt_bt_ovfl_write(db, data, &data_ovfl.addr)); data->data = &data_ovfl; data->size = sizeof(data_ovfl); @@ -156,7 +156,7 @@ skip_read: */ if ((key == NULL ? 0 : WT_ITEM_SPACE_REQ(key->size)) + WT_ITEM_SPACE_REQ(data->size) > page->space_avail) { - WT_ERR((__wt_bt_page_alloc(db, 1, &next))); + WT_ERR(__wt_bt_page_alloc(db, 1, &next)); next->hdr->type = WT_PAGE_LEAF; next->hdr->prevaddr = page->addr; page->hdr->nextaddr = next->addr; @@ -226,10 +226,9 @@ skip_read: * sets the page's parent address, which is the same for * the newly allocated page. */ - WT_ERR( - (__wt_bt_promote(db, page, page->records, NULL))); + WT_ERR(__wt_bt_promote(db, page, page->records, NULL)); next->hdr->prntaddr = page->hdr->prntaddr; - WT_ERR((__wt_bt_page_out(db, page, WT_MODIFIED))); + WT_ERR(__wt_bt_page_out(db, page, WT_MODIFIED)); /* Switch to the next page. */ page = next; @@ -312,8 +311,8 @@ skip_read: * Move the duplicate set offpage and read in the * rest of the duplicate set. */ - WT_ERR((__wt_bt_dup_offpage(db, page, &key, - &data, lastkey, dup_data, dup_count, cb))); + WT_ERR(__wt_bt_dup_offpage(db, page, &key, + &data, lastkey, dup_data, dup_count, cb)); /* * Reset local counters -- on-page information was @@ -332,7 +331,7 @@ skip_read: /* Promote a key from any partially-filled page and write it. */ if (page != NULL) { ret = __wt_bt_promote(db, page, page->records, NULL); - WT_TRET((__wt_bt_page_out(db, page, WT_MODIFIED))); + WT_TRET(__wt_bt_page_out(db, page, WT_MODIFIED)); page = NULL; } } @@ -403,7 +402,7 @@ __wt_bt_dup_offpage(DB *db, WT_PAGE *leaf_page, * Allocate and initialize a new page, and copy the duplicate set into * place. */ - WT_RET((__wt_bt_page_alloc(db, 1, &page))); + WT_RET(__wt_bt_page_alloc(db, 1, &page)); page->hdr->type = WT_PAGE_DUP_LEAF; page->hdr->u.entries = dup_count; page->records = dup_count; @@ -445,8 +444,7 @@ __wt_bt_dup_offpage(DB *db, WT_PAGE *leaf_page, /* Create overflow objects if the data won't fit. */ if (data->size > db->leafitemsize) { data_local.len = data->size; - WT_RET((__wt_bt_ovfl_write( - db, data, &data_local.addr))); + WT_RET(__wt_bt_ovfl_write(db, data, &data_local.addr)); data->data = &data_local; data->size = sizeof(data_local); WT_ITEM_TYPE_SET(&data_item, WT_ITEM_DUP_OVFL); @@ -459,7 +457,7 @@ __wt_bt_dup_offpage(DB *db, WT_PAGE *leaf_page, * page. */ if (WT_ITEM_SPACE_REQ(data->size) > page->space_avail) { - WT_RET((__wt_bt_page_alloc(db, 1, &next))); + WT_RET(__wt_bt_page_alloc(db, 1, &next)); next->hdr->type = WT_PAGE_DUP_LEAF; next->hdr->prevaddr = page->addr; page->hdr->nextaddr = next->addr; @@ -473,10 +471,10 @@ __wt_bt_dup_offpage(DB *db, WT_PAGE *leaf_page, * If we promoted a key, we might have split, and so * there may be a new offpage duplicates root page. */ - WT_RET((__wt_bt_promote( - db, page, page->records, &root_addr))); + WT_RET(__wt_bt_promote( + db, page, page->records, &root_addr)); next->hdr->prntaddr = page->hdr->prntaddr; - WT_RET((__wt_bt_page_out(db, page, WT_MODIFIED))); + WT_RET(__wt_bt_page_out(db, page, WT_MODIFIED)); /* Switch to the next page. */ page = next; @@ -541,7 +539,7 @@ __wt_bt_promote( WT_ITEM_OVFL tmp_ovfl; WT_PAGE *next, *parent; u_int32_t parent_addr, tmp_root_addr; - int need_promotion, ret, root_split, tret; + int need_promotion, ret, root_split; WT_CLEAR(key); WT_CLEAR(item); @@ -568,8 +566,8 @@ __wt_bt_promote( case WT_ITEM_DUP_OVFL: case WT_ITEM_KEY_OVFL: WT_CLEAR(tmp_ovfl); - WT_RET((__wt_bt_ovfl_copy(db, - (WT_ITEM_OVFL *)WT_ITEM_BYTE(key_item), &tmp_ovfl))); + WT_RET(__wt_bt_ovfl_copy(db, + (WT_ITEM_OVFL *)WT_ITEM_BYTE(key_item), &tmp_ovfl)); key.data = &tmp_ovfl; key.size = sizeof(tmp_ovfl); WT_ITEM_TYPE_SET(&item, WT_ITEM_KEY_OVFL); @@ -638,7 +636,7 @@ __wt_bt_promote( */ parent_addr = page->hdr->prntaddr; if (parent_addr == WT_ADDR_INVALID) { -split: WT_ERR((__wt_bt_page_alloc(db, 0, &next))); +split: WT_ERR(__wt_bt_page_alloc(db, 0, &next)); next->hdr->type = page->hdr->type == WT_PAGE_INT || page->hdr->type == WT_PAGE_LEAF ? @@ -671,15 +669,15 @@ split: WT_ERR((__wt_bt_page_alloc(db, 0, &next))); */ if (parent->hdr->prntaddr == WT_ADDR_INVALID) { root_split = 1; - WT_ERR((__wt_bt_promote( - db, parent, increment, root_addrp))); + WT_ERR(__wt_bt_promote( + db, parent, increment, root_addrp)); } else root_split = 0; next->hdr->prntaddr = parent->hdr->prntaddr; /* Discard the old parent page, we have a new one. */ - WT_ERR((__wt_bt_page_out(db, parent, WT_MODIFIED))); + WT_ERR(__wt_bt_page_out(db, parent, WT_MODIFIED)); need_promotion = 1; } @@ -693,14 +691,14 @@ split: WT_ERR((__wt_bt_page_alloc(db, 0, &next))); * Update the returned database level. */ if (root_split && next->hdr->type == WT_PAGE_INT) - WT_ERR((__wt_bt_desc_write(db, *root_addrp))); + WT_ERR(__wt_bt_desc_write(db, *root_addrp)); /* There's a new parent page, update the page's parent ref. */ page->hdr->prntaddr = next->addr; parent = next; next = NULL; } else { - WT_ERR((__wt_bt_page_in(db, parent_addr, 0, 1, &parent))); + WT_ERR(__wt_bt_page_in(db, parent_addr, 0, 1, &parent)); need_promotion = 0; } @@ -741,8 +739,7 @@ split: WT_ERR((__wt_bt_page_alloc(db, 0, &next))); parent->space_avail -= WT_ITEM_SPACE_REQ(sizeof(WT_ITEM_OFFP)); /* Append the new parent key index to the in-memory page structures. */ - WT_ERR(( - __wt_bt_page_inmem_append(db, parent, parent_key, parent_data))); + WT_ERR(__wt_bt_page_inmem_append(db, parent, parent_key, parent_data)); parent->records += page->records; /* @@ -761,10 +758,9 @@ split: WT_ERR((__wt_bt_page_alloc(db, 0, &next))); if ((parent_addr = parent->hdr->prntaddr) == WT_ADDR_INVALID) break; - WT_ERR((__wt_bt_page_out(db, parent, WT_MODIFIED))); + WT_ERR(__wt_bt_page_out(db, parent, WT_MODIFIED)); parent = NULL; - WT_ERR( - (__wt_bt_page_in(db, parent_addr, 0, 1, &parent))); + WT_ERR(__wt_bt_page_in(db, parent_addr, 0, 1, &parent)); /* * Because of the bulk load pattern, we're always adding @@ -779,9 +775,9 @@ split: WT_ERR((__wt_bt_page_alloc(db, 0, &next))); err: /* Discard the parent page. */ if (parent != NULL) - WT_TRET((__wt_bt_page_out(db, parent, WT_MODIFIED))); + WT_TRET(__wt_bt_page_out(db, parent, WT_MODIFIED)); if (next != NULL) - WT_TRET((__wt_bt_page_out(db, next, WT_MODIFIED))); + WT_TRET(__wt_bt_page_out(db, next, WT_MODIFIED)); return (ret); } @@ -794,8 +790,8 @@ static int __wt_bt_dbt_copy(ENV *env, DBT *orig, DBT *copy) { if (copy->data == NULL || copy->data_len < orig->size) { - WT_RET((__wt_realloc( - env, copy->data_len, orig->size, ©->data))); + WT_RET(__wt_realloc( + env, copy->data_len, orig->size, ©->data)); copy->data_len = orig->size; } memcpy(copy->data, orig->data, copy->size = orig->size); diff --git a/btree/bt_cache.c b/btree/bt_cache.c index 53482c51792..39ef4f04f09 100644 --- a/btree/bt_cache.c +++ b/btree/bt_cache.c @@ -38,8 +38,8 @@ __wt_cache_open(DB *db) * per MB). */ stoc->hashsize = __wt_prime(env->cachesize * 8); - WT_RET((__wt_calloc(env, - stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh))); + WT_RET(__wt_calloc( + env, stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh)); for (i = 0; i < stoc->hashsize; ++i) TAILQ_INIT(&stoc->hqh[i]); TAILQ_INIT(&stoc->lqh); @@ -79,15 +79,15 @@ __wt_cache_close(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_TRET((__wt_cache_write(stoc, page))); - WT_TRET((__wt_cache_discard(stoc, page))); + WT_TRET(__wt_cache_write(stoc, page)); + WT_TRET(__wt_cache_discard(stoc, page)); } /* There shouldn't be any allocated bytes. */ WT_ASSERT(env, stoc->cache_bytes == 0); /* Close the underlying file handle. */ - WT_TRET((__wt_close(env, idb->fh))); + WT_TRET(__wt_close(env, idb->fh)); idb->fh = NULL; /* Discard buckets. */ @@ -116,7 +116,7 @@ __wt_cache_sync(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } return (0); } @@ -136,8 +136,8 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) break; if (page->ref == 0) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } } return (0); @@ -152,15 +152,17 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) * Clear the memory because code depends on initial values of 0. */ #define WT_PAGE_ALLOC(env, stoc, bytes, page) do { \ - int __ret; \ if ((stoc)->cache_bytes > (env)->cachesize * WT_MEGABYTE) \ - WT_RET((__wt_cache_stoc_lru(stoc, env))); \ - WT_RET((__wt_calloc((env), 1, sizeof(WT_PAGE), &(page)))); \ + WT_RET(__wt_cache_stoc_lru(stoc, env)); \ + WT_RET(__wt_calloc((env), 1, sizeof(WT_PAGE), &(page))); \ + { \ + int __ret; \ if (((__ret) = __wt_calloc( \ (env), 1, (size_t)(bytes), &(page)->hdr)) != 0) { \ __wt_free((env), (page)); \ return ((__ret)); \ } \ + } \ (stoc)->cache_bytes += (bytes); \ WT_STAT_INCR((env)->hstats, CACHE_CLEAN, NULL); \ } while (0) @@ -271,7 +273,7 @@ __wt_cache_in(WT_STOC *stoc, TAILQ_INSERT_HEAD(hashq, page, hq); /* Read the page. */ - WT_ERR((__wt_read(env, idb->fh, offset, bytes, page->hdr))); + WT_ERR(__wt_read(env, idb->fh, offset, bytes, page->hdr)); /* Verify the checksum. */ if (!LF_ISSET(WT_UNFORMATTED)) { @@ -328,8 +330,8 @@ __wt_cache_out(WT_STOC *stoc, WT_PAGE *page, u_int32_t flags) */ if (LF_ISSET(WT_UNFORMATTED)) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } return (0); @@ -365,7 +367,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) WT_STAT_INCR(env->hstats, CACHE_WRITE_EVICT, "dirty pages evicted from the cache"); - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } else WT_STAT_INCR(env->hstats, CACHE_EVICT, "clean pages evicted from the cache"); @@ -391,7 +393,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) bytes_free += page->bytes; /* Discard the page. */ - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_discard(stoc, page)); } while (bytes_free < bytes_need_free); return (0); @@ -419,7 +421,7 @@ __wt_cache_write(WT_STOC *stoc, WT_PAGE *page) hdr->checksum = __wt_cksum(hdr, page->bytes); /* Write, and if successful, clear the modified flag. */ - WT_RET((__wt_write(env, idb->fh, page->offset, page->bytes, hdr))); + WT_RET(__wt_write(env, idb->fh, page->offset, page->bytes, hdr)); F_CLR(page, WT_MODIFIED); diff --git a/btree/bt_debug.c b/btree/bt_debug.c index 0e4f59cb908..ae6161afb95 100644 --- a/btree/bt_debug.c +++ b/btree/bt_debug.c @@ -57,7 +57,7 @@ __wt_bt_dump_addr(DB *db, u_int32_t addr, char *ofile, FILE *fp) WT_STOC *stoc; off_t offset; u_int32_t bytes; - int ret, tret; + int ret; stoc = db->idb->stoc; @@ -72,8 +72,8 @@ __wt_bt_dump_addr(DB *db, u_int32_t addr, char *ofile, FILE *fp) * should have in-memory page information. */ offset = WT_ADDR_TO_OFF(db, addr); - WT_RET((__wt_cache_in( - stoc, offset, (u_int32_t)WT_FRAGMENT, WT_UNFORMATTED, &page))); + WT_RET(__wt_cache_in( + stoc, offset, (u_int32_t)WT_FRAGMENT, WT_UNFORMATTED, &page)); if (page->indx_count == 0) { switch (page->hdr->type) { case WT_PAGE_OVFL: @@ -90,13 +90,13 @@ __wt_bt_dump_addr(DB *db, u_int32_t addr, char *ofile, FILE *fp) break; WT_DEFAULT_FORMAT(db); } - WT_RET((__wt_cache_out(stoc, page, WT_UNFORMATTED))); - WT_RET((__wt_cache_in(stoc, offset, bytes, 0, &page))); + WT_RET(__wt_cache_out(stoc, page, WT_UNFORMATTED)); + WT_RET(__wt_cache_in(stoc, offset, bytes, 0, &page)); } ret = __wt_bt_dump_page(db, page, ofile, fp); - WT_TRET((__wt_cache_out(stoc, page, 0))); + WT_TRET(__wt_cache_out(stoc, page, 0)); return (ret); } diff --git a/btree/bt_desc.c b/btree/bt_desc.c index 7558e0c8bfa..b50abc9448b 100644 --- a/btree/bt_desc.c +++ b/btree/bt_desc.c @@ -127,7 +127,6 @@ __wt_bt_desc_read(DB *db) IDB *idb; WT_PAGE *page; WT_PAGE_DESC desc; - int ret; idb = db->idb; @@ -138,9 +137,9 @@ __wt_bt_desc_read(DB *db) * Read in the first fragment of the database and get the root addr * and pagesizes from it. */ - WT_RET((__wt_cache_in(idb->stoc, + WT_RET(__wt_cache_in(idb->stoc, WT_ADDR_TO_OFF(db, WT_ADDR_FIRST_PAGE), - (u_int32_t)WT_FRAGMENT, WT_UNFORMATTED, &page))); + (u_int32_t)WT_FRAGMENT, WT_UNFORMATTED, &page)); memcpy( &desc, (u_int8_t *)page->hdr + WT_PAGE_HDR_SIZE, WT_PAGE_DESC_SIZE); @@ -149,7 +148,7 @@ __wt_bt_desc_read(DB *db) idb->root_addr = desc.root_addr; /* Then discard it from the cache, it's probably the wrong size. */ - WT_RET((__wt_cache_out(idb->stoc, page, WT_UNFORMATTED))); + WT_RET(__wt_cache_out(idb->stoc, page, WT_UNFORMATTED)); return (0); } @@ -165,13 +164,12 @@ __wt_bt_desc_write(DB *db, u_int32_t root_addr) WT_PAGE *page; WT_PAGE_DESC desc; WT_STOC *stoc; - int ret; idb = db->idb; stoc = idb->stoc; - WT_RET((__wt_cache_in(stoc, - WT_ADDR_TO_OFF(db, WT_ADDR_FIRST_PAGE), db->leafsize, 0, &page))); + WT_RET(__wt_cache_in(stoc, + WT_ADDR_TO_OFF(db, WT_ADDR_FIRST_PAGE), db->leafsize, 0, &page)); idb->root_addr = root_addr; diff --git a/btree/bt_discard.c b/btree/bt_discard.c index 8d943046b0e..9a8a6a1c511 100644 --- a/btree/bt_discard.c +++ b/btree/bt_discard.c @@ -23,7 +23,6 @@ __wt_bt_page_alloc(DB *db, int isleaf, WT_PAGE **pagep) WT_PAGE *page; WT_PAGE_HDR *hdr; WT_STOC *stoc; - int ret; stoc = db->idb->stoc; @@ -209,7 +208,6 @@ __wt_bt_page_inmem_append(DB *db, WT_INDX *indx; WT_ITEM_OVFL *ovfl; u_int32_t n; - int ret; env = db->env; idb = db->idb; diff --git a/btree/bt_dump.c b/btree/bt_dump.c index 62fd9e21968..122e17c1485 100644 --- a/btree/bt_dump.c +++ b/btree/bt_dump.c @@ -65,7 +65,7 @@ __wt_db_dump(WT_TOC *toc) WT_CLEAR(last_key_ovfl); for (addr = WT_ADDR_FIRST_PAGE;;) { - WT_RET((__wt_bt_page_in(db, addr, 1, 0, &page))); + WT_RET(__wt_bt_page_in(db, addr, 1, 0, &page)); WT_ITEM_FOREACH(page, item, i) { item_len = WT_ITEM_LEN(item); @@ -103,8 +103,8 @@ __wt_db_dump(WT_TOC *toc) case WT_ITEM_DATA_OVFL: case WT_ITEM_DUP_OVFL: ovfl = (WT_ITEM_OVFL *)WT_ITEM_BYTE(item); - WT_RET((__wt_bt_ovfl_in(db, - ovfl->addr, ovfl->len, &ovfl_page))); + WT_RET(__wt_bt_ovfl_in(db, + ovfl->addr, ovfl->len, &ovfl_page)); /* * If we're already in a duplicate set, dump @@ -120,28 +120,28 @@ __wt_db_dump(WT_TOC *toc) * later display. Otherwise, dump this item. */ if (dup_ahead) { - WT_RET((__wt_bt_data_copy_to_dbt(db, + WT_RET(__wt_bt_data_copy_to_dbt(db, WT_PAGE_BYTE(ovfl_page), ovfl->len, - &last_key_ovfl))); + &last_key_ovfl)); last_key = &last_key_ovfl; dup_ahead = 0; } else func(WT_PAGE_BYTE(ovfl_page), ovfl->len, stream); - WT_RET((__wt_bt_page_out(db, ovfl_page, 0))); + WT_RET(__wt_bt_page_out(db, ovfl_page, 0)); break; case WT_ITEM_OFFP_INTL: case WT_ITEM_OFFP_LEAF: - WT_RET((__wt_bt_dump_offpage( - db, last_key, item, stream, func))); + WT_RET(__wt_bt_dump_offpage( + db, last_key, item, stream, func)); break; WT_DEFAULT_FORMAT(db); } } addr = page->hdr->nextaddr; - WT_RET((__wt_bt_page_out(db, page, 0))); + WT_RET(__wt_bt_page_out(db, page, 0)); if (addr == WT_ADDR_INVALID) break; } @@ -177,7 +177,7 @@ __wt_bt_dump_offpage(DB *db, DBT *key, WT_ITEM *item, /* Walk down the duplicates tree to the first leaf page. */ for (;;) { - WT_RET((__wt_bt_page_in(db, addr, isleaf, 0, &page))); + WT_RET(__wt_bt_page_in(db, addr, isleaf, 0, &page)); if (isleaf) break; @@ -200,11 +200,11 @@ __wt_bt_dump_offpage(DB *db, DBT *key, WT_ITEM *item, break; case WT_ITEM_DUP_OVFL: ovfl = (WT_ITEM_OVFL *)WT_ITEM_BYTE(item); - WT_ERR((__wt_bt_ovfl_in(db, - ovfl->addr, ovfl->len, &ovfl_page))); + WT_ERR(__wt_bt_ovfl_in(db, + ovfl->addr, ovfl->len, &ovfl_page)); func( WT_PAGE_BYTE(ovfl_page), ovfl->len, stream); - WT_ERR((__wt_bt_page_out(db, ovfl_page, 0))); + WT_ERR(__wt_bt_page_out(db, ovfl_page, 0)); break; WT_DEFAULT_FORMAT(db); } @@ -218,7 +218,7 @@ __wt_bt_dump_offpage(DB *db, DBT *key, WT_ITEM *item, if (addr == WT_ADDR_INVALID) break; - WT_ERR((__wt_bt_page_in(db, addr, 1, 0, &page))); + WT_ERR(__wt_bt_page_in(db, addr, 1, 0, &page)); } if (0) { diff --git a/btree/bt_evict.c b/btree/bt_evict.c index 53482c51792..39ef4f04f09 100644 --- a/btree/bt_evict.c +++ b/btree/bt_evict.c @@ -38,8 +38,8 @@ __wt_cache_open(DB *db) * per MB). */ stoc->hashsize = __wt_prime(env->cachesize * 8); - WT_RET((__wt_calloc(env, - stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh))); + WT_RET(__wt_calloc( + env, stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh)); for (i = 0; i < stoc->hashsize; ++i) TAILQ_INIT(&stoc->hqh[i]); TAILQ_INIT(&stoc->lqh); @@ -79,15 +79,15 @@ __wt_cache_close(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_TRET((__wt_cache_write(stoc, page))); - WT_TRET((__wt_cache_discard(stoc, page))); + WT_TRET(__wt_cache_write(stoc, page)); + WT_TRET(__wt_cache_discard(stoc, page)); } /* There shouldn't be any allocated bytes. */ WT_ASSERT(env, stoc->cache_bytes == 0); /* Close the underlying file handle. */ - WT_TRET((__wt_close(env, idb->fh))); + WT_TRET(__wt_close(env, idb->fh)); idb->fh = NULL; /* Discard buckets. */ @@ -116,7 +116,7 @@ __wt_cache_sync(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } return (0); } @@ -136,8 +136,8 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) break; if (page->ref == 0) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } } return (0); @@ -152,15 +152,17 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) * Clear the memory because code depends on initial values of 0. */ #define WT_PAGE_ALLOC(env, stoc, bytes, page) do { \ - int __ret; \ if ((stoc)->cache_bytes > (env)->cachesize * WT_MEGABYTE) \ - WT_RET((__wt_cache_stoc_lru(stoc, env))); \ - WT_RET((__wt_calloc((env), 1, sizeof(WT_PAGE), &(page)))); \ + WT_RET(__wt_cache_stoc_lru(stoc, env)); \ + WT_RET(__wt_calloc((env), 1, sizeof(WT_PAGE), &(page))); \ + { \ + int __ret; \ if (((__ret) = __wt_calloc( \ (env), 1, (size_t)(bytes), &(page)->hdr)) != 0) { \ __wt_free((env), (page)); \ return ((__ret)); \ } \ + } \ (stoc)->cache_bytes += (bytes); \ WT_STAT_INCR((env)->hstats, CACHE_CLEAN, NULL); \ } while (0) @@ -271,7 +273,7 @@ __wt_cache_in(WT_STOC *stoc, TAILQ_INSERT_HEAD(hashq, page, hq); /* Read the page. */ - WT_ERR((__wt_read(env, idb->fh, offset, bytes, page->hdr))); + WT_ERR(__wt_read(env, idb->fh, offset, bytes, page->hdr)); /* Verify the checksum. */ if (!LF_ISSET(WT_UNFORMATTED)) { @@ -328,8 +330,8 @@ __wt_cache_out(WT_STOC *stoc, WT_PAGE *page, u_int32_t flags) */ if (LF_ISSET(WT_UNFORMATTED)) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } return (0); @@ -365,7 +367,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) WT_STAT_INCR(env->hstats, CACHE_WRITE_EVICT, "dirty pages evicted from the cache"); - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } else WT_STAT_INCR(env->hstats, CACHE_EVICT, "clean pages evicted from the cache"); @@ -391,7 +393,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) bytes_free += page->bytes; /* Discard the page. */ - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_discard(stoc, page)); } while (bytes_free < bytes_need_free); return (0); @@ -419,7 +421,7 @@ __wt_cache_write(WT_STOC *stoc, WT_PAGE *page) hdr->checksum = __wt_cksum(hdr, page->bytes); /* Write, and if successful, clear the modified flag. */ - WT_RET((__wt_write(env, idb->fh, page->offset, page->bytes, hdr))); + WT_RET(__wt_write(env, idb->fh, page->offset, page->bytes, hdr)); F_CLR(page, WT_MODIFIED); diff --git a/btree/bt_misc.c b/btree/bt_misc.c index c3865d8a1e4..044ee87bccb 100644 --- a/btree/bt_misc.c +++ b/btree/bt_misc.c @@ -76,7 +76,7 @@ __wt_bt_data_copy_to_dbt(DB *db, u_int8_t *data, size_t len, DBT *copy) env = db->env; if (copy->data == NULL || copy->data_len < len) { - WT_RET((__wt_realloc(env, copy->data_len, len, ©->data))); + WT_RET(__wt_realloc(env, copy->data_len, len, ©->data)); copy->data_len = len; } memcpy(copy->data, data, copy->size = len); diff --git a/btree/bt_open.c b/btree/bt_open.c index fe011197d38..eb5d491dd42 100644 --- a/btree/bt_open.c +++ b/btree/bt_open.c @@ -24,10 +24,10 @@ __wt_bt_open(DB *db) idb = db->idb; /* Check page size configuration. */ - WT_RET((__wt_bt_vrfy_sizes(db))); + WT_RET(__wt_bt_vrfy_sizes(db)); /* Open the underlying database file. */ - WT_RET((__wt_cache_open(db))); + WT_RET(__wt_cache_open(db)); /* If the file is empty, we're done. */ if (idb->fh->file_size == 0) { @@ -41,15 +41,14 @@ __wt_bt_open(DB *db) * there had better be a description record.) Then, read in the root * page. */ - WT_RET((__wt_bt_desc_read(db))); + WT_RET(__wt_bt_desc_read(db)); /* * The isleaf value tells us how big a page to read. If the tree has * split, the root page is an internal page, otherwise it's a leaf page. */ isleaf = idb->root_addr == WT_ADDR_FIRST_PAGE ? 1 : 0; - WT_RET((__wt_bt_page_in( - db, idb->root_addr, isleaf, 1, &idb->root_page))); + WT_RET(__wt_bt_page_in(db, idb->root_addr, isleaf, 1, &idb->root_page)); return (0); } diff --git a/btree/bt_ovfl.c b/btree/bt_ovfl.c index 5abde562c17..8e2795ecae9 100644 --- a/btree/bt_ovfl.c +++ b/btree/bt_ovfl.c @@ -23,8 +23,8 @@ __wt_bt_ovfl_in(DB *db, u_int32_t addr, u_int32_t len, WT_PAGE **pagep) env = db->env; stoc = db->idb->stoc; - WT_RET((__wt_cache_in( - stoc, WT_ADDR_TO_OFF(db, addr), WT_OVFL_BYTES(db, len), 0, &page))); + WT_RET(__wt_cache_in( + stoc, WT_ADDR_TO_OFF(db, addr), WT_OVFL_BYTES(db, len), 0, &page)); /* Verify the page. */ WT_ASSERT(env, __wt_bt_verify_page(db, page, NULL, NULL) == 0); @@ -47,8 +47,7 @@ __wt_bt_ovfl_write(DB *db, DBT *dbt, u_int32_t *addrp) stoc = db->idb->stoc; /* Allocate a chunk of file space. */ - WT_RET(( - __wt_cache_alloc(stoc, WT_OVFL_BYTES(db, dbt->size), &page))); + WT_RET(__wt_cache_alloc(stoc, WT_OVFL_BYTES(db, dbt->size), &page)); /* Initialize the page and copy the overflow item in. */ page->hdr->type = WT_PAGE_OVFL; @@ -80,7 +79,7 @@ __wt_bt_ovfl_copy(DB *db, WT_ITEM_OVFL *from, WT_ITEM_OVFL *copy) int ret; /* Read in the overflow record. */ - WT_RET((__wt_bt_ovfl_in(db, from->addr, from->len, &ovfl_page))); + WT_RET(__wt_bt_ovfl_in(db, from->addr, from->len, &ovfl_page)); /* * Copy the overflow record to a new location, and set our return @@ -93,7 +92,7 @@ __wt_bt_ovfl_copy(DB *db, WT_ITEM_OVFL *from, WT_ITEM_OVFL *copy) copy->len = from->len; /* Discard the overflow record. */ - WT_TRET((__wt_bt_page_out(db, ovfl_page, 0))); + WT_TRET(__wt_bt_page_out(db, ovfl_page, 0)); return (ret); } @@ -108,12 +107,12 @@ __wt_bt_ovfl_to_dbt(DB *db, WT_ITEM_OVFL *ovfl, DBT *copy) WT_PAGE *ovfl_page; int ret; - WT_RET((__wt_bt_ovfl_in(db, ovfl->addr, ovfl->len, &ovfl_page))); + WT_RET(__wt_bt_ovfl_in(db, ovfl->addr, ovfl->len, &ovfl_page)); ret = __wt_bt_data_copy_to_dbt( db, WT_PAGE_BYTE(ovfl_page), ovfl->len, copy); - WT_TRET((__wt_bt_page_out(db, ovfl_page, 0))); + WT_TRET(__wt_bt_page_out(db, ovfl_page, 0)); return (ret); } @@ -127,20 +126,19 @@ __wt_bt_ovfl_to_indx(DB *db, WT_PAGE *page, WT_INDX *ip) { ENV *env; WT_PAGE *ovfl_page; - int ret; env = db->env; - WT_RET(( - __wt_bt_ovfl_in(db, WT_INDX_OVFL_ADDR(ip), ip->size, &ovfl_page))); + WT_RET( + __wt_bt_ovfl_in(db, WT_INDX_OVFL_ADDR(ip), ip->size, &ovfl_page)); - WT_RET((__wt_calloc(env, ip->size, 1, &ip->data))); + WT_RET(__wt_calloc(env, ip->size, 1, &ip->data)); memcpy(ip->data, WT_PAGE_BYTE(ovfl_page), ip->size); - WT_TRET((__wt_bt_page_out(db, ovfl_page, 0))); + WT_RET(__wt_bt_page_out(db, ovfl_page, 0)); F_SET(ip, WT_ALLOCATED); F_SET(page, WT_ALLOCATED); - return (ret); + return (0); } diff --git a/btree/bt_page.c b/btree/bt_page.c index 8d943046b0e..9a8a6a1c511 100644 --- a/btree/bt_page.c +++ b/btree/bt_page.c @@ -23,7 +23,6 @@ __wt_bt_page_alloc(DB *db, int isleaf, WT_PAGE **pagep) WT_PAGE *page; WT_PAGE_HDR *hdr; WT_STOC *stoc; - int ret; stoc = db->idb->stoc; @@ -209,7 +208,6 @@ __wt_bt_page_inmem_append(DB *db, WT_INDX *indx; WT_ITEM_OVFL *ovfl; u_int32_t n; - int ret; env = db->env; idb = db->idb; diff --git a/btree/bt_read.c b/btree/bt_read.c index 53482c51792..39ef4f04f09 100644 --- a/btree/bt_read.c +++ b/btree/bt_read.c @@ -38,8 +38,8 @@ __wt_cache_open(DB *db) * per MB). */ stoc->hashsize = __wt_prime(env->cachesize * 8); - WT_RET((__wt_calloc(env, - stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh))); + WT_RET(__wt_calloc( + env, stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh)); for (i = 0; i < stoc->hashsize; ++i) TAILQ_INIT(&stoc->hqh[i]); TAILQ_INIT(&stoc->lqh); @@ -79,15 +79,15 @@ __wt_cache_close(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_TRET((__wt_cache_write(stoc, page))); - WT_TRET((__wt_cache_discard(stoc, page))); + WT_TRET(__wt_cache_write(stoc, page)); + WT_TRET(__wt_cache_discard(stoc, page)); } /* There shouldn't be any allocated bytes. */ WT_ASSERT(env, stoc->cache_bytes == 0); /* Close the underlying file handle. */ - WT_TRET((__wt_close(env, idb->fh))); + WT_TRET(__wt_close(env, idb->fh)); idb->fh = NULL; /* Discard buckets. */ @@ -116,7 +116,7 @@ __wt_cache_sync(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } return (0); } @@ -136,8 +136,8 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) break; if (page->ref == 0) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } } return (0); @@ -152,15 +152,17 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) * Clear the memory because code depends on initial values of 0. */ #define WT_PAGE_ALLOC(env, stoc, bytes, page) do { \ - int __ret; \ if ((stoc)->cache_bytes > (env)->cachesize * WT_MEGABYTE) \ - WT_RET((__wt_cache_stoc_lru(stoc, env))); \ - WT_RET((__wt_calloc((env), 1, sizeof(WT_PAGE), &(page)))); \ + WT_RET(__wt_cache_stoc_lru(stoc, env)); \ + WT_RET(__wt_calloc((env), 1, sizeof(WT_PAGE), &(page))); \ + { \ + int __ret; \ if (((__ret) = __wt_calloc( \ (env), 1, (size_t)(bytes), &(page)->hdr)) != 0) { \ __wt_free((env), (page)); \ return ((__ret)); \ } \ + } \ (stoc)->cache_bytes += (bytes); \ WT_STAT_INCR((env)->hstats, CACHE_CLEAN, NULL); \ } while (0) @@ -271,7 +273,7 @@ __wt_cache_in(WT_STOC *stoc, TAILQ_INSERT_HEAD(hashq, page, hq); /* Read the page. */ - WT_ERR((__wt_read(env, idb->fh, offset, bytes, page->hdr))); + WT_ERR(__wt_read(env, idb->fh, offset, bytes, page->hdr)); /* Verify the checksum. */ if (!LF_ISSET(WT_UNFORMATTED)) { @@ -328,8 +330,8 @@ __wt_cache_out(WT_STOC *stoc, WT_PAGE *page, u_int32_t flags) */ if (LF_ISSET(WT_UNFORMATTED)) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } return (0); @@ -365,7 +367,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) WT_STAT_INCR(env->hstats, CACHE_WRITE_EVICT, "dirty pages evicted from the cache"); - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } else WT_STAT_INCR(env->hstats, CACHE_EVICT, "clean pages evicted from the cache"); @@ -391,7 +393,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) bytes_free += page->bytes; /* Discard the page. */ - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_discard(stoc, page)); } while (bytes_free < bytes_need_free); return (0); @@ -419,7 +421,7 @@ __wt_cache_write(WT_STOC *stoc, WT_PAGE *page) hdr->checksum = __wt_cksum(hdr, page->bytes); /* Write, and if successful, clear the modified flag. */ - WT_RET((__wt_write(env, idb->fh, page->offset, page->bytes, hdr))); + WT_RET(__wt_write(env, idb->fh, page->offset, page->bytes, hdr)); F_CLR(page, WT_MODIFIED); diff --git a/btree/bt_reconcile.c b/btree/bt_reconcile.c index 8d943046b0e..9a8a6a1c511 100644 --- a/btree/bt_reconcile.c +++ b/btree/bt_reconcile.c @@ -23,7 +23,6 @@ __wt_bt_page_alloc(DB *db, int isleaf, WT_PAGE **pagep) WT_PAGE *page; WT_PAGE_HDR *hdr; WT_STOC *stoc; - int ret; stoc = db->idb->stoc; @@ -209,7 +208,6 @@ __wt_bt_page_inmem_append(DB *db, WT_INDX *indx; WT_ITEM_OVFL *ovfl; u_int32_t n; - int ret; env = db->env; idb = db->idb; diff --git a/btree/bt_ret.c b/btree/bt_ret.c index ee48d8a6ff5..83242b77ec2 100644 --- a/btree/bt_ret.c +++ b/btree/bt_ret.c @@ -50,10 +50,10 @@ __wt_bt_dbt_return(DB *db, */ if (key_return) { if (ip->data == NULL) - WT_RET((__wt_bt_ovfl_to_indx(db, page, ip))); + WT_RET(__wt_bt_ovfl_to_indx(db, page, ip)); if (callback == NULL) { - WT_RET((__wt_bt_dbt_copyout( - db, key, &idb->key, ip->data, ip->size))); + WT_RET(__wt_bt_dbt_copyout( + db, key, &idb->key, ip->data, ip->size)); } else { key->data = ip->data; key->size = ip->size; @@ -70,9 +70,9 @@ __wt_bt_dbt_return(DB *db, goto overflow; if (callback == NULL) { - WT_RET((__wt_bt_dbt_copyout(db, data, + WT_RET(__wt_bt_dbt_copyout(db, data, &idb->data, WT_ITEM_BYTE(item), - (u_int32_t)WT_ITEM_LEN(item)))); + (u_int32_t)WT_ITEM_LEN(item))); } else { data->data = WT_ITEM_BYTE(item); data->size = (u_int32_t)WT_ITEM_LEN(item); @@ -83,8 +83,8 @@ __wt_bt_dbt_return(DB *db, goto overflow; if (callback == NULL) { - WT_RET((__wt_bt_dbt_copyout(db, data, - &idb->data, ip->data, ip->size))); + WT_RET(__wt_bt_dbt_copyout(db, data, + &idb->data, ip->data, ip->size)); } else { data->data = ip->data; data->size = ip->size; @@ -106,9 +106,9 @@ overflow: /* if (F_ISSET(data, WT_DBT_APPMEM) && data->data_len < ovfl->len) return (WT_TOOSMALL); - WT_RET((__wt_bt_ovfl_to_dbt(db, ovfl, data))); + WT_RET(__wt_bt_ovfl_to_dbt(db, ovfl, data)); } else { - WT_RET((__wt_bt_ovfl_to_dbt(db, ovfl, &idb->data))); + WT_RET(__wt_bt_ovfl_to_dbt(db, ovfl, &idb->data)); data->data = idb->data.data; data->size = idb->data.size; } @@ -140,8 +140,8 @@ __wt_bt_dbt_copyout( */ if (F_ISSET(dbt, WT_DBT_ALLOC)) { if (dbt->data_len < size) { - WT_RET((__wt_realloc( - env, dbt->data_len, size, &dbt->data))); + WT_RET(__wt_realloc( + env, dbt->data_len, size, &dbt->data)); dbt->data_len = size; } } else if (F_ISSET(dbt, WT_DBT_APPMEM)) { @@ -149,8 +149,8 @@ __wt_bt_dbt_copyout( return (WT_TOOSMALL); } else { if (local_dbt->data_len < size) { - WT_RET((__wt_realloc( - env, size, size + 40, &local_dbt->data))); + WT_RET(__wt_realloc( + env, size, size + 40, &local_dbt->data)); local_dbt->data_len = size + 40; } dbt->data = local_dbt->data; diff --git a/btree/bt_rw.c b/btree/bt_rw.c index 53482c51792..39ef4f04f09 100644 --- a/btree/bt_rw.c +++ b/btree/bt_rw.c @@ -38,8 +38,8 @@ __wt_cache_open(DB *db) * per MB). */ stoc->hashsize = __wt_prime(env->cachesize * 8); - WT_RET((__wt_calloc(env, - stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh))); + WT_RET(__wt_calloc( + env, stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh)); for (i = 0; i < stoc->hashsize; ++i) TAILQ_INIT(&stoc->hqh[i]); TAILQ_INIT(&stoc->lqh); @@ -79,15 +79,15 @@ __wt_cache_close(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_TRET((__wt_cache_write(stoc, page))); - WT_TRET((__wt_cache_discard(stoc, page))); + WT_TRET(__wt_cache_write(stoc, page)); + WT_TRET(__wt_cache_discard(stoc, page)); } /* There shouldn't be any allocated bytes. */ WT_ASSERT(env, stoc->cache_bytes == 0); /* Close the underlying file handle. */ - WT_TRET((__wt_close(env, idb->fh))); + WT_TRET(__wt_close(env, idb->fh)); idb->fh = NULL; /* Discard buckets. */ @@ -116,7 +116,7 @@ __wt_cache_sync(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } return (0); } @@ -136,8 +136,8 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) break; if (page->ref == 0) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } } return (0); @@ -152,15 +152,17 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) * Clear the memory because code depends on initial values of 0. */ #define WT_PAGE_ALLOC(env, stoc, bytes, page) do { \ - int __ret; \ if ((stoc)->cache_bytes > (env)->cachesize * WT_MEGABYTE) \ - WT_RET((__wt_cache_stoc_lru(stoc, env))); \ - WT_RET((__wt_calloc((env), 1, sizeof(WT_PAGE), &(page)))); \ + WT_RET(__wt_cache_stoc_lru(stoc, env)); \ + WT_RET(__wt_calloc((env), 1, sizeof(WT_PAGE), &(page))); \ + { \ + int __ret; \ if (((__ret) = __wt_calloc( \ (env), 1, (size_t)(bytes), &(page)->hdr)) != 0) { \ __wt_free((env), (page)); \ return ((__ret)); \ } \ + } \ (stoc)->cache_bytes += (bytes); \ WT_STAT_INCR((env)->hstats, CACHE_CLEAN, NULL); \ } while (0) @@ -271,7 +273,7 @@ __wt_cache_in(WT_STOC *stoc, TAILQ_INSERT_HEAD(hashq, page, hq); /* Read the page. */ - WT_ERR((__wt_read(env, idb->fh, offset, bytes, page->hdr))); + WT_ERR(__wt_read(env, idb->fh, offset, bytes, page->hdr)); /* Verify the checksum. */ if (!LF_ISSET(WT_UNFORMATTED)) { @@ -328,8 +330,8 @@ __wt_cache_out(WT_STOC *stoc, WT_PAGE *page, u_int32_t flags) */ if (LF_ISSET(WT_UNFORMATTED)) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } return (0); @@ -365,7 +367,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) WT_STAT_INCR(env->hstats, CACHE_WRITE_EVICT, "dirty pages evicted from the cache"); - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } else WT_STAT_INCR(env->hstats, CACHE_EVICT, "clean pages evicted from the cache"); @@ -391,7 +393,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) bytes_free += page->bytes; /* Discard the page. */ - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_discard(stoc, page)); } while (bytes_free < bytes_need_free); return (0); @@ -419,7 +421,7 @@ __wt_cache_write(WT_STOC *stoc, WT_PAGE *page) hdr->checksum = __wt_cksum(hdr, page->bytes); /* Write, and if successful, clear the modified flag. */ - WT_RET((__wt_write(env, idb->fh, page->offset, page->bytes, hdr))); + WT_RET(__wt_write(env, idb->fh, page->offset, page->bytes, hdr)); F_CLR(page, WT_MODIFIED); diff --git a/btree/bt_stat.c b/btree/bt_stat.c index 932894b0ec9..8508352b1b3 100644 --- a/btree/bt_stat.c +++ b/btree/bt_stat.c @@ -29,9 +29,9 @@ __wt_bt_stat(DB *db) /* If no root address has been set, it's a one-leaf-page database. */ if (idb->root_addr == WT_ADDR_INVALID) { - WT_RET((__wt_bt_page_in(db, WT_ADDR_FIRST_PAGE, 1, 0, &page))); + WT_RET(__wt_bt_page_in(db, WT_ADDR_FIRST_PAGE, 1, 0, &page)); ret = __wt_bt_stat_page(db, page); - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); return (ret); } @@ -55,7 +55,7 @@ __wt_bt_stat_level(DB *db, u_int32_t addr, int isleaf) for (first = 1; addr != WT_ADDR_INVALID;) { /* Get the next page and stat it. */ - WT_RET((__wt_bt_page_in(db, addr, isleaf, 0, &page))); + WT_RET(__wt_bt_page_in(db, addr, isleaf, 0, &page)); ret = __wt_bt_stat_page(db, page); @@ -74,7 +74,7 @@ __wt_bt_stat_level(DB *db, u_int32_t addr, int isleaf) page, &addr_arg, &isleaf_arg); } - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); if (ret != 0) return (ret); } @@ -174,10 +174,10 @@ __wt_bt_stat_page(DB *db, WT_PAGE *page) case WT_ITEM_OFFP_LEAF: if (hdr->type != WT_PAGE_LEAF) break; - WT_RET((__wt_bt_stat_level(db, + WT_RET(__wt_bt_stat_level(db, ((WT_ITEM_OFFP *)WT_ITEM_BYTE(item))->addr, WT_ITEM_TYPE(item) == - WT_ITEM_OFFP_LEAF ? 1 : 0))); + WT_ITEM_OFFP_LEAF ? 1 : 0)); break; default: break; diff --git a/btree/bt_vrfy.c b/btree/bt_vrfy.c index a49659c76e9..43c15edaf1d 100644 --- a/btree/bt_vrfy.c +++ b/btree/bt_vrfy.c @@ -51,7 +51,7 @@ __wt_bt_verify_int(DB *db, FILE *fp) * Read the database description chunk to get the allocation and * page sizes. */ - WT_RET((__wt_bt_desc_read(db))); + WT_RET(__wt_bt_desc_read(db)); /* * Allocate a bit array, where each bit represents a single allocation @@ -73,14 +73,14 @@ __wt_bt_verify_int(DB *db, FILE *fp) __wt_db_errx(db, "file is too large to verify"); return (WT_ERROR); } - WT_RET((bit_alloc(env, (int)frags, &fragbits))); + WT_RET(bit_alloc(env, (int)frags, &fragbits)); /* If no root address has been set, it's a one-leaf-page database. */ if (idb->root_addr == WT_ADDR_INVALID) { - WT_RET(( - __wt_bt_page_in(db, WT_ADDR_FIRST_PAGE, 1, 0, &page))); + WT_RET( + __wt_bt_page_in(db, WT_ADDR_FIRST_PAGE, 1, 0, &page)); ret = __wt_bt_verify_page(db, page, fragbits, fp); - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); if (ret != 0) goto err; } else { @@ -90,8 +90,8 @@ __wt_bt_verify_int(DB *db, FILE *fp) * level in the DESC structure, so there's no way to know * what the correct level is yet. */ - WT_ERR((__wt_bt_verify_level( - db, idb->root_addr, 0, fragbits, fp))); + WT_ERR(__wt_bt_verify_level( + db, idb->root_addr, 0, fragbits, fp)); } ret = __wt_bt_verify_checkfrag(db, fragbits); @@ -205,10 +205,10 @@ __wt_bt_verify_level( addr != WT_ADDR_INVALID; addr = hdr->nextaddr, prev = page, page = NULL) { /* Get the next page and set the address. */ - WT_ERR((__wt_bt_page_in(db, addr, isleaf, 0, &page))); + WT_ERR(__wt_bt_page_in(db, addr, isleaf, 0, &page)); /* Verify the page. */ - WT_ERR((__wt_bt_verify_page(db, page, fragbits, fp))); + WT_ERR(__wt_bt_verify_page(db, page, fragbits, fp)); /* * If we're walking an internal page, we'll want to descend @@ -241,10 +241,10 @@ __wt_bt_verify_level( * we don't have it already. */ if (page->indx_count == 0) - WT_ERR((__wt_bt_page_inmem(db, page))); + WT_ERR(__wt_bt_page_inmem(db, page)); /* Verify its connections. */ - WT_ERR((__wt_bt_verify_connections(db, page, fragbits))); + WT_ERR(__wt_bt_verify_connections(db, page, fragbits)); if (prev == NULL) continue; @@ -257,10 +257,10 @@ __wt_bt_verify_level( */ prev_indx = prev->indx + (prev->indx_count - 1); if (prev_indx->data == NULL) - WT_ERR((__wt_bt_ovfl_to_indx(db, prev, prev_indx))); + WT_ERR(__wt_bt_ovfl_to_indx(db, prev, prev_indx)); page_indx = page->indx; if (page_indx->data == NULL) - WT_ERR((__wt_bt_ovfl_to_indx(db, page, page_indx))); + WT_ERR(__wt_bt_ovfl_to_indx(db, page, page_indx)); if (func(db, (DBT *)prev_indx, (DBT *)page_indx) >= 0) { __wt_db_errx(db, "the first key on page at addr %lu does not sort " @@ -270,13 +270,13 @@ __wt_bt_verify_level( } /* We're done with the previous page. */ - WT_ERR((__wt_bt_page_out(db, prev, 0))); + WT_ERR(__wt_bt_page_out(db, prev, 0)); } err: if (prev != NULL) - WT_TRET((__wt_bt_page_out(db, prev, 0))); + WT_TRET(__wt_bt_page_out(db, prev, 0)); if (page != NULL) - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); if (ret == 0 && addr_arg != WT_ADDR_INVALID) ret = __wt_bt_verify_level( @@ -356,7 +356,7 @@ __wt_bt_verify_connections(DB *db, WT_PAGE *child, bitstr_t *fragbits) (u_long)addr); return (WT_ERROR); } - WT_RET((__wt_bt_page_in(db, hdr->prntaddr, 0, 1, &parent))); + WT_RET(__wt_bt_page_in(db, hdr->prntaddr, 0, 1, &parent)); /* * Search the parent for the reference to this page -- because we've @@ -415,9 +415,9 @@ __wt_bt_verify_connections(DB *db, WT_PAGE *child, bitstr_t *fragbits) /* The two keys we're going to compare may be overflow keys. */ child_indx = child->indx; if (child_indx->data == NULL) - WT_ERR((__wt_bt_ovfl_to_indx(db, child, child_indx))); + WT_ERR(__wt_bt_ovfl_to_indx(db, child, child_indx)); if (parent_indx->data == NULL) - WT_ERR((__wt_bt_ovfl_to_indx(db, parent, parent_indx))); + WT_ERR(__wt_bt_ovfl_to_indx(db, parent, parent_indx)); /* Compare the parent's key against the child's key. */ if (func(db, (DBT *)child_indx, (DBT *)parent_indx) < 0) { @@ -455,11 +455,11 @@ __wt_bt_verify_connections(DB *db, WT_PAGE *child, bitstr_t *fragbits) } /* Switch for the subsequent page at the parent level. */ - WT_RET((__wt_bt_page_out(db, parent, 0))); + WT_RET(__wt_bt_page_out(db, parent, 0)); if (nextaddr == WT_ADDR_INVALID) parent = NULL; else { - WT_RET((__wt_bt_page_in(db, nextaddr, 0, 1, &parent))); + WT_RET(__wt_bt_page_in(db, nextaddr, 0, 1, &parent)); parent_indx = parent->indx; } } else @@ -469,9 +469,9 @@ __wt_bt_verify_connections(DB *db, WT_PAGE *child, bitstr_t *fragbits) /* The two keys we're going to compare may be overflow keys. */ child_indx = child->indx + (child->indx_count - 1); if (child_indx->data == NULL) - WT_ERR((__wt_bt_ovfl_to_indx(db, child, child_indx))); + WT_ERR(__wt_bt_ovfl_to_indx(db, child, child_indx)); if (parent_indx->data == NULL) - WT_ERR((__wt_bt_ovfl_to_indx(db, parent, parent_indx))); + WT_ERR(__wt_bt_ovfl_to_indx(db, parent, parent_indx)); /* Compare the parent's key against the child's key. */ if (func(db, (DBT *)child_indx, (DBT *)parent_indx) >= 0) { __wt_db_errx(db, @@ -487,7 +487,7 @@ err_set: ret = WT_ERROR; } err: if (parent != NULL) - WT_TRET((__wt_bt_page_out(db, parent, 0))); + WT_TRET(__wt_bt_page_out(db, parent, 0)); return (ret); } @@ -563,11 +563,11 @@ __wt_bt_verify_page(DB *db, WT_PAGE *page, bitstr_t *fragbits, FILE *fp) /* Page 0 has the descriptor record. */ if (addr == WT_ADDR_FIRST_PAGE) - WT_RET((__wt_bt_desc_verify(db, page))); + WT_RET(__wt_bt_desc_verify(db, page)); /* Verify the items on the page. */ if (hdr->type != WT_PAGE_OVFL) - WT_RET((__wt_bt_verify_item(db, page, fragbits, fp))); + WT_RET(__wt_bt_verify_item(db, page, fragbits, fp)); return (0); } @@ -721,18 +721,18 @@ eop: __wt_db_errx(db, case WT_ITEM_KEY_OVFL: case WT_ITEM_DATA_OVFL: case WT_ITEM_DUP_OVFL: - WT_ERR((__wt_bt_verify_ovfl(db, + WT_ERR(__wt_bt_verify_ovfl(db, (WT_ITEM_OVFL *)WT_ITEM_BYTE(item), - fragbits, fp))); + fragbits, fp)); break; case WT_ITEM_OFFP_INTL: case WT_ITEM_OFFP_LEAF: if (hdr->type == WT_PAGE_LEAF) - WT_ERR((__wt_bt_verify_level(db, + WT_ERR(__wt_bt_verify_level(db, ((WT_ITEM_OFFP *) WT_ITEM_BYTE(item))->addr, item_type == WT_ITEM_OFFP_LEAF ? - 1 : 0, fragbits, fp))); + 1 : 0, fragbits, fp)); break; default: break; @@ -758,8 +758,8 @@ eop: __wt_db_errx(db, case WT_ITEM_DUP_OVFL: current->indx = item_num; current->item = ¤t->item_ovfl; - WT_ERR((__wt_bt_ovfl_to_dbt(db, (WT_ITEM_OVFL *) - WT_ITEM_BYTE(item), current->item))); + WT_ERR(__wt_bt_ovfl_to_dbt(db, (WT_ITEM_OVFL *) + WT_ITEM_BYTE(item), current->item)); break; default: break; @@ -829,11 +829,11 @@ __wt_bt_verify_ovfl(DB *db, WT_ITEM_OVFL *ovfl, bitstr_t *fragbits, FILE *fp) WT_PAGE *ovfl_page; int ret; - WT_RET((__wt_bt_ovfl_in(db, ovfl->addr, ovfl->len, &ovfl_page))); + WT_RET(__wt_bt_ovfl_in(db, ovfl->addr, ovfl->len, &ovfl_page)); ret = __wt_bt_verify_page(db, ovfl_page, fragbits, fp); - WT_TRET((__wt_bt_page_out(db, ovfl_page, 0))); + WT_TRET(__wt_bt_page_out(db, ovfl_page, 0)); return (ret); } diff --git a/btree/bt_walk.c b/btree/bt_walk.c index 932894b0ec9..8508352b1b3 100644 --- a/btree/bt_walk.c +++ b/btree/bt_walk.c @@ -29,9 +29,9 @@ __wt_bt_stat(DB *db) /* If no root address has been set, it's a one-leaf-page database. */ if (idb->root_addr == WT_ADDR_INVALID) { - WT_RET((__wt_bt_page_in(db, WT_ADDR_FIRST_PAGE, 1, 0, &page))); + WT_RET(__wt_bt_page_in(db, WT_ADDR_FIRST_PAGE, 1, 0, &page)); ret = __wt_bt_stat_page(db, page); - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); return (ret); } @@ -55,7 +55,7 @@ __wt_bt_stat_level(DB *db, u_int32_t addr, int isleaf) for (first = 1; addr != WT_ADDR_INVALID;) { /* Get the next page and stat it. */ - WT_RET((__wt_bt_page_in(db, addr, isleaf, 0, &page))); + WT_RET(__wt_bt_page_in(db, addr, isleaf, 0, &page)); ret = __wt_bt_stat_page(db, page); @@ -74,7 +74,7 @@ __wt_bt_stat_level(DB *db, u_int32_t addr, int isleaf) page, &addr_arg, &isleaf_arg); } - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); if (ret != 0) return (ret); } @@ -174,10 +174,10 @@ __wt_bt_stat_page(DB *db, WT_PAGE *page) case WT_ITEM_OFFP_LEAF: if (hdr->type != WT_PAGE_LEAF) break; - WT_RET((__wt_bt_stat_level(db, + WT_RET(__wt_bt_stat_level(db, ((WT_ITEM_OFFP *)WT_ITEM_BYTE(item))->addr, WT_ITEM_TYPE(item) == - WT_ITEM_OFFP_LEAF ? 1 : 0))); + WT_ITEM_OFFP_LEAF ? 1 : 0)); break; default: break; diff --git a/btree/c_drain.c b/btree/c_drain.c index 53482c51792..39ef4f04f09 100644 --- a/btree/c_drain.c +++ b/btree/c_drain.c @@ -38,8 +38,8 @@ __wt_cache_open(DB *db) * per MB). */ stoc->hashsize = __wt_prime(env->cachesize * 8); - WT_RET((__wt_calloc(env, - stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh))); + WT_RET(__wt_calloc( + env, stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh)); for (i = 0; i < stoc->hashsize; ++i) TAILQ_INIT(&stoc->hqh[i]); TAILQ_INIT(&stoc->lqh); @@ -79,15 +79,15 @@ __wt_cache_close(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_TRET((__wt_cache_write(stoc, page))); - WT_TRET((__wt_cache_discard(stoc, page))); + WT_TRET(__wt_cache_write(stoc, page)); + WT_TRET(__wt_cache_discard(stoc, page)); } /* There shouldn't be any allocated bytes. */ WT_ASSERT(env, stoc->cache_bytes == 0); /* Close the underlying file handle. */ - WT_TRET((__wt_close(env, idb->fh))); + WT_TRET(__wt_close(env, idb->fh)); idb->fh = NULL; /* Discard buckets. */ @@ -116,7 +116,7 @@ __wt_cache_sync(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } return (0); } @@ -136,8 +136,8 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) break; if (page->ref == 0) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } } return (0); @@ -152,15 +152,17 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) * Clear the memory because code depends on initial values of 0. */ #define WT_PAGE_ALLOC(env, stoc, bytes, page) do { \ - int __ret; \ if ((stoc)->cache_bytes > (env)->cachesize * WT_MEGABYTE) \ - WT_RET((__wt_cache_stoc_lru(stoc, env))); \ - WT_RET((__wt_calloc((env), 1, sizeof(WT_PAGE), &(page)))); \ + WT_RET(__wt_cache_stoc_lru(stoc, env)); \ + WT_RET(__wt_calloc((env), 1, sizeof(WT_PAGE), &(page))); \ + { \ + int __ret; \ if (((__ret) = __wt_calloc( \ (env), 1, (size_t)(bytes), &(page)->hdr)) != 0) { \ __wt_free((env), (page)); \ return ((__ret)); \ } \ + } \ (stoc)->cache_bytes += (bytes); \ WT_STAT_INCR((env)->hstats, CACHE_CLEAN, NULL); \ } while (0) @@ -271,7 +273,7 @@ __wt_cache_in(WT_STOC *stoc, TAILQ_INSERT_HEAD(hashq, page, hq); /* Read the page. */ - WT_ERR((__wt_read(env, idb->fh, offset, bytes, page->hdr))); + WT_ERR(__wt_read(env, idb->fh, offset, bytes, page->hdr)); /* Verify the checksum. */ if (!LF_ISSET(WT_UNFORMATTED)) { @@ -328,8 +330,8 @@ __wt_cache_out(WT_STOC *stoc, WT_PAGE *page, u_int32_t flags) */ if (LF_ISSET(WT_UNFORMATTED)) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } return (0); @@ -365,7 +367,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) WT_STAT_INCR(env->hstats, CACHE_WRITE_EVICT, "dirty pages evicted from the cache"); - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } else WT_STAT_INCR(env->hstats, CACHE_EVICT, "clean pages evicted from the cache"); @@ -391,7 +393,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) bytes_free += page->bytes; /* Discard the page. */ - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_discard(stoc, page)); } while (bytes_free < bytes_need_free); return (0); @@ -419,7 +421,7 @@ __wt_cache_write(WT_STOC *stoc, WT_PAGE *page) hdr->checksum = __wt_cksum(hdr, page->bytes); /* Write, and if successful, clear the modified flag. */ - WT_RET((__wt_write(env, idb->fh, page->offset, page->bytes, hdr))); + WT_RET(__wt_write(env, idb->fh, page->offset, page->bytes, hdr)); F_CLR(page, WT_MODIFIED); diff --git a/btree/c_init.c b/btree/c_init.c index 53482c51792..39ef4f04f09 100644 --- a/btree/c_init.c +++ b/btree/c_init.c @@ -38,8 +38,8 @@ __wt_cache_open(DB *db) * per MB). */ stoc->hashsize = __wt_prime(env->cachesize * 8); - WT_RET((__wt_calloc(env, - stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh))); + WT_RET(__wt_calloc( + env, stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh)); for (i = 0; i < stoc->hashsize; ++i) TAILQ_INIT(&stoc->hqh[i]); TAILQ_INIT(&stoc->lqh); @@ -79,15 +79,15 @@ __wt_cache_close(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_TRET((__wt_cache_write(stoc, page))); - WT_TRET((__wt_cache_discard(stoc, page))); + WT_TRET(__wt_cache_write(stoc, page)); + WT_TRET(__wt_cache_discard(stoc, page)); } /* There shouldn't be any allocated bytes. */ WT_ASSERT(env, stoc->cache_bytes == 0); /* Close the underlying file handle. */ - WT_TRET((__wt_close(env, idb->fh))); + WT_TRET(__wt_close(env, idb->fh)); idb->fh = NULL; /* Discard buckets. */ @@ -116,7 +116,7 @@ __wt_cache_sync(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } return (0); } @@ -136,8 +136,8 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) break; if (page->ref == 0) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } } return (0); @@ -152,15 +152,17 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) * Clear the memory because code depends on initial values of 0. */ #define WT_PAGE_ALLOC(env, stoc, bytes, page) do { \ - int __ret; \ if ((stoc)->cache_bytes > (env)->cachesize * WT_MEGABYTE) \ - WT_RET((__wt_cache_stoc_lru(stoc, env))); \ - WT_RET((__wt_calloc((env), 1, sizeof(WT_PAGE), &(page)))); \ + WT_RET(__wt_cache_stoc_lru(stoc, env)); \ + WT_RET(__wt_calloc((env), 1, sizeof(WT_PAGE), &(page))); \ + { \ + int __ret; \ if (((__ret) = __wt_calloc( \ (env), 1, (size_t)(bytes), &(page)->hdr)) != 0) { \ __wt_free((env), (page)); \ return ((__ret)); \ } \ + } \ (stoc)->cache_bytes += (bytes); \ WT_STAT_INCR((env)->hstats, CACHE_CLEAN, NULL); \ } while (0) @@ -271,7 +273,7 @@ __wt_cache_in(WT_STOC *stoc, TAILQ_INSERT_HEAD(hashq, page, hq); /* Read the page. */ - WT_ERR((__wt_read(env, idb->fh, offset, bytes, page->hdr))); + WT_ERR(__wt_read(env, idb->fh, offset, bytes, page->hdr)); /* Verify the checksum. */ if (!LF_ISSET(WT_UNFORMATTED)) { @@ -328,8 +330,8 @@ __wt_cache_out(WT_STOC *stoc, WT_PAGE *page, u_int32_t flags) */ if (LF_ISSET(WT_UNFORMATTED)) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } return (0); @@ -365,7 +367,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) WT_STAT_INCR(env->hstats, CACHE_WRITE_EVICT, "dirty pages evicted from the cache"); - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } else WT_STAT_INCR(env->hstats, CACHE_EVICT, "clean pages evicted from the cache"); @@ -391,7 +393,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) bytes_free += page->bytes; /* Discard the page. */ - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_discard(stoc, page)); } while (bytes_free < bytes_need_free); return (0); @@ -419,7 +421,7 @@ __wt_cache_write(WT_STOC *stoc, WT_PAGE *page) hdr->checksum = __wt_cksum(hdr, page->bytes); /* Write, and if successful, clear the modified flag. */ - WT_RET((__wt_write(env, idb->fh, page->offset, page->bytes, hdr))); + WT_RET(__wt_write(env, idb->fh, page->offset, page->bytes, hdr)); F_CLR(page, WT_MODIFIED); diff --git a/btree/c_page.c b/btree/c_page.c index 53482c51792..39ef4f04f09 100644 --- a/btree/c_page.c +++ b/btree/c_page.c @@ -38,8 +38,8 @@ __wt_cache_open(DB *db) * per MB). */ stoc->hashsize = __wt_prime(env->cachesize * 8); - WT_RET((__wt_calloc(env, - stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh))); + WT_RET(__wt_calloc( + env, stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh)); for (i = 0; i < stoc->hashsize; ++i) TAILQ_INIT(&stoc->hqh[i]); TAILQ_INIT(&stoc->lqh); @@ -79,15 +79,15 @@ __wt_cache_close(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_TRET((__wt_cache_write(stoc, page))); - WT_TRET((__wt_cache_discard(stoc, page))); + WT_TRET(__wt_cache_write(stoc, page)); + WT_TRET(__wt_cache_discard(stoc, page)); } /* There shouldn't be any allocated bytes. */ WT_ASSERT(env, stoc->cache_bytes == 0); /* Close the underlying file handle. */ - WT_TRET((__wt_close(env, idb->fh))); + WT_TRET(__wt_close(env, idb->fh)); idb->fh = NULL; /* Discard buckets. */ @@ -116,7 +116,7 @@ __wt_cache_sync(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } return (0); } @@ -136,8 +136,8 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) break; if (page->ref == 0) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } } return (0); @@ -152,15 +152,17 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) * Clear the memory because code depends on initial values of 0. */ #define WT_PAGE_ALLOC(env, stoc, bytes, page) do { \ - int __ret; \ if ((stoc)->cache_bytes > (env)->cachesize * WT_MEGABYTE) \ - WT_RET((__wt_cache_stoc_lru(stoc, env))); \ - WT_RET((__wt_calloc((env), 1, sizeof(WT_PAGE), &(page)))); \ + WT_RET(__wt_cache_stoc_lru(stoc, env)); \ + WT_RET(__wt_calloc((env), 1, sizeof(WT_PAGE), &(page))); \ + { \ + int __ret; \ if (((__ret) = __wt_calloc( \ (env), 1, (size_t)(bytes), &(page)->hdr)) != 0) { \ __wt_free((env), (page)); \ return ((__ret)); \ } \ + } \ (stoc)->cache_bytes += (bytes); \ WT_STAT_INCR((env)->hstats, CACHE_CLEAN, NULL); \ } while (0) @@ -271,7 +273,7 @@ __wt_cache_in(WT_STOC *stoc, TAILQ_INSERT_HEAD(hashq, page, hq); /* Read the page. */ - WT_ERR((__wt_read(env, idb->fh, offset, bytes, page->hdr))); + WT_ERR(__wt_read(env, idb->fh, offset, bytes, page->hdr)); /* Verify the checksum. */ if (!LF_ISSET(WT_UNFORMATTED)) { @@ -328,8 +330,8 @@ __wt_cache_out(WT_STOC *stoc, WT_PAGE *page, u_int32_t flags) */ if (LF_ISSET(WT_UNFORMATTED)) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } return (0); @@ -365,7 +367,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) WT_STAT_INCR(env->hstats, CACHE_WRITE_EVICT, "dirty pages evicted from the cache"); - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } else WT_STAT_INCR(env->hstats, CACHE_EVICT, "clean pages evicted from the cache"); @@ -391,7 +393,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) bytes_free += page->bytes; /* Discard the page. */ - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_discard(stoc, page)); } while (bytes_free < bytes_need_free); return (0); @@ -419,7 +421,7 @@ __wt_cache_write(WT_STOC *stoc, WT_PAGE *page) hdr->checksum = __wt_cksum(hdr, page->bytes); /* Write, and if successful, clear the modified flag. */ - WT_RET((__wt_write(env, idb->fh, page->offset, page->bytes, hdr))); + WT_RET(__wt_write(env, idb->fh, page->offset, page->bytes, hdr)); F_CLR(page, WT_MODIFIED); diff --git a/btree/c_read.c b/btree/c_read.c index 53482c51792..39ef4f04f09 100644 --- a/btree/c_read.c +++ b/btree/c_read.c @@ -38,8 +38,8 @@ __wt_cache_open(DB *db) * per MB). */ stoc->hashsize = __wt_prime(env->cachesize * 8); - WT_RET((__wt_calloc(env, - stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh))); + WT_RET(__wt_calloc( + env, stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh)); for (i = 0; i < stoc->hashsize; ++i) TAILQ_INIT(&stoc->hqh[i]); TAILQ_INIT(&stoc->lqh); @@ -79,15 +79,15 @@ __wt_cache_close(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_TRET((__wt_cache_write(stoc, page))); - WT_TRET((__wt_cache_discard(stoc, page))); + WT_TRET(__wt_cache_write(stoc, page)); + WT_TRET(__wt_cache_discard(stoc, page)); } /* There shouldn't be any allocated bytes. */ WT_ASSERT(env, stoc->cache_bytes == 0); /* Close the underlying file handle. */ - WT_TRET((__wt_close(env, idb->fh))); + WT_TRET(__wt_close(env, idb->fh)); idb->fh = NULL; /* Discard buckets. */ @@ -116,7 +116,7 @@ __wt_cache_sync(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } return (0); } @@ -136,8 +136,8 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) break; if (page->ref == 0) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } } return (0); @@ -152,15 +152,17 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) * Clear the memory because code depends on initial values of 0. */ #define WT_PAGE_ALLOC(env, stoc, bytes, page) do { \ - int __ret; \ if ((stoc)->cache_bytes > (env)->cachesize * WT_MEGABYTE) \ - WT_RET((__wt_cache_stoc_lru(stoc, env))); \ - WT_RET((__wt_calloc((env), 1, sizeof(WT_PAGE), &(page)))); \ + WT_RET(__wt_cache_stoc_lru(stoc, env)); \ + WT_RET(__wt_calloc((env), 1, sizeof(WT_PAGE), &(page))); \ + { \ + int __ret; \ if (((__ret) = __wt_calloc( \ (env), 1, (size_t)(bytes), &(page)->hdr)) != 0) { \ __wt_free((env), (page)); \ return ((__ret)); \ } \ + } \ (stoc)->cache_bytes += (bytes); \ WT_STAT_INCR((env)->hstats, CACHE_CLEAN, NULL); \ } while (0) @@ -271,7 +273,7 @@ __wt_cache_in(WT_STOC *stoc, TAILQ_INSERT_HEAD(hashq, page, hq); /* Read the page. */ - WT_ERR((__wt_read(env, idb->fh, offset, bytes, page->hdr))); + WT_ERR(__wt_read(env, idb->fh, offset, bytes, page->hdr)); /* Verify the checksum. */ if (!LF_ISSET(WT_UNFORMATTED)) { @@ -328,8 +330,8 @@ __wt_cache_out(WT_STOC *stoc, WT_PAGE *page, u_int32_t flags) */ if (LF_ISSET(WT_UNFORMATTED)) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } return (0); @@ -365,7 +367,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) WT_STAT_INCR(env->hstats, CACHE_WRITE_EVICT, "dirty pages evicted from the cache"); - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } else WT_STAT_INCR(env->hstats, CACHE_EVICT, "clean pages evicted from the cache"); @@ -391,7 +393,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) bytes_free += page->bytes; /* Discard the page. */ - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_discard(stoc, page)); } while (bytes_free < bytes_need_free); return (0); @@ -419,7 +421,7 @@ __wt_cache_write(WT_STOC *stoc, WT_PAGE *page) hdr->checksum = __wt_cksum(hdr, page->bytes); /* Write, and if successful, clear the modified flag. */ - WT_RET((__wt_write(env, idb->fh, page->offset, page->bytes, hdr))); + WT_RET(__wt_write(env, idb->fh, page->offset, page->bytes, hdr)); F_CLR(page, WT_MODIFIED); diff --git a/btree/c_server.c b/btree/c_server.c index 53482c51792..39ef4f04f09 100644 --- a/btree/c_server.c +++ b/btree/c_server.c @@ -38,8 +38,8 @@ __wt_cache_open(DB *db) * per MB). */ stoc->hashsize = __wt_prime(env->cachesize * 8); - WT_RET((__wt_calloc(env, - stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh))); + WT_RET(__wt_calloc( + env, stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh)); for (i = 0; i < stoc->hashsize; ++i) TAILQ_INIT(&stoc->hqh[i]); TAILQ_INIT(&stoc->lqh); @@ -79,15 +79,15 @@ __wt_cache_close(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_TRET((__wt_cache_write(stoc, page))); - WT_TRET((__wt_cache_discard(stoc, page))); + WT_TRET(__wt_cache_write(stoc, page)); + WT_TRET(__wt_cache_discard(stoc, page)); } /* There shouldn't be any allocated bytes. */ WT_ASSERT(env, stoc->cache_bytes == 0); /* Close the underlying file handle. */ - WT_TRET((__wt_close(env, idb->fh))); + WT_TRET(__wt_close(env, idb->fh)); idb->fh = NULL; /* Discard buckets. */ @@ -116,7 +116,7 @@ __wt_cache_sync(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } return (0); } @@ -136,8 +136,8 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) break; if (page->ref == 0) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } } return (0); @@ -152,15 +152,17 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) * Clear the memory because code depends on initial values of 0. */ #define WT_PAGE_ALLOC(env, stoc, bytes, page) do { \ - int __ret; \ if ((stoc)->cache_bytes > (env)->cachesize * WT_MEGABYTE) \ - WT_RET((__wt_cache_stoc_lru(stoc, env))); \ - WT_RET((__wt_calloc((env), 1, sizeof(WT_PAGE), &(page)))); \ + WT_RET(__wt_cache_stoc_lru(stoc, env)); \ + WT_RET(__wt_calloc((env), 1, sizeof(WT_PAGE), &(page))); \ + { \ + int __ret; \ if (((__ret) = __wt_calloc( \ (env), 1, (size_t)(bytes), &(page)->hdr)) != 0) { \ __wt_free((env), (page)); \ return ((__ret)); \ } \ + } \ (stoc)->cache_bytes += (bytes); \ WT_STAT_INCR((env)->hstats, CACHE_CLEAN, NULL); \ } while (0) @@ -271,7 +273,7 @@ __wt_cache_in(WT_STOC *stoc, TAILQ_INSERT_HEAD(hashq, page, hq); /* Read the page. */ - WT_ERR((__wt_read(env, idb->fh, offset, bytes, page->hdr))); + WT_ERR(__wt_read(env, idb->fh, offset, bytes, page->hdr)); /* Verify the checksum. */ if (!LF_ISSET(WT_UNFORMATTED)) { @@ -328,8 +330,8 @@ __wt_cache_out(WT_STOC *stoc, WT_PAGE *page, u_int32_t flags) */ if (LF_ISSET(WT_UNFORMATTED)) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } return (0); @@ -365,7 +367,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) WT_STAT_INCR(env->hstats, CACHE_WRITE_EVICT, "dirty pages evicted from the cache"); - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } else WT_STAT_INCR(env->hstats, CACHE_EVICT, "clean pages evicted from the cache"); @@ -391,7 +393,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) bytes_free += page->bytes; /* Discard the page. */ - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_discard(stoc, page)); } while (bytes_free < bytes_need_free); return (0); @@ -419,7 +421,7 @@ __wt_cache_write(WT_STOC *stoc, WT_PAGE *page) hdr->checksum = __wt_cksum(hdr, page->bytes); /* Write, and if successful, clear the modified flag. */ - WT_RET((__wt_write(env, idb->fh, page->offset, page->bytes, hdr))); + WT_RET(__wt_write(env, idb->fh, page->offset, page->bytes, hdr)); F_CLR(page, WT_MODIFIED); diff --git a/btree/c_sync.c b/btree/c_sync.c index 53482c51792..39ef4f04f09 100644 --- a/btree/c_sync.c +++ b/btree/c_sync.c @@ -38,8 +38,8 @@ __wt_cache_open(DB *db) * per MB). */ stoc->hashsize = __wt_prime(env->cachesize * 8); - WT_RET((__wt_calloc(env, - stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh))); + WT_RET(__wt_calloc( + env, stoc->hashsize, sizeof(stoc->hqh[0]), &stoc->hqh)); for (i = 0; i < stoc->hashsize; ++i) TAILQ_INIT(&stoc->hqh[i]); TAILQ_INIT(&stoc->lqh); @@ -79,15 +79,15 @@ __wt_cache_close(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_TRET((__wt_cache_write(stoc, page))); - WT_TRET((__wt_cache_discard(stoc, page))); + WT_TRET(__wt_cache_write(stoc, page)); + WT_TRET(__wt_cache_discard(stoc, page)); } /* There shouldn't be any allocated bytes. */ WT_ASSERT(env, stoc->cache_bytes == 0); /* Close the underlying file handle. */ - WT_TRET((__wt_close(env, idb->fh))); + WT_TRET(__wt_close(env, idb->fh)); idb->fh = NULL; /* Discard buckets. */ @@ -116,7 +116,7 @@ __wt_cache_sync(DB *db) WT_ASSERT(env, page->ref == 0); if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } return (0); } @@ -136,8 +136,8 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) break; if (page->ref == 0) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } } return (0); @@ -152,15 +152,17 @@ __wt_cache_stoc_lru(WT_STOC *stoc, ENV *env) * Clear the memory because code depends on initial values of 0. */ #define WT_PAGE_ALLOC(env, stoc, bytes, page) do { \ - int __ret; \ if ((stoc)->cache_bytes > (env)->cachesize * WT_MEGABYTE) \ - WT_RET((__wt_cache_stoc_lru(stoc, env))); \ - WT_RET((__wt_calloc((env), 1, sizeof(WT_PAGE), &(page)))); \ + WT_RET(__wt_cache_stoc_lru(stoc, env)); \ + WT_RET(__wt_calloc((env), 1, sizeof(WT_PAGE), &(page))); \ + { \ + int __ret; \ if (((__ret) = __wt_calloc( \ (env), 1, (size_t)(bytes), &(page)->hdr)) != 0) { \ __wt_free((env), (page)); \ return ((__ret)); \ } \ + } \ (stoc)->cache_bytes += (bytes); \ WT_STAT_INCR((env)->hstats, CACHE_CLEAN, NULL); \ } while (0) @@ -271,7 +273,7 @@ __wt_cache_in(WT_STOC *stoc, TAILQ_INSERT_HEAD(hashq, page, hq); /* Read the page. */ - WT_ERR((__wt_read(env, idb->fh, offset, bytes, page->hdr))); + WT_ERR(__wt_read(env, idb->fh, offset, bytes, page->hdr)); /* Verify the checksum. */ if (!LF_ISSET(WT_UNFORMATTED)) { @@ -328,8 +330,8 @@ __wt_cache_out(WT_STOC *stoc, WT_PAGE *page, u_int32_t flags) */ if (LF_ISSET(WT_UNFORMATTED)) { if (F_ISSET(page, WT_MODIFIED)) - WT_RET((__wt_cache_write(stoc, page))); - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); + WT_RET(__wt_cache_discard(stoc, page)); } return (0); @@ -365,7 +367,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) WT_STAT_INCR(env->hstats, CACHE_WRITE_EVICT, "dirty pages evicted from the cache"); - WT_RET((__wt_cache_write(stoc, page))); + WT_RET(__wt_cache_write(stoc, page)); } else WT_STAT_INCR(env->hstats, CACHE_EVICT, "clean pages evicted from the cache"); @@ -391,7 +393,7 @@ __wt_cache_clean(WT_STOC *stoc, u_int32_t bytes, WT_PAGE **pagep) bytes_free += page->bytes; /* Discard the page. */ - WT_RET((__wt_cache_discard(stoc, page))); + WT_RET(__wt_cache_discard(stoc, page)); } while (bytes_free < bytes_need_free); return (0); @@ -419,7 +421,7 @@ __wt_cache_write(WT_STOC *stoc, WT_PAGE *page) hdr->checksum = __wt_cksum(hdr, page->bytes); /* Write, and if successful, clear the modified flag. */ - WT_RET((__wt_write(env, idb->fh, page->offset, page->bytes, hdr))); + WT_RET(__wt_write(env, idb->fh, page->offset, page->bytes, hdr)); F_CLR(page, WT_MODIFIED); diff --git a/btree/col_get.c b/btree/col_get.c index 000de1c6b1c..58643cad35d 100644 --- a/btree/col_get.c +++ b/btree/col_get.c @@ -35,7 +35,7 @@ __wt_db_get(WT_TOC *toc) WT_DB_FCHK(db, "Db.get", flags, WT_APIMASK_DB_GET); /* Search the primary btree for the key. */ - WT_RET((__wt_bt_search(db, key, &page, &indx))); + WT_RET(__wt_bt_search(db, key, &page, &indx)); /* * The Db.get method can only return single key/data pairs. @@ -52,7 +52,7 @@ __wt_db_get(WT_TOC *toc) /* Discard any page other than the root page, which remains pinned. */ if (page != idb->root_page) - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); return (ret); @@ -81,7 +81,7 @@ __wt_db_get_recno(WT_TOC *toc) WT_DB_FCHK(db, "Db.get_recno", flags, WT_APIMASK_DB_GET_RECNO); /* Search the primary btree for the key. */ - WT_RET((__wt_bt_search_recno(db, recno, &page, &indx))); + WT_RET(__wt_bt_search_recno(db, recno, &page, &indx)); /* * The Db.get_recno method can only return single key/data pairs. @@ -98,7 +98,7 @@ __wt_db_get_recno(WT_TOC *toc) /* Discard any page other than the root page, which remains pinned. */ if (page != idb->root_page) - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); return (ret); } @@ -140,7 +140,7 @@ __wt_bt_search(DB *db, DBT *key, WT_PAGE **pagep, WT_INDX **indxp) */ ip = page->indx + indx; if (ip->data == NULL) - WT_ERR((__wt_bt_ovfl_to_indx(db, page, ip))); + WT_ERR(__wt_bt_ovfl_to_indx(db, page, ip)); /* * If we're about to compare an application key with @@ -195,7 +195,7 @@ __wt_bt_search(DB *db, DBT *key, WT_PAGE **pagep, WT_INDX **indxp) /* We're done with the page. */ if (put_page) - WT_RET((__wt_bt_page_out(db, page, 0))); + WT_RET(__wt_bt_page_out(db, page, 0)); /* * Failed to match on a leaf page -- we're done, return the @@ -206,7 +206,7 @@ __wt_bt_search(DB *db, DBT *key, WT_PAGE **pagep, WT_INDX **indxp) isleaf = next_isleaf; /* Get the next page. */ - WT_RET((__wt_bt_page_in(db, addr, isleaf, 1, &page))); + WT_RET(__wt_bt_page_in(db, addr, isleaf, 1, &page)); } /* NOTREACHED */ @@ -228,7 +228,7 @@ __wt_bt_search_recno(DB *db, u_int64_t recno, WT_PAGE **pagep, WT_INDX **indxp) WT_PAGE *page; u_int64_t total; u_int32_t addr, i; - int isleaf, next_isleaf, put_page, ret; + int isleaf, next_isleaf, put_page; idb = db->idb; @@ -265,12 +265,12 @@ __wt_bt_search_recno(DB *db, u_int64_t recno, WT_PAGE **pagep, WT_INDX **indxp) /* We're done with the page. */ if (put_page) - WT_RET((__wt_bt_page_out(db, page, 0))); + WT_RET(__wt_bt_page_out(db, page, 0)); isleaf = next_isleaf; /* Get the next page. */ - WT_RET((__wt_bt_page_in(db, addr, isleaf, 1, &page))); + WT_RET(__wt_bt_page_in(db, addr, isleaf, 1, &page)); } /* Discard any page we've read other than the root page. */ diff --git a/btree/col_srch.c b/btree/col_srch.c index 000de1c6b1c..58643cad35d 100644 --- a/btree/col_srch.c +++ b/btree/col_srch.c @@ -35,7 +35,7 @@ __wt_db_get(WT_TOC *toc) WT_DB_FCHK(db, "Db.get", flags, WT_APIMASK_DB_GET); /* Search the primary btree for the key. */ - WT_RET((__wt_bt_search(db, key, &page, &indx))); + WT_RET(__wt_bt_search(db, key, &page, &indx)); /* * The Db.get method can only return single key/data pairs. @@ -52,7 +52,7 @@ __wt_db_get(WT_TOC *toc) /* Discard any page other than the root page, which remains pinned. */ if (page != idb->root_page) - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); return (ret); @@ -81,7 +81,7 @@ __wt_db_get_recno(WT_TOC *toc) WT_DB_FCHK(db, "Db.get_recno", flags, WT_APIMASK_DB_GET_RECNO); /* Search the primary btree for the key. */ - WT_RET((__wt_bt_search_recno(db, recno, &page, &indx))); + WT_RET(__wt_bt_search_recno(db, recno, &page, &indx)); /* * The Db.get_recno method can only return single key/data pairs. @@ -98,7 +98,7 @@ __wt_db_get_recno(WT_TOC *toc) /* Discard any page other than the root page, which remains pinned. */ if (page != idb->root_page) - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); return (ret); } @@ -140,7 +140,7 @@ __wt_bt_search(DB *db, DBT *key, WT_PAGE **pagep, WT_INDX **indxp) */ ip = page->indx + indx; if (ip->data == NULL) - WT_ERR((__wt_bt_ovfl_to_indx(db, page, ip))); + WT_ERR(__wt_bt_ovfl_to_indx(db, page, ip)); /* * If we're about to compare an application key with @@ -195,7 +195,7 @@ __wt_bt_search(DB *db, DBT *key, WT_PAGE **pagep, WT_INDX **indxp) /* We're done with the page. */ if (put_page) - WT_RET((__wt_bt_page_out(db, page, 0))); + WT_RET(__wt_bt_page_out(db, page, 0)); /* * Failed to match on a leaf page -- we're done, return the @@ -206,7 +206,7 @@ __wt_bt_search(DB *db, DBT *key, WT_PAGE **pagep, WT_INDX **indxp) isleaf = next_isleaf; /* Get the next page. */ - WT_RET((__wt_bt_page_in(db, addr, isleaf, 1, &page))); + WT_RET(__wt_bt_page_in(db, addr, isleaf, 1, &page)); } /* NOTREACHED */ @@ -228,7 +228,7 @@ __wt_bt_search_recno(DB *db, u_int64_t recno, WT_PAGE **pagep, WT_INDX **indxp) WT_PAGE *page; u_int64_t total; u_int32_t addr, i; - int isleaf, next_isleaf, put_page, ret; + int isleaf, next_isleaf, put_page; idb = db->idb; @@ -265,12 +265,12 @@ __wt_bt_search_recno(DB *db, u_int64_t recno, WT_PAGE **pagep, WT_INDX **indxp) /* We're done with the page. */ if (put_page) - WT_RET((__wt_bt_page_out(db, page, 0))); + WT_RET(__wt_bt_page_out(db, page, 0)); isleaf = next_isleaf; /* Get the next page. */ - WT_RET((__wt_bt_page_in(db, addr, isleaf, 1, &page))); + WT_RET(__wt_bt_page_in(db, addr, isleaf, 1, &page)); } /* Discard any page we've read other than the root page. */ diff --git a/btree/row_get.c b/btree/row_get.c index 000de1c6b1c..58643cad35d 100644 --- a/btree/row_get.c +++ b/btree/row_get.c @@ -35,7 +35,7 @@ __wt_db_get(WT_TOC *toc) WT_DB_FCHK(db, "Db.get", flags, WT_APIMASK_DB_GET); /* Search the primary btree for the key. */ - WT_RET((__wt_bt_search(db, key, &page, &indx))); + WT_RET(__wt_bt_search(db, key, &page, &indx)); /* * The Db.get method can only return single key/data pairs. @@ -52,7 +52,7 @@ __wt_db_get(WT_TOC *toc) /* Discard any page other than the root page, which remains pinned. */ if (page != idb->root_page) - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); return (ret); @@ -81,7 +81,7 @@ __wt_db_get_recno(WT_TOC *toc) WT_DB_FCHK(db, "Db.get_recno", flags, WT_APIMASK_DB_GET_RECNO); /* Search the primary btree for the key. */ - WT_RET((__wt_bt_search_recno(db, recno, &page, &indx))); + WT_RET(__wt_bt_search_recno(db, recno, &page, &indx)); /* * The Db.get_recno method can only return single key/data pairs. @@ -98,7 +98,7 @@ __wt_db_get_recno(WT_TOC *toc) /* Discard any page other than the root page, which remains pinned. */ if (page != idb->root_page) - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); return (ret); } @@ -140,7 +140,7 @@ __wt_bt_search(DB *db, DBT *key, WT_PAGE **pagep, WT_INDX **indxp) */ ip = page->indx + indx; if (ip->data == NULL) - WT_ERR((__wt_bt_ovfl_to_indx(db, page, ip))); + WT_ERR(__wt_bt_ovfl_to_indx(db, page, ip)); /* * If we're about to compare an application key with @@ -195,7 +195,7 @@ __wt_bt_search(DB *db, DBT *key, WT_PAGE **pagep, WT_INDX **indxp) /* We're done with the page. */ if (put_page) - WT_RET((__wt_bt_page_out(db, page, 0))); + WT_RET(__wt_bt_page_out(db, page, 0)); /* * Failed to match on a leaf page -- we're done, return the @@ -206,7 +206,7 @@ __wt_bt_search(DB *db, DBT *key, WT_PAGE **pagep, WT_INDX **indxp) isleaf = next_isleaf; /* Get the next page. */ - WT_RET((__wt_bt_page_in(db, addr, isleaf, 1, &page))); + WT_RET(__wt_bt_page_in(db, addr, isleaf, 1, &page)); } /* NOTREACHED */ @@ -228,7 +228,7 @@ __wt_bt_search_recno(DB *db, u_int64_t recno, WT_PAGE **pagep, WT_INDX **indxp) WT_PAGE *page; u_int64_t total; u_int32_t addr, i; - int isleaf, next_isleaf, put_page, ret; + int isleaf, next_isleaf, put_page; idb = db->idb; @@ -265,12 +265,12 @@ __wt_bt_search_recno(DB *db, u_int64_t recno, WT_PAGE **pagep, WT_INDX **indxp) /* We're done with the page. */ if (put_page) - WT_RET((__wt_bt_page_out(db, page, 0))); + WT_RET(__wt_bt_page_out(db, page, 0)); isleaf = next_isleaf; /* Get the next page. */ - WT_RET((__wt_bt_page_in(db, addr, isleaf, 1, &page))); + WT_RET(__wt_bt_page_in(db, addr, isleaf, 1, &page)); } /* Discard any page we've read other than the root page. */ diff --git a/btree/row_srch.c b/btree/row_srch.c index 000de1c6b1c..58643cad35d 100644 --- a/btree/row_srch.c +++ b/btree/row_srch.c @@ -35,7 +35,7 @@ __wt_db_get(WT_TOC *toc) WT_DB_FCHK(db, "Db.get", flags, WT_APIMASK_DB_GET); /* Search the primary btree for the key. */ - WT_RET((__wt_bt_search(db, key, &page, &indx))); + WT_RET(__wt_bt_search(db, key, &page, &indx)); /* * The Db.get method can only return single key/data pairs. @@ -52,7 +52,7 @@ __wt_db_get(WT_TOC *toc) /* Discard any page other than the root page, which remains pinned. */ if (page != idb->root_page) - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); return (ret); @@ -81,7 +81,7 @@ __wt_db_get_recno(WT_TOC *toc) WT_DB_FCHK(db, "Db.get_recno", flags, WT_APIMASK_DB_GET_RECNO); /* Search the primary btree for the key. */ - WT_RET((__wt_bt_search_recno(db, recno, &page, &indx))); + WT_RET(__wt_bt_search_recno(db, recno, &page, &indx)); /* * The Db.get_recno method can only return single key/data pairs. @@ -98,7 +98,7 @@ __wt_db_get_recno(WT_TOC *toc) /* Discard any page other than the root page, which remains pinned. */ if (page != idb->root_page) - WT_TRET((__wt_bt_page_out(db, page, 0))); + WT_TRET(__wt_bt_page_out(db, page, 0)); return (ret); } @@ -140,7 +140,7 @@ __wt_bt_search(DB *db, DBT *key, WT_PAGE **pagep, WT_INDX **indxp) */ ip = page->indx + indx; if (ip->data == NULL) - WT_ERR((__wt_bt_ovfl_to_indx(db, page, ip))); + WT_ERR(__wt_bt_ovfl_to_indx(db, page, ip)); /* * If we're about to compare an application key with @@ -195,7 +195,7 @@ __wt_bt_search(DB *db, DBT *key, WT_PAGE **pagep, WT_INDX **indxp) /* We're done with the page. */ if (put_page) - WT_RET((__wt_bt_page_out(db, page, 0))); + WT_RET(__wt_bt_page_out(db, page, 0)); /* * Failed to match on a leaf page -- we're done, return the @@ -206,7 +206,7 @@ __wt_bt_search(DB *db, DBT *key, WT_PAGE **pagep, WT_INDX **indxp) isleaf = next_isleaf; /* Get the next page. */ - WT_RET((__wt_bt_page_in(db, addr, isleaf, 1, &page))); + WT_RET(__wt_bt_page_in(db, addr, isleaf, 1, &page)); } /* NOTREACHED */ @@ -228,7 +228,7 @@ __wt_bt_search_recno(DB *db, u_int64_t recno, WT_PAGE **pagep, WT_INDX **indxp) WT_PAGE *page; u_int64_t total; u_int32_t addr, i; - int isleaf, next_isleaf, put_page, ret; + int isleaf, next_isleaf, put_page; idb = db->idb; @@ -265,12 +265,12 @@ __wt_bt_search_recno(DB *db, u_int64_t recno, WT_PAGE **pagep, WT_INDX **indxp) /* We're done with the page. */ if (put_page) - WT_RET((__wt_bt_page_out(db, page, 0))); + WT_RET(__wt_bt_page_out(db, page, 0)); isleaf = next_isleaf; /* Get the next page. */ - WT_RET((__wt_bt_page_in(db, addr, isleaf, 1, &page))); + WT_RET(__wt_bt_page_in(db, addr, isleaf, 1, &page)); } /* Discard any page we've read other than the root page. */ diff --git a/db/db_close.c b/db/db_close.c index 05267ea92ed..dd15afb1e70 100644 --- a/db/db_close.c +++ b/db/db_close.c @@ -30,10 +30,10 @@ __wt_db_close(WT_TOC *toc) WT_DB_FCHK_NOTFATAL(db, "Db.close", flags, WT_APIMASK_DB_CLOSE, ret); /* Close the underlying Btree. */ - WT_TRET((__wt_bt_close(db))); + WT_TRET(__wt_bt_close(db)); /* Discard the cache. */ - WT_TRET((__wt_cache_close(db))); + WT_TRET(__wt_cache_close(db)); /* Discard the server thread. */ if (!F_ISSET(ienv, WT_SINGLE_THREADED)) { @@ -46,7 +46,7 @@ __wt_db_close(WT_TOC *toc) TAILQ_REMOVE(&env->dbqh, db, q); /* Re-cycle the underlying IDB structure. */ - WT_TRET((__wt_idb_destroy(db, 1))); + WT_TRET(__wt_idb_destroy(db, 1)); /* * Reset the methods that are permitted. diff --git a/db/db_handle.c b/db/db_handle.c index ebaa3c76e9a..5cc22e2db04 100644 --- a/db/db_handle.c +++ b/db/db_handle.c @@ -31,8 +31,8 @@ __wt_env_db_create(WT_TOC *toc) WT_ENV_FCHK(env, "Env.db_create", flags, WT_APIMASK_WT_DB_CREATE); /* Create the DB and IDB structures. */ - WT_ERR((__wt_calloc(env, 1, sizeof(DB), &db))); - WT_ERR((__wt_calloc(env, 1, sizeof(IDB), &idb))); + WT_ERR(__wt_calloc(env, 1, sizeof(DB), &db)); + WT_ERR(__wt_calloc(env, 1, sizeof(IDB), &idb)); /* Connect everything together. */ toc->db = db; @@ -42,8 +42,8 @@ __wt_env_db_create(WT_TOC *toc) db->ienv = env->ienv; /* Configure the DB and the IDB. */ - WT_ERR((__wt_db_config_default(db))); - WT_ERR((__wt_idb_config_default(db))); + WT_ERR(__wt_db_config_default(db)); + WT_ERR(__wt_idb_config_default(db)); /* Insert the database on the environment's list. */ TAILQ_INSERT_TAIL(&env->dbqh, db, q); @@ -86,7 +86,7 @@ __wt_db_destroy_int(WT_TOC *toc, u_int32_t flags) db, "Db.destroy", flags, WT_APIMASK_DB_DESTROY, ret); /* Discard the underlying IDB structure. */ - WT_TRET((__wt_idb_destroy(db, 0))); + WT_TRET(__wt_idb_destroy(db, 0)); /* Free any allocated memory. */ WT_FREE_AND_CLEAR(env, db->hstats); @@ -115,8 +115,8 @@ __wt_db_config_default(DB *db) db->btree_compare = db->btree_dup_compare = __wt_bt_lex_compare; - WT_RET((__wt_stat_alloc_db_hstats(env, &db->hstats))); - WT_RET((__wt_stat_alloc_db_dstats(env, &db->dstats))); + WT_RET(__wt_stat_alloc_db_hstats(env, &db->hstats)); + WT_RET(__wt_stat_alloc_db_dstats(env, &db->dstats)); return (0); } @@ -159,7 +159,7 @@ __wt_idb_destroy(DB *db, int refresh) * by DB configuration, we'd lose that configuration here. */ memset(idb, 0, sizeof(idb)); - WT_RET((__wt_idb_config_default(db))); + WT_RET(__wt_idb_config_default(db)); return (0); } diff --git a/db/db_open.c b/db/db_open.c index c49e543ec44..1d7f374d9da 100644 --- a/db/db_open.c +++ b/db/db_open.c @@ -31,7 +31,7 @@ __wt_db_open(WT_TOC *toc) WT_DB_FCHK(db, "Db.open", flags, WT_APIMASK_DB_OPEN); /* Initialize the IDB structure. */ - WT_RET((__wt_db_idb_open(db, dbname, mode, flags))); + WT_RET(__wt_db_idb_open(db, dbname, mode, flags)); /* * If we're using a single thread, reference it. Otherwise create @@ -50,7 +50,7 @@ __wt_db_open(WT_TOC *toc) stoc->idb = idb; /* Open the underlying Btree. */ - WT_RET((__wt_bt_open(db))); + WT_RET(__wt_bt_open(db)); /* Turn on the methods that require open. */ __wt_db_config_methods_open(db); @@ -73,7 +73,7 @@ __wt_db_idb_open(DB *db, const char *dbname, mode_t mode, u_int32_t flags) ienv = env->ienv; idb = db->idb; - WT_RET((__wt_strdup(env, dbname, &idb->dbname))); + WT_RET(__wt_strdup(env, dbname, &idb->dbname)); idb->mode = mode; idb->file_id = ++ienv->file_id; diff --git a/db/db_stat.c b/db/db_stat.c index 14d36304a46..921f4c7d08b 100644 --- a/db/db_stat.c +++ b/db/db_stat.c @@ -20,7 +20,6 @@ __wt_db_stat_print(WT_TOC *toc) IDB *idb; IENV *ienv; WT_STATS *stats; - WT_STOC *stoc; idb = db->idb; ienv = toc->env->ienv; @@ -30,8 +29,8 @@ __wt_db_stat_print(WT_TOC *toc) fprintf(stream, "Database statistics: %s\n", db->idb->dbname); /* Clear the database stats, then call Btree stat to fill them in. */ - WT_RET((__wt_stat_clear_db_dstats(db->dstats))); - WT_RET((__wt_bt_stat(db))); + WT_RET(__wt_stat_clear_db_dstats(db->dstats)); + WT_RET(__wt_bt_stat(db)); for (stats = db->dstats; stats->desc != NULL; ++stats) fprintf(stream, "%llu\t%s\n", stats->v, stats->desc); @@ -79,9 +78,9 @@ __wt_db_stat_clear(WT_TOC *toc) WT_DB_FCHK(db, "Db.stat_clear", flags, WT_APIMASK_DB_STAT_CLEAR); ret = __wt_stat_clear_db_hstats(db->hstats); - WT_TRET((__wt_stat_clear_db_dstats(db->dstats))); + WT_TRET(__wt_stat_clear_db_dstats(db->dstats)); if (idb->fh != NULL) - WT_TRET((__wt_stat_clear_fh_stats(idb->fh->stats))); + WT_TRET(__wt_stat_clear_fh_stats(idb->fh->stats)); return (ret); } diff --git a/dist/stat.py b/dist/stat.py index 89add2ee6a1..fbd70cfcfbd 100644 --- a/dist/stat.py +++ b/dist/stat.py @@ -71,9 +71,9 @@ for d in sorted(stats.iteritems()): f.write('__wt_stat_alloc_' + d[0] + '(ENV *env, WT_STATS **statsp)\n') f.write('{\n') f.write('\tWT_STATS *stats;\n\n') - f.write('\tWT_RET((__wt_calloc(env,\n') + f.write('\tWT_RET(__wt_calloc(env,\n') f.write('\t WT_STAT_' + d[0].upper() +\ - '_TOTAL + 1, sizeof(WT_STATS), &stats)));\n\n') + '_TOTAL + 1, sizeof(WT_STATS), &stats));\n\n') for l in sorted(d[1]): o = '\tstats[WT_STAT_' + l[0] + '].desc = ' + l[1] + ';\n' if len(o) + 7 > 80: diff --git a/env/env_close.c b/env/env_close.c index 536ea39a770..b4c13062b2b 100644 --- a/env/env_close.c +++ b/env/env_close.c @@ -25,7 +25,7 @@ __wt_env_close(WT_TOC *toc) env, "ENV.close", flags, WT_APIMASK_ENV_CLOSE, ret); /* Re-cycle the underlying IENV structure. */ - WT_TRET((__wt_ienv_destroy(env, 1))); + WT_TRET(__wt_ienv_destroy(env, 1)); /* * Reset the methods that are permitted. diff --git a/env/env_global.c b/env/env_global.c index d24e690ea4b..0b69a126dbf 100644 --- a/env/env_global.c +++ b/env/env_global.c @@ -19,11 +19,11 @@ __wt_build_verify(void) /* * Check the build & compiler itself before going further. */ - WT_RET((__wt_bt_build_verify())); + WT_RET(__wt_bt_build_verify()); #ifdef HAVE_DIAGNOSTIC /* Load debug code the compiler might optimize out. */ - WT_RET((__wt_breakpoint())); + WT_RET(__wt_breakpoint()); #endif return (0); diff --git a/env/env_handle.c b/env/env_handle.c index 9d7d6e5d9ed..f402ee25dd3 100644 --- a/env/env_handle.c +++ b/env/env_handle.c @@ -30,8 +30,8 @@ wt_env_create(u_int32_t flags, ENV **envp) * that can handle NULL structures are the memory allocation and free * functions, no other functions may be called. */ - WT_RET((__wt_calloc(NULL, 1, sizeof(ENV), &env))); - WT_ERR((__wt_calloc(NULL, 1, sizeof(IENV), &ienv))); + WT_RET(__wt_calloc(NULL, 1, sizeof(ENV), &env)); + WT_ERR(__wt_calloc(NULL, 1, sizeof(IENV), &ienv)); /* Connect everything together. */ env->ienv = ienv; @@ -44,8 +44,8 @@ wt_env_create(u_int32_t flags, ENV **envp) goto err; /* Configure the ENV and the IENV. */ - WT_ERR((__wt_env_config_default(env))); - WT_ERR((__wt_ienv_config_default(env))); + WT_ERR(__wt_env_config_default(env)); + WT_ERR(__wt_ienv_config_default(env)); *envp = env; return (0); @@ -77,7 +77,7 @@ __wt_env_destroy(ENV *env, u_int32_t flags) * * Discard the underlying IENV structure. */ - WT_TRET((__wt_ienv_destroy(env, 0))); + WT_TRET(__wt_ienv_destroy(env, 0)); /* Free any allocated memory. */ WT_FREE_AND_CLEAR(env, env->hstats); @@ -108,7 +108,7 @@ __wt_env_config_default(ENV *env) TAILQ_INIT(&env->dbqh); - WT_RET((__wt_stat_alloc_env_hstats(env, &env->hstats))); + WT_RET(__wt_stat_alloc_env_hstats(env, &env->hstats)); return (0); } @@ -144,7 +144,7 @@ __wt_ienv_destroy(ENV *env, int refresh) * by ENV configuration, we'd lose that configuration here. */ memset(ienv, 0, sizeof(ienv)); - WT_RET((__wt_ienv_config_default(env))); + WT_RET(__wt_ienv_config_default(env)); return (0); } @@ -177,13 +177,13 @@ __wt_ienv_config_default(ENV *env) */ #define WT_SERVERQ_SIZE 64 ienv->sq_entries = WT_SERVERQ_SIZE; - WT_RET((__wt_calloc( - NULL, WT_SERVERQ_SIZE, sizeof(WT_STOC), &ienv->sq))); + WT_RET(__wt_calloc( + NULL, WT_SERVERQ_SIZE, sizeof(WT_STOC), &ienv->sq)); WT_STOC_FOREACH(ienv, stoc, i) - WT_RET((__wt_stat_alloc_stoc_stats(NULL, &stoc->stats))); + WT_RET(__wt_stat_alloc_stoc_stats(NULL, &stoc->stats)); /* Initialize the global mutex. */ - WT_RET((__wt_mtx_init(&ienv->mtx))); + WT_RET(__wt_mtx_init(&ienv->mtx)); /* Diagnostic output separator. */ ienv->sep = "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-="; diff --git a/env/env_stat.c b/env/env_stat.c index 1508850f53e..68a1698c8f1 100644 --- a/env/env_stat.c +++ b/env/env_stat.c @@ -42,7 +42,7 @@ __wt_env_stat_print(WT_TOC *toc) fprintf(stream, "%s\n", ienv->sep); TAILQ_FOREACH(db, &env->dbqh, q) - WT_RET((db->stat_print(db, toc, stream, flags))); + WT_RET(db->stat_print(db, toc, stream, flags)); return (0); } @@ -61,7 +61,7 @@ __wt_env_stat_clear(WT_TOC *toc) ret = 0; TAILQ_FOREACH(db, &env->dbqh, q) - WT_TRET((db->stat_clear(db, toc, flags))); - WT_TRET((__wt_stat_clear_env_hstats(env->hstats))); + WT_TRET(db->stat_clear(db, toc, flags)); + WT_TRET(__wt_stat_clear_env_hstats(env->hstats)); return (ret); } diff --git a/env/env_toc.c b/env/env_toc.c index ff0c7c4b80d..44f92d05b6c 100644 --- a/env/env_toc.c +++ b/env/env_toc.c @@ -26,17 +26,17 @@ __wt_env_toc_create(ENV *env, u_int32_t flags, WT_TOC **tocp) WT_ENV_FCHK(env, "wt_toc_create", flags, WT_APIMASK_ENV_TOC_CREATE); - WT_RET((__wt_calloc(env, 1, sizeof(WT_TOC), &toc))); - WT_ERR((__wt_calloc(env, 1, sizeof(WT_MTX), &toc->block))); + WT_RET(__wt_calloc(env, 1, sizeof(WT_TOC), &toc)); + WT_ERR(__wt_calloc(env, 1, sizeof(WT_MTX), &toc->block)); /* The mutex is self-blocking, so it's normal state is locked. */ - WT_ERR((__wt_mtx_init(toc->block))); - WT_ERR((__wt_lock(toc->block))); + WT_ERR(__wt_mtx_init(toc->block)); + WT_ERR(__wt_lock(toc->block)); /* Get a server slot ID. */ - WT_ERR((__wt_lock(&ienv->mtx))); + WT_ERR(__wt_lock(&ienv->mtx)); toc->slot = ienv->toc_slot++; - WT_ERR((__wt_unlock(&ienv->mtx))); + WT_ERR(__wt_unlock(&ienv->mtx)); if (toc->slot >= WT_SERVER_QSIZE) { __wt_env_errx(env, "wt_env_toc_create: too many threads"); ret = WT_ERROR; @@ -70,7 +70,7 @@ __wt_env_toc_destroy(WT_TOC *toc, u_int32_t flags) WT_ENV_FCHK_NOTFATAL( env, "WtToc.destroy", flags, WT_APIMASK_TOC_DESTROY, ret); - WT_TRET((__wt_mtx_destroy(toc->block))); + WT_TRET(__wt_mtx_destroy(toc->block)); WT_FREE_AND_CLEAR(env, toc->block); @@ -86,10 +86,7 @@ __wt_env_toc_destroy(WT_TOC *toc, u_int32_t flags) int __wt_env_toc_sched(WT_TOC *toc) { - IENV *ienv; WT_STOC *stoc; - WT_TOC **q, **eq; - u_int sid; /* * The engine may be single-threaded or threads of control may re-enter diff --git a/env/env_workq.c b/env/env_workq.c index 3231b05f3c2..e6715749ca7 100644 --- a/env/env_workq.c +++ b/env/env_workq.c @@ -27,7 +27,7 @@ __wt_env_start(ENV *env, u_int32_t flags) * No matter what we're doing, we end up here before we do any real * work. Check the build itself. */ - WT_RET((__wt_build_verify())); + WT_RET(__wt_build_verify()); /* Create the primary thread-of-control structure. */ stoc = ienv->sq + ienv->sq_next; @@ -92,7 +92,7 @@ __wt_workq(void *arg) { WT_STOC *stoc; WT_TOC **q, **eq, *toc; - int maxsleep, not_found; + int not_found; stoc = arg; diff --git a/inc_posix/misc.h b/inc_posix/misc.h index 9906a1c245c..baeb2f8e7b0 100644 --- a/inc_posix/misc.h +++ b/inc_posix/misc.h @@ -80,23 +80,23 @@ extern "C" { return (__wt_database_format(db)) /* - * Standard macros that set return values and optionally branch to an error - * label. + * Standard macros to handle simple return values and optionally branch to + * an error label. */ -#define WT_ERR(a) { \ - if ((ret = a) != 0) \ +#define WT_ERR(a) do { \ + if ((ret = (a)) != 0) \ goto err; \ -} -#define WT_RET(a) { \ +} while (0) +#define WT_RET(a) do { \ int __ret; \ - if ((__ret = a) != 0) \ + if ((__ret = (a)) != 0) \ return (__ret); \ -} -#define WT_TRET(a) { \ +} while (0) +#define WT_TRET(a) do { \ int __ret; \ - if ((__ret = a) != 0 && ret == 0) \ + if ((__ret = (a)) != 0 && ret == 0) \ ret = __ret; \ -} +} while (0) #if defined(__cplusplus) } diff --git a/os_posix/os_alloc.c b/os_posix/os_alloc.c index c951c951c55..3d63528b2f5 100644 --- a/os_posix/os_alloc.c +++ b/os_posix/os_alloc.c @@ -172,7 +172,7 @@ __wt_strdup(ENV *env, const char *str, void *retp) */ len = strlen(str) + 1; - WT_RET((__wt_calloc(env, len, 1, &p))); + WT_RET(__wt_calloc(env, len, 1, &p)); memcpy(p, str, len); diff --git a/os_posix/os_mtx.c b/os_posix/os_mtx.c index c2202740982..1b0d276589d 100644 --- a/os_posix/os_mtx.c +++ b/os_posix/os_mtx.c @@ -112,11 +112,11 @@ __wt_unlock(WT_MTX *mtx) int __wt_mtx_destroy(WT_MTX *mtx) { - int ret, tret; + int ret; ret = pthread_cond_destroy(&mtx->cond); - WT_TRET((pthread_mutex_destroy(&mtx->mtx))); + WT_TRET(pthread_mutex_destroy(&mtx->mtx)); return (ret == 0 ? 0 : WT_ERROR); } diff --git a/os_posix/os_open.c b/os_posix/os_open.c index 6eeb4a99965..802d76a28a3 100644 --- a/os_posix/os_open.c +++ b/os_posix/os_open.c @@ -52,9 +52,9 @@ __wt_open(ENV *env, return (WT_ERROR); } - WT_RET((__wt_calloc(env, 1, sizeof(WT_FH), &fh))); - WT_ERR((__wt_stat_alloc_fh_stats(env, &fh->stats))); - WT_ERR((__wt_strdup(env, name, &fh->name))); + WT_RET(__wt_calloc(env, 1, sizeof(WT_FH), &fh)); + WT_ERR(__wt_stat_alloc_fh_stats(env, &fh->stats)); + WT_ERR(__wt_strdup(env, name, &fh->name)); #if defined(HAVE_FCNTL) && defined(FD_CLOEXEC) /* @@ -75,7 +75,7 @@ __wt_open(ENV *env, *fhp = fh; /* Set the file's size. */ - WT_ERR((__wt_filesize(env, fh, &fh->file_size))); + WT_ERR(__wt_filesize(env, fh, &fh->file_size)); return (0); diff --git a/support/stat.c b/support/stat.c index 56e9a9a6f67..cde057d92d9 100644 --- a/support/stat.c +++ b/support/stat.c @@ -7,8 +7,8 @@ __wt_stat_alloc_db_dstats(ENV *env, WT_STATS **statsp) { WT_STATS *stats; - WT_RET((__wt_calloc(env, - WT_STAT_DB_DSTATS_TOTAL + 1, sizeof(WT_STATS), &stats))); + WT_RET(__wt_calloc(env, + WT_STAT_DB_DSTATS_TOTAL + 1, sizeof(WT_STATS), &stats)); stats[WT_STAT_BASE_RECNO].desc = "base record number"; stats[WT_STAT_EXTSIZE].desc = "database extent size"; @@ -66,8 +66,8 @@ __wt_stat_alloc_db_hstats(ENV *env, WT_STATS **statsp) { WT_STATS *stats; - WT_RET((__wt_calloc(env, - WT_STAT_DB_HSTATS_TOTAL + 1, sizeof(WT_STATS), &stats))); + WT_RET(__wt_calloc(env, + WT_STAT_DB_HSTATS_TOTAL + 1, sizeof(WT_STATS), &stats)); stats[WT_STAT_BULK_DUP_DATA_READ].desc = "bulk duplicate data pairs read"; @@ -103,8 +103,8 @@ __wt_stat_alloc_env_hstats(ENV *env, WT_STATS **statsp) { WT_STATS *stats; - WT_RET((__wt_calloc(env, - WT_STAT_ENV_HSTATS_TOTAL + 1, sizeof(WT_STATS), &stats))); + WT_RET(__wt_calloc(env, + WT_STAT_ENV_HSTATS_TOTAL + 1, sizeof(WT_STATS), &stats)); stats[WT_STAT_CACHE_ALLOC].desc = "pages allocated in the cache"; stats[WT_STAT_CACHE_CLEAN].desc = "clean pages in the cache"; @@ -140,8 +140,8 @@ __wt_stat_alloc_fh_stats(ENV *env, WT_STATS **statsp) { WT_STATS *stats; - WT_RET((__wt_calloc(env, - WT_STAT_FH_STATS_TOTAL + 1, sizeof(WT_STATS), &stats))); + WT_RET(__wt_calloc(env, + WT_STAT_FH_STATS_TOTAL + 1, sizeof(WT_STATS), &stats)); stats[WT_STAT_READ_IO].desc = "count of read I/Os"; stats[WT_STAT_WRITE_IO].desc = "count of write I/Os"; @@ -163,8 +163,8 @@ __wt_stat_alloc_stoc_stats(ENV *env, WT_STATS **statsp) { WT_STATS *stats; - WT_RET((__wt_calloc(env, - WT_STAT_STOC_STATS_TOTAL + 1, sizeof(WT_STATS), &stats))); + WT_RET(__wt_calloc(env, + WT_STAT_STOC_STATS_TOTAL + 1, sizeof(WT_STATS), &stats)); stats[WT_STAT_STOC_ARRAY].desc = "server thread array passes"; stats[WT_STAT_STOC_OPS].desc = "server thread operations"; |