summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Chen <luke.chen@mongodb.com>2021-06-11 16:13:50 +1000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-06-11 06:37:22 +0000
commit25b30cfeb6af601e44c752066b807b8c88844c14 (patch)
tree5b69e710269b240d2fe922816c9dd0679793012c
parentaa1e6d41cd35baaeb7651ef3d3ec140184703ad9 (diff)
downloadmongo-25b30cfeb6af601e44c752066b807b8c88844c14.tar.gz
Import wiredtiger: bfb4d5ee40e0ef36482478088fab48583baae54c from branch mongodb-5.0
ref: 47a6ec641b..bfb4d5ee40 for: 5.1.0 WT-7583 Coverity analysis defect 114074: Logically dead code (rework)
-rw-r--r--src/third_party/wiredtiger/import.data2
-rw-r--r--src/third_party/wiredtiger/test/csuite/incr_backup/main.c26
2 files changed, 22 insertions, 6 deletions
diff --git a/src/third_party/wiredtiger/import.data b/src/third_party/wiredtiger/import.data
index f52b3d69242..51da7c4324f 100644
--- a/src/third_party/wiredtiger/import.data
+++ b/src/third_party/wiredtiger/import.data
@@ -2,5 +2,5 @@
"vendor": "wiredtiger",
"github": "wiredtiger/wiredtiger.git",
"branch": "mongodb-5.0",
- "commit": "47a6ec641bc6d35c3f4fc28ba671e0d81c45055c"
+ "commit": "bfb4d5ee40e0ef36482478088fab48583baae54c"
}
diff --git a/src/third_party/wiredtiger/test/csuite/incr_backup/main.c b/src/third_party/wiredtiger/test/csuite/incr_backup/main.c
index b09e1b44da4..2e269dd8df5 100644
--- a/src/third_party/wiredtiger/test/csuite/incr_backup/main.c
+++ b/src/third_party/wiredtiger/test/csuite/incr_backup/main.c
@@ -110,7 +110,9 @@ extern int __wt_optind;
extern char *__wt_optarg;
/*
- * The choices of operations we do to each table.
+ * The choices of operations we do to each table. Please do not initialize enum elements with custom
+ * values as there's an assumption that the first element has the default value of 0 and the last
+ * element is always reserved to check count on elements.
*/
typedef enum { INSERT, MODIFY, REMOVE, UPDATE, _OPERATION_TYPE_COUNT } OPERATION_TYPE;
@@ -370,7 +372,14 @@ table_changes(WT_SESSION *session, TABLE *table)
item.size = table->max_value_size;
key_value(change_count, key, sizeof(key), &item, &op_type);
cur->set_key(cur, key);
- testutil_assert(op_type < _OPERATION_TYPE_COUNT);
+
+ /*
+ * To satisfy code analysis checks, we must handle all elements of the enum in the
+ * switch statement. For that reason we use the "less or equal" operator in the assert
+ * condition below to test the upper boundary. We check the lower boundary against 0
+ * since this is the default value of the first element in any enum.
+ */
+ testutil_assert(op_type >= 0 && op_type <= _OPERATION_TYPE_COUNT);
switch (op_type) {
case INSERT:
cur->set_value(cur, &item);
@@ -393,7 +402,7 @@ table_changes(WT_SESSION *session, TABLE *table)
testutil_check(cur->update(cur));
break;
case _OPERATION_TYPE_COUNT:
- break;
+ testutil_die(0, "Unexpected OPERATION_TYPE: _OPERATION_TYPE_COUNT");
}
}
free(value);
@@ -686,7 +695,14 @@ check_table(WT_SESSION *session, TABLE *table)
value = dcalloc(1, table->max_value_size);
VERBOSE(3, "Checking: %s\n", table->name);
- testutil_assert(op_type < _OPERATION_TYPE_COUNT);
+
+ /*
+ * To satisfy code analysis checks, we must handle all elements of the enum in the switch
+ * statement. For that reason we use the "less or equal" operator in the assert condition below
+ * to test the upper boundary. We check the lower boundary against 0 since this is the default
+ * value of the first element in any enum.
+ */
+ testutil_assert(op_type >= 0 && op_type <= _OPERATION_TYPE_COUNT);
switch (op_type) {
case INSERT:
expect_records = total_changes % KEYS_PER_TABLE;
@@ -699,7 +715,7 @@ check_table(WT_SESSION *session, TABLE *table)
expect_records = KEYS_PER_TABLE - (total_changes % KEYS_PER_TABLE);
break;
case _OPERATION_TYPE_COUNT:
- break;
+ testutil_die(0, "Unexpected OPERATION_TYPE: _OPERATION_TYPE_COUNT");
}
testutil_check(session->open_cursor(session, table->name, NULL, NULL, &cursor));