-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Mono] Fix warnings to enable W4 on Windows. #66710
[Mono] Fix warnings to enable W4 on Windows. #66710
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
3f6fbb8
to
e29a0b8
Compare
@lateralusX Is this helping to contribute to #66154? |
If so, I would also add the following to help ensure regressions are caught early.
|
Yes, that was my plan to do in this PR, once I worked it through. |
This PR is mainly upstreaming other work getting W4 building on Mono, so not explicitly target any of those warnings, but yet another stepping stone bringing down warnings altogether on Mono while still bumping to W4. I think I will be able to take care of: #pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned as part of this PR, so will add some progression on #66154 as well. |
e026c33
to
49b688f
Compare
@@ -6433,7 +6429,7 @@ get_types_for_source_file (gpointer key, gpointer value, gpointer user_data) | |||
files = get_source_files_for_type (klass); | |||
g_hash_table_insert (info->source_files, klass, files); | |||
|
|||
for (int i = 0; i < files->len; ++i) { | |||
for (guint i = 0; i < files->len; ++i) { |
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.
Can we change GPtrArray->len to an int instead ?
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.
Yes we probably could, did a quick test and it still builds without additional warnings. Any particular reason to do that, except that we might have usage in many places that do int i when iterating it? It will also affect the signature of g_ptr_array_remove_* that currently accept indexes to go from guint to int.
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.
Changing it to int would reduce the amount of changes required and make it easier to write code to iterate on it.
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.
So for the warnings, this PR makes sure all builds as expected, but enabling more warnings might trigger more warnings related to doing unsinged->signed conversion. This PR is already very big, and I mainly did small number of changes like the one above, just to align with original types in files already touched. Could an alternative be to look into that when we enable some additional warnings that will trigger errors due to singed/unsigned mismatch? An alternative would be to revert all of the int i -> source type in this PR and then take care of all in separate PR when enabling more warnings where we also could discuss if we should change type when iterating or at the source. So mainly three options for this PR:
- Leave as is, changes done so far will simplify future fixes of warnings, but might need to be change back in a couple of places if we change any of the source types like len -> int.
- Revert the int i -> source type done in this PR (unless it breaks some other warnings enabled by this PR).
- Change len to int and fix all usage of it as part of this PR, includes changing some of the array API's as well, but as said, this PR is already big enough.
Thoughts?
@@ -529,14 +529,14 @@ hot_reload_close_all (MonoImage *base_image) | |||
if (!info) | |||
return; | |||
for (GList *ptr = info->delta_info; ptr; ptr = ptr->next) { | |||
DeltaInfo *info = (DeltaInfo *)ptr->data; | |||
if (!info) | |||
DeltaInfo *delta_info = (DeltaInfo *)ptr->data; |
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.
What was the problem here ?
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.
That change was mainly aligning the last DeltaInfo *info to use same naming as all others in this file, delta_info, the other change in this file fix a local hiding issue, warning C4456: declaration of 'info' hides previous local declaration, that was very common through the code and fixed in this PR.
9ce5ecc
to
c81c2b0
Compare
0e88c45
to
277a366
Compare
Rebased and fixed review feedback. |
# Conflicts: # src/mono/mono/component/debugger-agent.c # Conflicts: # src/mono/mono/component/debugger-agent.c
# Conflicts: # src/mono/mono/mini/method-to-ir.c # Conflicts: # src/mono/mono/mini/aot-runtime.c
# Conflicts: # src/mono/mono/component/hot_reload.c
4a86047
to
0617776
Compare
Moved disable of zlib warnings from source file into cmake file + rebase branch. |
Upstream work done in different downstream repros.
Fix selected W4 warnings on Windows as well as suppressing specific W4 warnings to be fixed. Give us option to do Mono runtime build using W4 on Windows and also turn on warnings as errors to prevent regressions on the warnings we enable.
Fix Warning C4146 in Mono runtime build.
Enable "Treat Warnings As Errors" to prevent regressions on the warnings we decided to fix.