summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2016-12-11 22:01:19 -0500
committerAlex Gorrod <alexander.gorrod@mongodb.com>2016-12-12 14:01:19 +1100
commit493bbf750c86319757fc61d30c478f43fe2fdc48 (patch)
tree158c1f5b4b89c65502dae9451960826815811692
parent1b812c0aa2fbab91e289642b0a8d02d65c879438 (diff)
downloadmongo-493bbf750c86319757fc61d30c478f43fe2fdc48.tar.gz
WT-3066 lint (#3189)
-rwxr-xr-xdist/s_void37
-rw-r--r--src/async/async_op.c3
-rw-r--r--src/block/block_compact.c6
-rw-r--r--src/btree/bt_debug.c4
-rw-r--r--src/cursor/cur_json.c3
-rw-r--r--src/include/txn.i3
-rw-r--r--src/lsm/lsm_cursor.c13
-rw-r--r--src/lsm/lsm_tree.c6
-rw-r--r--src/os_win/os_fs.c3
-rw-r--r--src/os_win/os_utf8.c2
-rw-r--r--src/reconcile/rec_track.c12
-rw-r--r--src/reconcile/rec_write.c3
-rw-r--r--src/session/session_api.c3
-rw-r--r--src/txn/txn_nsnap.c6
14 files changed, 58 insertions, 46 deletions
diff --git a/dist/s_void b/dist/s_void
index 06111245fe2..025f6d4c7eb 100755
--- a/dist/s_void
+++ b/dist/s_void
@@ -12,6 +12,7 @@ file_parse()
sed -n \
-e '/^int$/b loop' \
-e '/^static int$/b loop' \
+ -e '/^static inline int$/b loop' \
-e 'd' \
-e ': loop' \
-e 'H' \
@@ -35,6 +36,7 @@ func_ok()
-e '/int __compact_uri_analyze$/d' \
-e '/int __config_parser_close$/d' \
-e '/int __curlog_reset$/d' \
+ -e '/int __cursor_fix_implicit$/d' \
-e '/int __handle_close_default$/d' \
-e '/int __handle_progress_default$/d' \
-e '/int __im_file_close$/d' \
@@ -43,7 +45,7 @@ func_ok()
-e '/int __im_file_sync$/d' \
-e '/int __im_fs_directory_list_free$/d' \
-e '/int __im_fs_exist$/d' \
- -e '/int __posix_file_close$/d' \
+ -e '/int __page_write_gen_wrapped_check$/d' \
-e '/int __posix_terminate$/d' \
-e '/int __rec_destroy_session$/d' \
-e '/int __win_terminate$/d' \
@@ -60,11 +62,14 @@ func_ok()
-e '/int __wt_lsm_manager_pop_entry$/d' \
-e '/int __wt_once$/d' \
-e '/int __wt_posix_directory_list_free$/d' \
+ -e '/int __wt_spin_init$/d' \
+ -e '/int __wt_spin_trylock$/d' \
-e '/int __wt_stat_connection_desc$/d' \
-e '/int __wt_stat_dsrc_desc$/d' \
-e '/int __wt_stat_join_desc$/d' \
-e '/int __wt_win_directory_list_free$/d' \
-e '/int bdb_compare_reverse$/d' \
+ -e '/int copyout_val$/d' \
-e '/int csv_error$/d' \
-e '/int csv_terminate$/d' \
-e '/int demo_file_close$/d' \
@@ -109,13 +114,14 @@ func_ok()
-e '/int zstd_terminate$/d'
}
-# Complain about functions which return an "int" but which don't return except
-# at the end of the function.
for f in `find bench ext src test -name '*.[ci]'`; do
if expr "$f" : '.*/windows_shim.c' > /dev/null; then
continue
fi
+ # Complain about functions which return an "int" but which don't return
+ # except at the end of the function.
+ #
# Turn each function into a single line, then discard the function's
# final "return" call, then discard any function that still has some
# form of return assignment or call.
@@ -128,6 +134,9 @@ for f in `find bench ext src test -name '*.[ci]'`; do
-e '/WT_ILLEGAL_VALUE[A-Z_]*(/d' \
-e '/WT_PANIC[A-Z_]*(/d' \
-e '/WT_RET[A-Z_]*(/d' \
+ -e '/WT_SIZE_CHECK_PACK(/d' \
+ -e '/WT_SIZE_CHECK_UNPACK(/d' \
+ -e '/WT_SYSCALL(/d' \
-e '/WT_TRET(/d' \
-e '/[^a-z_]ret = /d' \
-e '/[^a-z_]return (/d' \
@@ -142,6 +151,28 @@ for f in `find bench ext src test -name '*.[ci]'`; do
echo "Add false positives to the list in dist/s_void."
echo "=============================================="
}
+
+ # Complain about functions which declare a "ret" value but never use it.
+ file_parse $f |
+ grep 'WT_DECL_RET' |
+ sed -e '/ret =/d' \
+ -e '/API_END_RET/d' \
+ -e '/WT_CURSOR_NEEDKEY/d' \
+ -e '/WT_CURSOR_NEEDVALUE/d' \
+ -e '/WT_ERR/d' \
+ -e '/WT_ILLEGAL_VALUE_ERR/d' \
+ -e '/WT_SYSCALL.*ret/d' \
+ -e '/WT_TRET/d' \
+ -e 's/^\([^(]*\).*/\1/' \
+ -e 's/^ *//' > $t
+ test -s $t && {
+ echo "=============================================="
+ echo "$f:"
+ cat $t | sed 's/^/ /'
+ echo "Function declares ret without using it."
+ echo "Add false positives to the list in dist/s_void."
+ echo "=============================================="
+ }
done
exit 0
diff --git a/src/async/async_op.c b/src/async/async_op.c
index 8c074e503d9..6908802dbff 100644
--- a/src/async/async_op.c
+++ b/src/async/async_op.c
@@ -254,7 +254,6 @@ __wt_async_op_enqueue(WT_SESSION_IMPL *session, WT_ASYNC_OP_IMPL *op)
{
WT_ASYNC *async;
WT_CONNECTION_IMPL *conn;
- WT_DECL_RET;
uint64_t cur_head, cur_tail, my_alloc, my_slot;
#ifdef HAVE_DIAGNOSTIC
WT_ASYNC_OP_IMPL *my_op;
@@ -307,7 +306,7 @@ __wt_async_op_enqueue(WT_SESSION_IMPL *session, WT_ASYNC_OP_IMPL *op)
WT_ORDERED_READ(cur_head, async->head);
}
WT_PUBLISH(async->head, my_alloc);
- return (ret);
+ return (0);
}
/*
diff --git a/src/block/block_compact.c b/src/block/block_compact.c
index 380493d1c0b..eb6647dd03c 100644
--- a/src/block/block_compact.c
+++ b/src/block/block_compact.c
@@ -61,7 +61,6 @@ __wt_block_compact_end(WT_SESSION_IMPL *session, WT_BLOCK *block)
int
__wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, bool *skipp)
{
- WT_DECL_RET;
WT_EXT *ext;
WT_EXTLIST *el;
wt_off_t avail_eighty, avail_ninety, eighty, ninety;
@@ -138,7 +137,7 @@ __wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, bool *skipp)
__wt_spin_unlock(session, &block->live_lock);
- return (ret);
+ return (0);
}
/*
@@ -149,7 +148,6 @@ int
__wt_block_compact_page_skip(WT_SESSION_IMPL *session,
WT_BLOCK *block, const uint8_t *addr, size_t addr_size, bool *skipp)
{
- WT_DECL_RET;
WT_EXT *ext;
WT_EXTLIST *el;
wt_off_t limit, offset;
@@ -194,7 +192,7 @@ __wt_block_compact_page_skip(WT_SESSION_IMPL *session,
}
#endif
- return (ret);
+ return (0);
}
/*
diff --git a/src/btree/bt_debug.c b/src/btree/bt_debug.c
index 3352b797fa9..d507cc0e396 100644
--- a/src/btree/bt_debug.c
+++ b/src/btree/bt_debug.c
@@ -1104,9 +1104,9 @@ __debug_cell(WT_DBG *ds, const WT_PAGE_HEADER *dsk, WT_CELL_UNPACK *unpack)
case WT_CELL_VALUE_OVFL_RM:
type = "ovfl";
addr: WT_RET(__wt_scr_alloc(session, 128, &buf));
- WT_RET(ds->f(ds, ", %s %s", type,
+ ret = ds->f(ds, ", %s %s", type,
__wt_addr_string(
- session, unpack->data, unpack->size, buf)));
+ session, unpack->data, unpack->size, buf));
__wt_scr_free(session, &buf);
WT_RET(ret);
break;
diff --git a/src/cursor/cur_json.c b/src/cursor/cur_json.c
index d590dbd828a..a0a3ffdd974 100644
--- a/src/cursor/cur_json.c
+++ b/src/cursor/cur_json.c
@@ -270,7 +270,6 @@ __wt_json_alloc_unpack(WT_SESSION_IMPL *session, const void *buffer,
bool iskey, va_list ap)
{
WT_CONFIG_ITEM *names;
- WT_DECL_RET;
size_t needed;
char **json_bufp;
@@ -288,7 +287,7 @@ __wt_json_alloc_unpack(WT_SESSION_IMPL *session, const void *buffer,
WT_RET(__json_struct_unpackv(session, buffer, size, fmt,
names, (u_char *)*json_bufp, needed + 1, iskey, ap));
- return (ret);
+ return (0);
}
/*
diff --git a/src/include/txn.i b/src/include/txn.i
index 3e8dd45003e..0cc4a6f8439 100644
--- a/src/include/txn.i
+++ b/src/include/txn.i
@@ -62,7 +62,6 @@ __wt_txn_unmodify(WT_SESSION_IMPL *session)
static inline int
__wt_txn_modify(WT_SESSION_IMPL *session, WT_UPDATE *upd)
{
- WT_DECL_RET;
WT_TXN_OP *op;
WT_TXN *txn;
@@ -77,7 +76,7 @@ __wt_txn_modify(WT_SESSION_IMPL *session, WT_UPDATE *upd)
WT_TXN_OP_INMEM : WT_TXN_OP_BASIC;
op->u.upd = upd;
upd->txnid = session->txn.id;
- return (ret);
+ return (0);
}
/*
diff --git a/src/lsm/lsm_cursor.c b/src/lsm/lsm_cursor.c
index df209ce3b05..839648b97d7 100644
--- a/src/lsm/lsm_cursor.c
+++ b/src/lsm/lsm_cursor.c
@@ -409,13 +409,11 @@ static int
__clsm_resize_chunks(
WT_SESSION_IMPL *session, WT_CURSOR_LSM *clsm, u_int nchunks)
{
- WT_DECL_RET;
WT_LSM_CURSOR_CHUNK *chunk;
/* Don't allocate more iterators if we don't need them. */
- if (clsm->chunks_count >= nchunks) {
- return (ret);
- }
+ if (clsm->chunks_count >= nchunks)
+ return (0);
WT_RET(__wt_realloc_def(session, &clsm->chunks_alloc, nchunks,
&clsm->chunks));
@@ -423,7 +421,7 @@ __clsm_resize_chunks(
WT_RET(__wt_calloc_one(session, &chunk));
clsm->chunks[clsm->chunks_count] = chunk;
}
- return (ret);
+ return (0);
}
/*
@@ -434,9 +432,10 @@ static void
__clsm_free_chunks(WT_SESSION_IMPL *session, WT_CURSOR_LSM *clsm)
{
size_t i;
- for (i = 0; i < clsm->chunks_count; i++) {
+
+ for (i = 0; i < clsm->chunks_count; i++)
__wt_free(session, clsm->chunks[i]);
- }
+
__wt_free(session, clsm->chunks);
}
diff --git a/src/lsm/lsm_tree.c b/src/lsm/lsm_tree.c
index 80d20ad24f8..b0616fb8ec1 100644
--- a/src/lsm/lsm_tree.c
+++ b/src/lsm/lsm_tree.c
@@ -293,8 +293,6 @@ int
__wt_lsm_tree_setup_bloom(
WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, WT_LSM_CHUNK *chunk)
{
- WT_DECL_RET;
-
/*
* The Bloom URI can be populated when the chunk is created, but
* it isn't set yet on open or merge.
@@ -302,8 +300,8 @@ __wt_lsm_tree_setup_bloom(
if (chunk->bloom_uri == NULL)
WT_RET(__wt_lsm_tree_bloom_name(
session, lsm_tree, chunk->id, &chunk->bloom_uri));
- WT_RET(__lsm_tree_cleanup_old(session, chunk->bloom_uri));
- return (ret);
+
+ return (__lsm_tree_cleanup_old(session, chunk->bloom_uri));
}
/*
diff --git a/src/os_win/os_fs.c b/src/os_win/os_fs.c
index 6c74f2f411f..2f76fff04a5 100644
--- a/src/os_win/os_fs.c
+++ b/src/os_win/os_fs.c
@@ -16,7 +16,6 @@ static int
__win_fs_exist(WT_FILE_SYSTEM *file_system,
WT_SESSION *wt_session, const char *name, bool *existp)
{
- WT_DECL_RET;
WT_DECL_ITEM(name_wide);
WT_SESSION_IMPL *session;
@@ -43,8 +42,8 @@ __win_fs_remove(WT_FILE_SYSTEM *file_system,
WT_SESSION *wt_session, const char *name, uint32_t flags)
{
DWORD windows_error;
- WT_DECL_RET;
WT_DECL_ITEM(name_wide);
+ WT_DECL_RET;
WT_SESSION_IMPL *session;
WT_UNUSED(file_system);
diff --git a/src/os_win/os_utf8.c b/src/os_win/os_utf8.c
index f7d11c24f03..ccd8321aecf 100644
--- a/src/os_win/os_utf8.c
+++ b/src/os_win/os_utf8.c
@@ -18,7 +18,6 @@ __wt_to_utf16_string(
{
DWORD windows_error;
int bufferSize;
- WT_DECL_RET;
bufferSize = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0);
windows_error = __wt_getlasterror();
@@ -55,7 +54,6 @@ __wt_to_utf8_string(
{
DWORD windows_error;
int bufferSize;
- WT_DECL_RET;
bufferSize = WideCharToMultiByte(
CP_UTF8, 0, wide, -1, NULL, 0, NULL, NULL);
diff --git a/src/reconcile/rec_track.c b/src/reconcile/rec_track.c
index 10a64fdf116..3795b6e5ae8 100644
--- a/src/reconcile/rec_track.c
+++ b/src/reconcile/rec_track.c
@@ -35,7 +35,6 @@ __ovfl_discard_verbose(
{
WT_CELL_UNPACK *unpack, _unpack;
WT_DECL_ITEM(tmp);
- WT_DECL_RET;
WT_RET(__wt_scr_alloc(session, 512, &tmp));
@@ -50,7 +49,7 @@ __ovfl_discard_verbose(
__wt_addr_string(session, unpack->data, unpack->size, tmp));
__wt_scr_free(session, &tmp);
- return (ret);
+ return (0);
}
#if 0
@@ -83,7 +82,6 @@ static int
__ovfl_discard_wrapup(WT_SESSION_IMPL *session, WT_PAGE *page)
{
WT_CELL **cellp;
- WT_DECL_RET;
WT_OVFL_TRACK *track;
uint32_t i;
@@ -101,7 +99,7 @@ __ovfl_discard_wrapup(WT_SESSION_IMPL *session, WT_PAGE *page)
__wt_free(session, track->discard);
track->discard_entries = track->discard_allocated = 0;
- return (ret);
+ return (0);
}
/*
@@ -170,7 +168,6 @@ __ovfl_reuse_verbose(WT_SESSION_IMPL *session,
WT_PAGE *page, WT_OVFL_REUSE *reuse, const char *tag)
{
WT_DECL_ITEM(tmp);
- WT_DECL_RET;
WT_RET(__wt_scr_alloc(session, 64, &tmp));
@@ -188,7 +185,7 @@ __ovfl_reuse_verbose(WT_SESSION_IMPL *session,
WT_MIN(reuse->value_size, 40), (char *)WT_OVFL_REUSE_VALUE(reuse));
__wt_scr_free(session, &tmp);
- return (ret);
+ return (0);
}
#if 0
@@ -568,7 +565,6 @@ __ovfl_txnc_verbose(WT_SESSION_IMPL *session,
WT_PAGE *page, WT_OVFL_TXNC *txnc, const char *tag)
{
WT_DECL_ITEM(tmp);
- WT_DECL_RET;
WT_RET(__wt_scr_alloc(session, 64, &tmp));
@@ -583,7 +579,7 @@ __ovfl_txnc_verbose(WT_SESSION_IMPL *session,
WT_MIN(txnc->value_size, 40), (char *)WT_OVFL_TXNC_VALUE(txnc));
__wt_scr_free(session, &tmp);
- return (ret);
+ return (0);
}
#if 0
diff --git a/src/reconcile/rec_write.c b/src/reconcile/rec_write.c
index 86749eef2e1..e82f449a50d 100644
--- a/src/reconcile/rec_write.c
+++ b/src/reconcile/rec_write.c
@@ -5519,7 +5519,6 @@ __rec_row_leaf_insert(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins)
static int
__rec_split_discard(WT_SESSION_IMPL *session, WT_PAGE *page)
{
- WT_DECL_RET;
WT_PAGE_MODIFY *mod;
WT_MULTI *multi;
uint32_t i;
@@ -5579,7 +5578,7 @@ __rec_split_discard(WT_SESSION_IMPL *session, WT_PAGE *page)
break;
}
- return (ret);
+ return (0);
}
/*
diff --git a/src/session/session_api.c b/src/session/session_api.c
index 377bc0bdc2d..ed6339aa66e 100644
--- a/src/session/session_api.c
+++ b/src/session/session_api.c
@@ -58,7 +58,6 @@ int
__wt_session_copy_values(WT_SESSION_IMPL *session)
{
WT_CURSOR *cursor;
- WT_DECL_RET;
TAILQ_FOREACH(cursor, &session->cursors, q)
if (F_ISSET(cursor, WT_CURSTD_VALUE_INT)) {
@@ -80,7 +79,7 @@ __wt_session_copy_values(WT_SESSION_IMPL *session)
F_SET(cursor, WT_CURSTD_VALUE_EXT);
}
- return (ret);
+ return (0);
}
/*
diff --git a/src/txn/txn_nsnap.c b/src/txn/txn_nsnap.c
index b12da9fbaea..65ec1a6662f 100644
--- a/src/txn/txn_nsnap.c
+++ b/src/txn/txn_nsnap.c
@@ -28,7 +28,6 @@ __nsnap_destroy(WT_SESSION_IMPL *session, WT_NAMED_SNAPSHOT *nsnap)
static int
__nsnap_drop_one(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *name)
{
- WT_DECL_RET;
WT_NAMED_SNAPSHOT *found;
WT_TXN_GLOBAL *txn_global;
@@ -56,7 +55,7 @@ __nsnap_drop_one(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *name)
__nsnap_destroy(session, found);
WT_STAT_CONN_INCR(session, txn_snapshots_dropped);
- return (ret);
+ return (0);
}
/*
@@ -67,7 +66,6 @@ __nsnap_drop_one(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *name)
static int
__nsnap_drop_to(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *name, bool inclusive)
{
- WT_DECL_RET;
WT_NAMED_SNAPSHOT *last, *nsnap, *prev;
WT_TXN_GLOBAL *txn_global;
uint64_t new_nsnap_oldest;
@@ -134,7 +132,7 @@ __nsnap_drop_to(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *name, bool inclusive)
new_nsnap_oldest == WT_TXN_NONE ||
!__wt_txn_visible_all(session, new_nsnap_oldest));
- return (ret);
+ return (0);
}
/*