Skip to content

Commit 7c229ac

Browse files
authored
Reduce Warnings - implicit-fallthrough, switch-enum, extra-semi-stmt, unneeded-member-function (#1212)
* Address -Wimplicit-fallthrough warnings * Address -Wextra-semi-stmt warnings * Address -Wswitch-enum warnings * Address -Wunneeded-member-function warnings
1 parent ff7e7bd commit 7c229ac

File tree

11 files changed

+307
-2
lines changed

11 files changed

+307
-2
lines changed

src/bsoncxx/test/type_traits.test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// We declare variables that are only used for compilation checking
1111
BSONCXX_DISABLE_WARNING(GNU("-Wunused"));
1212
BSONCXX_DISABLE_WARNING(Clang("-Wunused-template"));
13+
BSONCXX_DISABLE_WARNING(Clang("-Wunneeded-member-function"));
1314

1415
namespace {
1516

src/mongocxx/test/client_helpers.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,25 @@ bsoncxx::array::value transform_array(bsoncxx::array::view view,
116116
builder.append(transform_array(v.get_array().value, fcn, context));
117117
break;
118118

119+
case bsoncxx::type::k_double:
120+
case bsoncxx::type::k_string:
121+
case bsoncxx::type::k_binary:
122+
case bsoncxx::type::k_undefined:
123+
case bsoncxx::type::k_oid:
124+
case bsoncxx::type::k_bool:
125+
case bsoncxx::type::k_date:
126+
case bsoncxx::type::k_null:
127+
case bsoncxx::type::k_regex:
128+
case bsoncxx::type::k_dbpointer:
129+
case bsoncxx::type::k_code:
130+
case bsoncxx::type::k_symbol:
131+
case bsoncxx::type::k_codewscope:
132+
case bsoncxx::type::k_int32:
133+
case bsoncxx::type::k_timestamp:
134+
case bsoncxx::type::k_int64:
135+
case bsoncxx::type::k_decimal128:
136+
case bsoncxx::type::k_maxkey:
137+
case bsoncxx::type::k_minkey:
119138
default:
120139
builder.append(v);
121140
break;
@@ -159,6 +178,25 @@ bsoncxx::document::value transform_document_recursive(bsoncxx::document::view vi
159178
k, transform_array(v.get_array().value, fcn, context)));
160179
break;
161180

181+
case bsoncxx::type::k_double:
182+
case bsoncxx::type::k_string:
183+
case bsoncxx::type::k_binary:
184+
case bsoncxx::type::k_undefined:
185+
case bsoncxx::type::k_oid:
186+
case bsoncxx::type::k_bool:
187+
case bsoncxx::type::k_date:
188+
case bsoncxx::type::k_null:
189+
case bsoncxx::type::k_regex:
190+
case bsoncxx::type::k_dbpointer:
191+
case bsoncxx::type::k_code:
192+
case bsoncxx::type::k_symbol:
193+
case bsoncxx::type::k_codewscope:
194+
case bsoncxx::type::k_int32:
195+
case bsoncxx::type::k_timestamp:
196+
case bsoncxx::type::k_int64:
197+
case bsoncxx::type::k_decimal128:
198+
case bsoncxx::type::k_maxkey:
199+
case bsoncxx::type::k_minkey:
162200
default:
163201
builder.append(bsoncxx::builder::basic::kvp(k, v));
164202
break;

src/mongocxx/test/client_helpers.hh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,10 @@ cseeos_result client_side_encryption_enabled_or_skip_impl();
235235
break; \
236236
case mongocxx::test_util::cseeos_result::skip: \
237237
SKIP("CSE environemnt variables not set"); \
238+
break; \
238239
case mongocxx::test_util::cseeos_result::fail: \
239240
FAIL("One or more CSE environment variable is missing"); \
241+
break; \
240242
} \
241243
} else \
242244
((void)0)

