-
Notifications
You must be signed in to change notification settings - Fork 455
CDRIVER-4599 Reducing Warnings - MSVC and MinGW Compilation Warnings #1229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the long delay on this one. LGTM.
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_example
executables undersrc/libbson
mongoc_add_test
executables undersrc/libmongoc
mongoc_add_example
executables undersrc/libmongoc
Verified by this patch, which temporarily adds
/WX
or-Werror
to 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_INIT
macro was added to mcd-azure.h to address this warning when initializingmcd_azure_imds_request
objects.The
_init
data member was added to the unionmongoc_rpc_t
in mongoc-rpc-private.h to address this warning. The_init
data 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
INFINITY
macro intest-json.c
prompted the addition of the/wd4756
compile option for thetest-libmongoc-lib
library 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
idx
parameter type fromint
tosize_t
for functionsmongoc_set_get_item*
.mongoc-gridfs-bucket-file-private.h
Changed the
bytes_read
data member type in structmongoc_gridfs_bucket_file_t
fromint32_t
tosize_t
.mongoc-buffer-private.h
Changed the
timeout_msec
parameter type fromint32_t
toint64_t
for functions_mongoc_buffer_*
, which now either return an error or log an error message whentimeout_msec
is not representable as anint32_t
.The scope of applicable changes was limited by CDRIVER-4589.
mongoc-stream-private.h
Changed the
timeout_msec
parameter type fromint32_t
toint64_t
for function_mongoc_stream_writev_full
, which now returns an error iftimeout_msec
is not representable as anint32_t
.The scope of applicable changes was limited by CDRIVER-4589.
mongoc-server-monitor.c
Changed the
(min_)heartbeat_frequency_ms
data member types in struct_mongoc_server_monitor_t
fromuint64_t
toint64_t
.Changed the
request_id
data member type in struct_mongoc_server_monitor_t
fromint64_t
toint32_t
.The function
_server_monitor_awaitable_hello
now appendsmaxAwaitTimeMS
to the awaitable hello command document as anInt64
instead of anInt32
!Scope of applicable changes was limited by CDRIVER-4589.
mongoc-stream-tls-private.h
Changed the
timeout_msec
data member type fromint32_t
toint64_t
, which now causes the following functions to log an error message iftimeout_msec
is 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_t
tossize_t
.Moved declaration ownership of the function
mongoc_secure_channel_write
intomongoc-secure-channel-private.h
(previously manually declared inmongoc-stream-tls-secure-channel.c
).mongoc-topology-private.h
Changed the
max_hosts
parameter type for function_mongoc_apply_srv_max_hosts
fromint32_t
tosize_t
.mongoc-topology-description-private.h
Changed the
local_threshold_ms
parameter type for functionmongoc_topology_description_suitable_servers
fromsize_t
toint64_t
.mongoc-host-list-private.h
Changed the return type of function
_mongoc_host_list_length
fromint
tosize_t
.mongoc-cluster-aws-private.h
Changed the
sts_fqdn_len
parameter type fromuint32_t
tosize_t
for_mongoc_validate_and_derive_region
.TestSuite.h
Changed the implementation of
ASSERT_CMPTIME
andASSERT_WITHIN_TIME_INTERVAL
from usingASSERT_CMPINT
toASSERT_CMPINT64
for consistency with the return type of functionbson_get_monotonic_type
.mock-rs.h
Changed the
id
parameter type for functionmock_rs_elect
fromint
tosize_t
.request.h
Changed the
n
parameter type for functionrequest_get_doc
fromint
tosize_t
.