summaryrefslogtreecommitdiff
path: root/src/schema
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/schema
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/schema')
-rw-r--r--src/schema/schema_truncate.c11
1 files changed, 4 insertions, 7 deletions
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);