src/mongocxx/test/client_side_encryption.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3377,6 +3377,12 @@ TEST_CASE("Range Explicit Encryption", "[client_side_encryption]") {
33773377
// This test case should be skipped if the encrypted field is
33783378
// `encryptedDoubleNoPrecision` or `encryptedDecimalNoPrecision`.
33793379
break;
3380+
3381+
case RangeFieldType::DecimalPrecision:
3382+
case RangeFieldType::DoublePrecision:
3383+
case RangeFieldType::Date:
3384+
case RangeFieldType::Int:
3385+
case RangeFieldType::Long:
33803386
default: {
33813387
SECTION("Case 6: encrypting a document greater than the maximum errors") {
33823388
const auto original = to_field_value(201, field_type);
@@ -3413,6 +3419,12 @@ TEST_CASE("Range Explicit Encryption", "[client_side_encryption]") {
34133419
// This test case should be skipped if the encrypted field is
34143420
// `encryptedDoubleNoPrecision`.
34153421
break;
3422+
3423+
case RangeFieldType::DecimalPrecision:
3424+
case RangeFieldType::DoublePrecision:
3425+
case RangeFieldType::Date:
3426+
case RangeFieldType::Int:
3427+
case RangeFieldType::Long:
34163428
default: {
34173429
SECTION("Case 7: encrypting a document of a different type errors") {
34183430
// For all the tests below use these EncryptOpts:
@@ -3454,6 +3466,10 @@ TEST_CASE("Range Explicit Encryption", "[client_side_encryption]") {
34543466
// `encryptedDoublePrecision` or `encryptedDoubleNoPrecision` or
34553467
// `encryptedDecimalPrecision` or `encryptedDecimalNoPrecision`.
34563468
break;
3469+
3470+
case RangeFieldType::Date:
3471+
case RangeFieldType::Int:
3472+
case RangeFieldType::Long:
34573473
default: {
34583474
SECTION("Case 8: setting precision errors if the type is not a double") {
34593475
// Use `clientEncryption.encrypt()` to try to encrypt the value 6 with these

src/mongocxx/test/options/create_collection.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ TEST_CASE("create_collection accessors/mutators", "[create_collection]") {
4444
auto validation = validation_criteria{}.rule(make_document(kvp("a", 1)));
4545

4646
CHECK_OPTIONAL_ARGUMENT(cc, capped, true);
47-
BSONCXX_SUPPRESS_DEPRECATION_WARNINGS_BEGIN;
48-
BSONCXX_SUPPRESS_DEPRECATION_WARNINGS_END;
4947
CHECK_OPTIONAL_ARGUMENT(cc, size, 5);
5048
CHECK_OPTIONAL_ARGUMENT(cc, max, 2);
5149
CHECK_OPTIONAL_ARGUMENT(cc, collation, collation.view());

src/mongocxx/test/spec/initial_dns_seedlist_discovery.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,33 @@ static void assert_elements_equal(bsoncxx::document::element expected_option,
8686
case bsoncxx::type::k_int32:
8787
REQUIRE(expected_option.get_int32() == my_option.get_int32());
8888
break;
89+
8990
case bsoncxx::type::k_bool:
9091
REQUIRE(expected_option.get_bool() == my_option.get_bool());
9192
break;
93+
9294
case bsoncxx::type::k_string:
9395
REQUIRE(expected_option.get_string() == my_option.get_string());
9496
break;
97+
98+
case bsoncxx::type::k_double:
99+
case bsoncxx::type::k_document:
100+
case bsoncxx::type::k_array:
101+
case bsoncxx::type::k_binary:
102+
case bsoncxx::type::k_undefined:
103+
case bsoncxx::type::k_oid:
104+
case bsoncxx::type::k_date:
105+
case bsoncxx::type::k_null:
106+
case bsoncxx::type::k_regex:
107+
case bsoncxx::type::k_dbpointer:
108+
case bsoncxx::type::k_code:
109+
case bsoncxx::type::k_symbol:
110+
case bsoncxx::type::k_codewscope:
111+
case bsoncxx::type::k_timestamp:
112+
case bsoncxx::type::k_int64:
113+
case bsoncxx::type::k_decimal128:
114+
case bsoncxx::type::k_maxkey:
115+
case bsoncxx::type::k_minkey:
95116
default:
96117
std::string msg =
97118
"option type not handled: " + bsoncxx::to_string(expected_option.type());

src/mongocxx/test/spec/operation.cpp

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@ document::value operation_runner::_run_find_one_and_update(document::view operat
572572
}
573573
break;
574574
}
575+
575576
case bsoncxx::type::k_array: {
576577
pipeline update = build_pipeline(arguments["update"].get_array().value);
577578
if (session) {
@@ -581,6 +582,26 @@ document::value operation_runner::_run_find_one_and_update(document::view operat
581582
}
582583
break;
583584
}
585+
586+
case bsoncxx::type::k_double:
587+
case bsoncxx::type::k_string:
588+
case bsoncxx::type::k_binary:
589+
case bsoncxx::type::k_undefined:
590+
case bsoncxx::type::k_oid:
591+
case bsoncxx::type::k_bool:
592+
case bsoncxx::type::k_date:
593+
case bsoncxx::type::k_null:
594+
case bsoncxx::type::k_regex:
595+
case bsoncxx::type::k_dbpointer:
596+
case bsoncxx::type::k_code:
597+
case bsoncxx::type::k_symbol:
598+
case bsoncxx::type::k_codewscope:
599+
case bsoncxx::type::k_int32:
600+
case bsoncxx::type::k_timestamp:
601+
case bsoncxx::type::k_int64:
602+
case bsoncxx::type::k_decimal128:
603+
case bsoncxx::type::k_maxkey:
604+
case bsoncxx::type::k_minkey:
584605
default:
585606
throw std::logic_error{"update must be a document or an array"};
586607
}
@@ -778,6 +799,7 @@ document::value operation_runner::_run_update_many(document::view operation) {
778799
}
779800
break;
780801
}
802+
781803
case bsoncxx::type::k_array: {
782804
pipeline update = build_pipeline(arguments["update"].get_array().value);
783805
if (session) {
@@ -787,6 +809,26 @@ document::value operation_runner::_run_update_many(document::view operation) {
787809
}
788810
break;
789811
}
812+
813+
case bsoncxx::type::k_double:
814+
case bsoncxx::type::k_string:
815+
case bsoncxx::type::k_binary:
816+
case bsoncxx::type::k_undefined:
817+
case bsoncxx::type::k_oid:
818+
case bsoncxx::type::k_bool:
819+
case bsoncxx::type::k_date:
820+
case bsoncxx::type::k_null:
821+
case bsoncxx::type::k_regex:
822+
case bsoncxx::type::k_dbpointer:
823+
case bsoncxx::type::k_code:
824+
case bsoncxx::type::k_symbol:
825+
case bsoncxx::type::k_codewscope:
826+
case bsoncxx::type::k_int32:
827+
case bsoncxx::type::k_timestamp:
828+
case bsoncxx::type::k_int64:
829+
case bsoncxx::type::k_decimal128:
830+
case bsoncxx::type::k_maxkey:
831+
case bsoncxx::type::k_minkey:
790832
default:
791833
throw std::logic_error{"update must be a document or an array"};
792834
}
@@ -870,6 +912,7 @@ document::value operation_runner::_run_update_one(document::view operation) {
870912
}
871913
break;
872914
}
915+
873916
case bsoncxx::type::k_array: {
874917
pipeline update = build_pipeline(arguments["update"].get_array().value);
875918
if (session) {
@@ -879,6 +922,26 @@ document::value operation_runner::_run_update_one(document::view operation) {
879922
}
880923
break;
881924
}
925+
926+
case bsoncxx::type::k_double:
927+
case bsoncxx::type::k_string:
928+
case bsoncxx::type::k_binary:
929+
case bsoncxx::type::k_undefined:
930+
case bsoncxx::type::k_oid:
931+
case bsoncxx::type::k_bool:
932+
case bsoncxx::type::k_date:
933+
case bsoncxx::type::k_null:
934+
case bsoncxx::type::k_regex:
935+
case bsoncxx::type::k_dbpointer:
936+
case bsoncxx::type::k_code:
937+
case bsoncxx::type::k_symbol:
938+
case bsoncxx::type::k_codewscope:
939+
case bsoncxx::type::k_int32:
940+
case bsoncxx::type::k_timestamp:
941+
case bsoncxx::type::k_int64:
942+
case bsoncxx::type::k_decimal128:
943+
case bsoncxx::type::k_maxkey:
944+
case bsoncxx::type::k_minkey:
882945
default:
883946
throw std::logic_error{"update must be a document or an array"};
884947
}
@@ -966,10 +1029,31 @@ T _build_update_model(document::view arguments) {
9661029
case bsoncxx::type::k_document: {
9671030
return T(filter, arguments["update"].get_document().value);
9681031
}
1032+
9691033
case bsoncxx::type::k_array: {
9701034
pipeline update = build_pipeline(arguments["update"].get_array().value);
9711035
return T(filter, update);
9721036
}
1037+
1038+
case bsoncxx::type::k_double:
1039+
case bsoncxx::type::k_string:
1040+
case bsoncxx::type::k_binary:
1041+
case bsoncxx::type::k_undefined:
1042+
case bsoncxx::type::k_oid:
1043+
case bsoncxx::type::k_bool:
1044+
case bsoncxx::type::k_date:
1045+
case bsoncxx::type::k_null:
1046+
case bsoncxx::type::k_regex:
1047+
case bsoncxx::type::k_dbpointer:
1048+
case bsoncxx::type::k_code:
1049+
case bsoncxx::type::k_symbol:
1050+
case bsoncxx::type::k_codewscope:
1051+
case bsoncxx::type::k_int32:
1052+
case bsoncxx::type::k_timestamp:
1053+
case bsoncxx::type::k_int64:
1054+
case bsoncxx::type::k_decimal128:
1055+
case bsoncxx::type::k_maxkey:
1056+
case bsoncxx::type::k_minkey:
9731057
default:
9741058
throw std::logic_error{"update must be a document or an array"};
9751059
}

src/mongocxx/test/spec/unified_tests/assert.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,11 @@ void assert::matches(types::bson_value::view actual,
247247
case bsoncxx::type::k_document:
248248
matches_document(actual, expected, map, is_root);
249249
return;
250+
250251
case bsoncxx::type::k_array:
251252
matches_array(actual, expected, map, is_array_of_root_docs);
252253
return;
254+
253255
case bsoncxx::type::k_int32:
254256
case bsoncxx::type::k_int64:
255257
case bsoncxx::type::k_double: {
@@ -267,6 +269,23 @@ void assert::matches(types::bson_value::view actual,
267269
BSONCXX_POP_WARNINGS();
268270
return;
269271
}
272+
273+
case bsoncxx::type::k_string:
274+
case bsoncxx::type::k_binary:
275+
case bsoncxx::type::k_undefined:
276+
case bsoncxx::type::k_oid:
277+
case bsoncxx::type::k_bool:
278+
case bsoncxx::type::k_date:
279+
case bsoncxx::type::k_null:
280+
case bsoncxx::type::k_regex:
281+
case bsoncxx::type::k_dbpointer:
282+
case bsoncxx::type::k_code:
283+
case bsoncxx::type::k_symbol:
284+
case bsoncxx::type::k_codewscope:
285+
case bsoncxx::type::k_timestamp:
286+
case bsoncxx::type::k_decimal128:
287+
case bsoncxx::type::k_maxkey:
288+
case bsoncxx::type::k_minkey:
270289
default: {
271290
CAPTURE(is_root,
272291
to_string(actual.type()),

0 commit comments

Comments
 (0)