CDRIVER-4599 Reducing Warnings - MSVC and MinGW Compilation Warnings#1229
Merged
eramongodb merged 102 commits intomongodb:masterfrom Apr 14, 2023
Merged
CDRIVER-4599 Reducing Warnings - MSVC and MinGW Compilation Warnings#1229eramongodb merged 102 commits intomongodb:masterfrom
eramongodb merged 102 commits intomongodb:masterfrom
Conversation
kkloberdanz
suggested changes
Apr 5, 2023
kevinAlbs
approved these changes
Apr 7, 2023
kkloberdanz
approved these changes
Apr 7, 2023
vector-of-bool
approved these changes
Apr 13, 2023
Contributor
vector-of-bool
left a comment
There was a problem hiding this comment.
Sorry for the long delay on this one. LGTM.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR is a followup to #1221 that resolves CDRIVER-4599 by addressing all remaining compilation warnings generated by MSVC and MinGW on the current Evergreen matrix for the following CMake targets:
add_exampleexecutables undersrc/libbsonmongoc_add_testexecutables undersrc/libmongocmongoc_add_exampleexecutables undersrc/libmongocVerified by this patch, which temporarily adds
/WXor-Werrorto the aforementioned CMake targets under src/libbson and src/libmongoc. As with the prior PR, these flags are not included in this PR.The scope of this PR is limited to MSVC and MinGW warnings for the aforementioned CMake targets. A followup PR may eventually address warnings generated by GCC and Clang as well.
Stats
Given the same method as described in #1221, relative to 9ef1cc9, this PR reduces the total number of warnings emitted by:
and the total number of unique warnings by:
Note: the warning counts do not include D9025 command line option override warnings generated by the kms_message and zlib libraries.
Methodology
In addition to the methods described in #1221:
-Wmissing-braces Warnings
The
MCD_AZURE_IMDS_REQUEST_INITmacro was added to mcd-azure.h to address this warning when initializingmcd_azure_imds_requestobjects.The
_initdata member was added to the unionmongoc_rpc_tin mongoc-rpc-private.h to address this warning. The_initdata member is only used to ensure the object is zero-initialized without unnecessarily specifying a specific union member as being active by default.C4091 Warning Generated by DbgHelp.h
This warning was observed when compiling on some MSVC versions. Opted to suppress this warning as it is not caused by our code (source of warning is in
DbgHelp.h).C4756 Constant Arithmetic Overflow Warnings
The use of the
INFINITYmacro intest-json.cprompted the addition of the/wd4756compile option for thetest-libmongoc-liblibrary as done in #1221.C4996 Deprecated Function Warnings
This is already tracked by CDRIVER-4263. Suppressions were added accordingly.
Changes to Internal APIs
Some notable changes to private interfaces include:
mongoc-set-private.h
Changed the
idxparameter type frominttosize_tfor functionsmongoc_set_get_item*.mongoc-gridfs-bucket-file-private.h
Changed the
bytes_readdata member type in structmongoc_gridfs_bucket_file_tfromint32_ttosize_t.mongoc-buffer-private.h
Changed the
timeout_msecparameter type fromint32_ttoint64_tfor functions_mongoc_buffer_*, which now either return an error or log an error message whentimeout_msecis not representable as anint32_t.The scope of applicable changes was limited by CDRIVER-4589.
mongoc-stream-private.h
Changed the
timeout_msecparameter type fromint32_ttoint64_tfor function_mongoc_stream_writev_full, which now returns an error iftimeout_msecis not representable as anint32_t.The scope of applicable changes was limited by CDRIVER-4589.
mongoc-server-monitor.c
Changed the
(min_)heartbeat_frequency_msdata member types in struct_mongoc_server_monitor_tfromuint64_ttoint64_t.Changed the
request_iddata member type in struct_mongoc_server_monitor_tfromint64_ttoint32_t.The function
_server_monitor_awaitable_hellonow appendsmaxAwaitTimeMSto the awaitable hello command document as anInt64instead of anInt32!Scope of applicable changes was limited by CDRIVER-4589.
mongoc-stream-tls-private.h
Changed the
timeout_msecdata member type fromint32_ttoint64_t, which now causes the following functions to log an error message iftimeout_msecis not representable as anint32_t:The scope of applicable changes was limited by CDRIVER-4589.
mongoc-secure-channel-private.h
Changed the return type of functions
mongoc_secure_channel_(read|write)fromsize_ttossize_t.Moved declaration ownership of the function
mongoc_secure_channel_writeintomongoc-secure-channel-private.h(previously manually declared inmongoc-stream-tls-secure-channel.c).mongoc-topology-private.h
Changed the
max_hostsparameter type for function_mongoc_apply_srv_max_hostsfromint32_ttosize_t.mongoc-topology-description-private.h
Changed the
local_threshold_msparameter type for functionmongoc_topology_description_suitable_serversfromsize_ttoint64_t.mongoc-host-list-private.h
Changed the return type of function
_mongoc_host_list_lengthfrominttosize_t.mongoc-cluster-aws-private.h
Changed the
sts_fqdn_lenparameter type fromuint32_ttosize_tfor_mongoc_validate_and_derive_region.TestSuite.h
Changed the implementation of
ASSERT_CMPTIMEandASSERT_WITHIN_TIME_INTERVALfrom usingASSERT_CMPINTtoASSERT_CMPINT64for consistency with the return type of functionbson_get_monotonic_type.mock-rs.h
Changed the
idparameter type for functionmock_rs_electfrominttosize_t.request.h
Changed the
nparameter type for functionrequest_get_docfrominttosize_t.