summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith.bostic@mongodb.com>2017-08-30 00:28:41 -0400
committerAlex Gorrod <alexander.gorrod@mongodb.com>2017-08-30 14:28:41 +1000
commit0cdb4a0a43f968ed3bed62ade31517e19c860c94 (patch)
tree380b9cc2d41b8151b3e5d8f514c19989c7d0d000
parentfa556f14150cce2285be628de67cc0c900a9c10c (diff)
downloadmongo-0cdb4a0a43f968ed3bed62ade31517e19c860c94.tar.gz
WT-3546 Coverity 1380021 dereference before NULL check, lint (#3626)
CID 1380021 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking table suggests that it may be null, but it has already been dereferenced on all paths leading to the check.
-rw-r--r--SConstruct33
-rw-r--r--src/evict/evict_lru.c22
-rw-r--r--src/include/btree.h8
-rw-r--r--src/include/cache.h9
-rw-r--r--src/include/cache.i2
-rw-r--r--src/schema/schema_create.c6
-rw-r--r--src/schema/schema_open.c6
-rw-r--r--src/schema/schema_rename.c4
-rw-r--r--src/txn/txn_rollback_to_stable.c5
-rw-r--r--test/suite/test_alter02.py2
-rw-r--r--test/suite/test_bug010.py2
-rw-r--r--test/suite/test_bulk01.py2
-rw-r--r--test/suite/test_colgap.py2
-rw-r--r--test/suite/test_empty.py2
-rw-r--r--test/suite/test_encrypt04.py4
-rw-r--r--test/suite/test_schema03.py2
-rw-r--r--test/suite/test_stat02.py2
-rw-r--r--test/suite/test_timestamp04.py4
-rw-r--r--test/suite/test_util02.py4
19 files changed, 46 insertions, 75 deletions
diff --git a/SConstruct b/SConstruct
index 501dae2ad9f..96012456b34 100644
--- a/SConstruct
+++ b/SConstruct
@@ -469,39 +469,6 @@ t = env.Program("t_manydbs",
LIBS=[wtlib, shim, testutil] + wtlibs)
Default(t)
-# t_readonly doesn't currently build/run.
-#t = env.Program("t_readonly",
-# "test/readonly/readonly.c",
-# LIBS=[wtlib, shim, testutil] + wtlibs)
-#Default(t)
-
-# t_random-abort doesn't currently build/run.
-#t = env.Program("t_random-abort",
-# "test/recovery/random-abort.c",
-# LIBS=[wtlib, shim, testutil] + wtlibs)
-#Default(t)
-
-# t_truncated-log doesn't currently build/run.
-#t = env.Program("t_truncated-log",
-# "test/recovery/truncated-log.c",
-# LIBS=[wtlib, shim, testutil] + wtlibs)
-#Default(t)
-
-# t_salvage-log doesn't currently build/run.
-#t = env.Program("t_salvage",
-# "test/salvage/salvage.c",
-# LIBS=[wtlib, shim, testutil] + wtlibs)
-#Default(t)
-
-# t_thread doesn't currently build/run.
-#t = env.Program("t_thread",
-# ["test/thread/file.c",
-# "test/thread/rw.c",
-# "test/thread/stats.c",
-# "test/thread/t.c"],
-# LIBS=[wtlib, shim, testutil] + wtlibs)
-#Default(t)
-
t = env.Program("wtperf", [
"bench/wtperf/config.c",
"bench/wtperf/idle_table_cycle.c",
diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c
index f745f7504a4..62f0294170b 100644
--- a/src/evict/evict_lru.c
+++ b/src/evict/evict_lru.c
@@ -1730,7 +1730,7 @@ __evict_walk_file(WT_SESSION_IMPL *session,
* eviction fairly visits all pages in trees with a lot of in-cache
* content.
*/
- switch ((WT_EVICT_WALK_START)btree->evict_start_type) {
+ switch (btree->evict_start_type) {
case WT_EVICT_WALK_NEXT:
break;
case WT_EVICT_WALK_PREV:
@@ -1788,9 +1788,23 @@ __evict_walk_file(WT_SESSION_IMPL *session,
* Try a different walk start point next time if a
* walk gave up.
*/
- btree->evict_start_type =
- (btree->evict_start_type + 1) %
- WT_EVICT_WALK_START_NUM;
+ switch (btree->evict_start_type) {
+ case WT_EVICT_WALK_NEXT:
+ btree->evict_start_type = WT_EVICT_WALK_PREV;
+ break;
+ case WT_EVICT_WALK_PREV:
+ btree->evict_start_type =
+ WT_EVICT_WALK_RAND_PREV;
+ break;
+ case WT_EVICT_WALK_RAND_PREV:
+ btree->evict_start_type =
+ WT_EVICT_WALK_RAND_NEXT;
+ break;
+ case WT_EVICT_WALK_RAND_NEXT:
+ btree->evict_start_type = WT_EVICT_WALK_NEXT;
+ break;
+ }
+
/*
* We differentiate the reasons we gave up on this walk
* and increment the stats accordingly.
diff --git a/src/include/btree.h b/src/include/btree.h
index 4d2a4f0c4d9..f69fc355383 100644
--- a/src/include/btree.h
+++ b/src/include/btree.h
@@ -154,8 +154,12 @@ struct __wt_btree {
u_int evict_walk_skips; /* Number of walks skipped */
int32_t evict_disabled; /* Eviction disabled count */
volatile uint32_t evict_busy; /* Count of threads in eviction */
- int evict_start_type; /* Start position for eviction walk
- (see WT_EVICT_WALK_START). */
+ enum { /* Start position for eviction walk */
+ WT_EVICT_WALK_NEXT,
+ WT_EVICT_WALK_PREV,
+ WT_EVICT_WALK_RAND_NEXT,
+ WT_EVICT_WALK_RAND_PREV
+ } evict_start_type;
/*
* We flush pages from the tree (in order to make checkpoint faster),
diff --git a/src/include/cache.h b/src/include/cache.h
index 9b5057d0b61..9d7489732aa 100644
--- a/src/include/cache.h
+++ b/src/include/cache.h
@@ -14,15 +14,6 @@
#define WT_EVICT_WALK_BASE 300 /* Pages tracked across file visits */
#define WT_EVICT_WALK_INCR 100 /* Pages added each walk */
-/* Ways to position when starting an eviction walk. */
-typedef enum {
- WT_EVICT_WALK_NEXT,
- WT_EVICT_WALK_PREV,
- WT_EVICT_WALK_RAND_NEXT,
- WT_EVICT_WALK_RAND_PREV
-} WT_EVICT_WALK_START;
-#define WT_EVICT_WALK_START_NUM (WT_EVICT_WALK_RAND_PREV + 1)
-
/*
* WT_EVICT_ENTRY --
* Encapsulation of an eviction candidate.
diff --git a/src/include/cache.i b/src/include/cache.i
index 1e058a3ec1b..6e0d2541c3c 100644
--- a/src/include/cache.i
+++ b/src/include/cache.i
@@ -216,7 +216,7 @@ __wt_session_can_wait(WT_SESSION_IMPL *session)
/*
* __wt_eviction_clean_needed --
* Return if an application thread should do eviction due to the total
- * volume of dirty data in cache.
+ * volume of data in cache.
*/
static inline bool
__wt_eviction_clean_needed(WT_SESSION_IMPL *session, u_int *pct_fullp)
diff --git a/src/schema/schema_create.c b/src/schema/schema_create.c
index 596975e8246..641c99793c3 100644
--- a/src/schema/schema_create.c
+++ b/src/schema/schema_create.c
@@ -609,10 +609,8 @@ __create_table(WT_SESSION_IMPL *session,
if (ncolgroups == 0) {
cgsize = strlen("colgroup:") + strlen(tablename) + 1;
WT_ERR(__wt_calloc_def(session, cgsize, &cgname));
- WT_ERR(__wt_snprintf(
- cgname, cgsize, "colgroup:%s", tablename));
- WT_ERR(__create_colgroup(
- session, cgname, exclusive, config));
+ WT_ERR(__wt_snprintf(cgname, cgsize, "colgroup:%s", tablename));
+ WT_ERR(__create_colgroup(session, cgname, exclusive, config));
}
/*
diff --git a/src/schema/schema_open.c b/src/schema/schema_open.c
index 2944239bf85..a2ccbbe83b1 100644
--- a/src/schema/schema_open.c
+++ b/src/schema/schema_open.c
@@ -432,11 +432,9 @@ __schema_open_table(WT_SESSION_IMPL *session, const char *cfg[])
WT_UNUSED(cfg);
WT_RET(__wt_config_gets(session, table_cfg, "columns", &cval));
- WT_RET(__wt_config_gets(
- session, table_cfg, "key_format", &cval));
+ WT_RET(__wt_config_gets(session, table_cfg, "key_format", &cval));
WT_RET(__wt_strndup(session, cval.str, cval.len, &table->key_format));
- WT_RET(__wt_config_gets(
- session, table_cfg, "value_format", &cval));
+ WT_RET(__wt_config_gets(session, table_cfg, "value_format", &cval));
WT_RET(__wt_strndup(session, cval.str, cval.len, &table->value_format));
/* Point to some items in the copy to save re-parsing. */
diff --git a/src/schema/schema_rename.c b/src/schema/schema_rename.c
index 1084b2570e6..06133814291 100644
--- a/src/schema/schema_rename.c
+++ b/src/schema/schema_rename.c
@@ -248,9 +248,9 @@ __rename_table(WT_SESSION_IMPL *session,
}
/* Rename the table. */
- WT_ERR(__metadata_rename(session, uri, newuri));
+ ret = __metadata_rename(session, uri, newuri);
-err: if (table != NULL && !tracked)
+err: if (!tracked)
WT_TRET(__wt_schema_release_table(session, table));
return (ret);
}
diff --git a/src/txn/txn_rollback_to_stable.c b/src/txn/txn_rollback_to_stable.c
index 7ce010834c2..54634c03dfb 100644
--- a/src/txn/txn_rollback_to_stable.c
+++ b/src/txn/txn_rollback_to_stable.c
@@ -307,13 +307,12 @@ __txn_rollback_to_stable_btree_walk(
* Called for each open handle - choose to either skip or wipe the commits
*/
static int
-__txn_rollback_to_stable_btree(
- WT_SESSION_IMPL *session, const char *cfg[])
+__txn_rollback_to_stable_btree(WT_SESSION_IMPL *session, const char *cfg[])
{
+ WT_BTREE *btree;
WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
WT_DECL_TIMESTAMP(rollback_timestamp)
- WT_BTREE *btree;
WT_TXN_GLOBAL *txn_global;
WT_UNUSED(cfg);
diff --git a/test/suite/test_alter02.py b/test/suite/test_alter02.py
index 3c5b67aeba5..3a288d7edf1 100644
--- a/test/suite/test_alter02.py
+++ b/test/suite/test_alter02.py
@@ -82,7 +82,7 @@ class test_alter02(wttest.WiredTigerTestCase):
self.session = self.conn.open_session()
# Verify the metadata string for this URI and that its setting in the
- # metdata file is correct.
+ # metadata file is correct.
def verify_metadata(self, metastr):
if metastr == '':
return
diff --git a/test/suite/test_bug010.py b/test/suite/test_bug010.py
index dfe317bf94e..1584c173053 100644
--- a/test/suite/test_bug010.py
+++ b/test/suite/test_bug010.py
@@ -40,7 +40,7 @@ class test_bug010(wttest.WiredTigerTestCase):
num_tables = 1000
# Disable checkpoint sync, to make checkpoints faster and
- # increase the likelyhood of triggering the symptom
+ # increase the likelihood of triggering the symptom
conn_config = 'checkpoint_sync=false'
def test_checkpoint_dirty(self):
diff --git a/test/suite/test_bulk01.py b/test/suite/test_bulk01.py
index da399faba2d..5cbb722d7a5 100644
--- a/test/suite/test_bulk01.py
+++ b/test/suite/test_bulk01.py
@@ -187,7 +187,7 @@ class test_bulk_load(wttest.WiredTigerTestCase):
if not wiredtiger.diagnostic_build():
self.skipTest('requires a diagnostic build')
- # Close explicitly, there's going to be a fallure.
+ # Close explicitly, there's going to be a failure.
msg = '/are incorrectly sorted/'
self.assertRaisesWithMessage(wiredtiger.WiredTigerError,
lambda: self.conn.close(), msg)
diff --git a/test/suite/test_colgap.py b/test/suite/test_colgap.py
index 01e52ea1da5..73feaf0dd8e 100644
--- a/test/suite/test_colgap.py
+++ b/test/suite/test_colgap.py
@@ -169,7 +169,7 @@ class test_colmax(wttest.WiredTigerTestCase):
bulk_config = "bulk"
cursor = self.session.open_cursor(uri, None, bulk_config)
- # Optionaly make the big record the only record in the table.
+ # Optionally make the big record the only record in the table.
if not self.single:
for i in range(1, 723):
cursor[simple_key(cursor, i)] = simple_value(cursor, i)
diff --git a/test/suite/test_empty.py b/test/suite/test_empty.py
index 82a3bb406ee..ad57bc78036 100644
--- a/test/suite/test_empty.py
+++ b/test/suite/test_empty.py
@@ -53,7 +53,7 @@ class test_empty(wttest.WiredTigerTestCase):
name = name + '.wt'
self.assertEquals(os.stat(name).st_size, 4*1024)
- # Open a new sesssion, add a few rows to an object and then remove them,
+ # Open a new session, add a few rows to an object and then remove them,
# then close the object. We open/close the object so it's flushed from
# the underlying cache each time.
def empty(self):
diff --git a/test/suite/test_encrypt04.py b/test/suite/test_encrypt04.py
index 7bbc4c617f1..3f9058404a8 100644
--- a/test/suite/test_encrypt04.py
+++ b/test/suite/test_encrypt04.py
@@ -42,7 +42,7 @@ class test_encrypt04(wttest.WiredTigerTestCase, suite_subprocess):
# For tests that are mismatching, we use a secretkey. The 'rotn'
# encryptor without a secretkey is too simple, and may leave
- # substantional portions of its input unchanged - a root page decoded
+ # substantial portions of its input unchanged - a root page decoded
# with simply the wrong keyid may appear valid when initially verified,
# but may result in error on first use. The odds that a real encryptor
# would leave a lot of its input unchanged is infinitesimally small.
@@ -175,7 +175,7 @@ class test_encrypt04(wttest.WiredTigerTestCase, suite_subprocess):
self.create_records(cursor, r, 0, self.nrecords)
cursor.close()
- # Now intentially expose the test to mismatched configuration
+ # Now intentionally expose the test to mismatched configuration
self.part = 2
self.name = self.name2
self.keyid = self.keyid2
diff --git a/test/suite/test_schema03.py b/test/suite/test_schema03.py
index e5471a4de73..ce6e3684980 100644
--- a/test/suite/test_schema03.py
+++ b/test/suite/test_schema03.py
@@ -133,7 +133,7 @@ class tabconfig:
rand = suite_random.suite_random(ncolumns, totalindices)
# Initially, all indices get one column from the collist.
- # Overlaps are allowed. Then probalistically, add some
+ # Overlaps are allowed. Then probabalistically, add some
# more columns.
for idx in self.idxlist:
prob = 1.0
diff --git a/test/suite/test_stat02.py b/test/suite/test_stat02.py
index d3bc18cb3e6..d7f66424c5d 100644
--- a/test/suite/test_stat02.py
+++ b/test/suite/test_stat02.py
@@ -243,7 +243,7 @@ class test_stat_cursor_dsrc_cache_walk(wttest.WiredTigerTestCase):
self.assertGreater(c[stat.dsrc.btree_entries][2], 0)
c.close()
- # Verify that cache and tree walk can operate independantly
+ # Verify that cache and tree walk can operate independently
self.conn.reconfigure('statistics=(all,clear)')
c = self.session.open_cursor(
'statistics:' + self.uri, None, 'statistics=(cache_walk,fast)')
diff --git a/test/suite/test_timestamp04.py b/test/suite/test_timestamp04.py
index 3af0feed31b..aa5b4fd9716 100644
--- a/test/suite/test_timestamp04.py
+++ b/test/suite/test_timestamp04.py
@@ -88,7 +88,7 @@ class test_timestamp04(wttest.WiredTigerTestCase, suite_subprocess):
self.skipTest('requires a timestamp build')
# Configure small page sizes to ensure eviction comes through and we have a
- # somewhat complex tree
+ # somewhat complex tree
self.session.create(self.uri,
'key_format=i,value_format=i,memory_page_max=32k,leaf_page_max=8k,internal_page_max=8k'
+ self.extra_config)
@@ -130,7 +130,7 @@ class test_timestamp04(wttest.WiredTigerTestCase, suite_subprocess):
self.check(self.session, 'read_timestamp=' + timestamp_str(2 * key_range),
dict((k, 2) for k in keys[:]))
- # Rollback a quater of the new commits
+ # Rollback a quarter of the new commits
self.conn.set_timestamp('stable_timestamp=' + timestamp_str(1 + key_range + key_range / 4))
self.conn.rollback_to_stable()
diff --git a/test/suite/test_util02.py b/test/suite/test_util02.py
index 59c34e6ef0e..b9bc3bd26c1 100644
--- a/test/suite/test_util02.py
+++ b/test/suite/test_util02.py
@@ -178,7 +178,7 @@ class test_load_commandline(wttest.WiredTigerTestCase, suite_subprocess):
else:
self.check_empty_file(errfile)
- # Empty arguments should suceed.
+ # Empty arguments should succeed.
def test_load_commandline_1(self):
self.load_commandline([], False)
@@ -199,7 +199,7 @@ class test_load_commandline(wttest.WiredTigerTestCase, suite_subprocess):
self.load_commandline([self.uri, "block_allocation=first"], False)
self.load_commandline(["table:bar", "block_allocation=first"], True)
- # You can specify multipleconfiguration arguments for the same object.
+ # You can specify multiple configuration arguments for the same object.
def test_load_commandline_5(self):
self.load_commandline([
self.uri, "block_allocation=first",