summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2016-03-11 08:52:22 -0500
committerKeith Bostic <keith@wiredtiger.com>2016-03-11 08:52:22 -0500
commit5e4766ff71886b0a00d4c56315dd55759cdf3811 (patch)
tree5bb6cae75d740626dace775668f36743fab1763f /src
parentd1a59d8d5342fcaaa194a31a60ca6c4c9c55ba43 (diff)
downloadmongo-5e4766ff71886b0a00d4c56315dd55759cdf3811.tar.gz
SERVER-23040: Coverity analysis defect 98151: Dereference after null check
We always truncate in cursor-forward direction, there's never a case where we don't have a "start" cursor. Simplify some code and stop checking if the start cursor is set or not.
Diffstat (limited to 'src')
-rw-r--r--src/btree/bt_cursor.c12
-rw-r--r--src/schema/schema_truncate.c11
2 files changed, 6 insertions, 17 deletions
diff --git a/src/btree/bt_cursor.c b/src/btree/bt_cursor.c
index c11b7d35de6..d64b6064268 100644
--- a/src/btree/bt_cursor.c
+++ b/src/btree/bt_cursor.c
@@ -1162,22 +1162,14 @@ int
__wt_btcur_range_truncate(WT_CURSOR_BTREE *start, WT_CURSOR_BTREE *stop)
{
WT_BTREE *btree;
- WT_CURSOR_BTREE *cbt;
WT_DECL_RET;
WT_SESSION_IMPL *session;
- cbt = (start != NULL) ? start : stop;
- session = (WT_SESSION_IMPL *)cbt->iface.session;
- btree = cbt->btree;
+ session = (WT_SESSION_IMPL *)start->iface.session;
+ btree = start->btree;
WT_STAT_FAST_DATA_INCR(session, cursor_truncate);
/*
- * We always delete in a forward direction because it's faster, assert
- * our caller provided us with a start cursor.
- */
- WT_ASSERT(session, start != NULL);
-
- /*
* For recovery, log the start and stop keys for a truncate operation,
* not the individual records removed. On the other hand, for rollback
* we need to keep track of all the in-memory operations.
diff --git a/src/schema/schema_truncate.c b/src/schema/schema_truncate.c
index e7752b60ca4..d9a798b6ed8 100644
--- a/src/schema/schema_truncate.c
+++ b/src/schema/schema_truncate.c
@@ -131,22 +131,19 @@ int
__wt_schema_range_truncate(
WT_SESSION_IMPL *session, WT_CURSOR *start, WT_CURSOR *stop)
{
- WT_CURSOR *cursor;
WT_DATA_SOURCE *dsrc;
WT_DECL_RET;
const char *uri;
- cursor = (start != NULL) ? start : stop;
- uri = cursor->internal_uri;
+ uri = start->internal_uri;
if (WT_PREFIX_MATCH(uri, "file:")) {
- if (start != NULL)
- WT_CURSOR_NEEDKEY(start);
+ WT_CURSOR_NEEDKEY(start);
if (stop != NULL)
WT_CURSOR_NEEDKEY(stop);
- WT_WITH_BTREE(session, ((WT_CURSOR_BTREE *)cursor)->btree,
+ WT_WITH_BTREE(session, ((WT_CURSOR_BTREE *)start)->btree,
ret = __wt_btcur_range_truncate(
- (WT_CURSOR_BTREE *)start, (WT_CURSOR_BTREE *)stop));
+ (WT_CURSOR_BTREE *)start, (WT_CURSOR_BTREE *)stop));
} else if (WT_PREFIX_MATCH(uri, "table:"))
ret = __wt_table_range_truncate(
(WT_CURSOR_TABLE *)start, (WT_CURSOR_TABLE *)stop);