Skip to content
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

Remove implicit narrowing conversions from zlib #91245

Merged
merged 2 commits into from
Aug 30, 2023

Conversation

GrabYourPitchforks
Copy link
Member

Allows us to reenable mandatory MSVC C4244 compiler warning and clang's "implicit-int-conversion" warning.

See the individual .patch files for a description of the changes and justification of their correctness.

and clang implicit-int-conversion

Descriptions of each changes are in the respective .patch files.
@ghost
Copy link

ghost commented Aug 28, 2023

Tagging subscribers to this area: @dotnet/area-system-io-compression
See info in area-owners.md if you want to be subscribed.

Issue Details

Allows us to reenable mandatory MSVC C4244 compiler warning and clang's "implicit-int-conversion" warning.

See the individual .patch files for a description of the changes and justification of their correctness.

Author: GrabYourPitchforks
Assignees: -
Labels:

area-System.IO.Compression

Milestone: -

@GrabYourPitchforks
Copy link
Member Author

GrabYourPitchforks commented Aug 28, 2023

Testing: On my Windows x64 box, I validated the zlib-intel build under MSVC. Then I changed my local .cmake files to force usage of zlib instead of zlib-intel and validated that it built correctly under MSVC. On my WSL box, I modified my local .cmake files to force it to use these zlib sources instead of the OS's inbox zlib. I also injected an #error line into deflate.c just to confirm that clang was in fact using our local files.

I also do plan on submitting this upstream to both zlib and zlib-intel if it passes review here, since others could also benefit from these changes.

This PR shouldn't introduce any behavioral changes, since it should produce the same AST under the covers. It just makes the casts explicit instead of implicit so that we can re-enable required warnings.

@carlossanlop
Copy link
Member

Is it your intention to get this backported to 8.0?

Copy link
Member

@carlossanlop carlossanlop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No blocking comments, just two questions for my own education and a small suggestion. Thanks for submitting this change.

@@ -0,0 +1,75 @@
From edabaf799fd071a328e0adb743a98628df6649f0 Mon Sep 17 00:00:00 2001
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is a patch file needed in a PR?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It makes it easier to separate our customizations so when we import a new upstream version we can just re-apply the patch.

@@ -721,7 +721,7 @@ local void scan_tree(s, tree, max_code)
if (++count < max_count && curlen == nextlen) {
continue;
} else if (count < min_count) {
s->bl_tree[curlen].Freq += count;
s->bl_tree[curlen].Freq += (ush)count;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's ush? Having trouble finding its definition.

Copy link
Member

@akoeplinger akoeplinger Aug 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's from a typedef here:

typedef unsigned short ush;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Oof, I really dislike cryptic c typedefs.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. It's trying to match the maintainer's style as closely as possible, which is why it could look strange from our eyes.

src/native/external/zlib-intel/deflate.c Show resolved Hide resolved
@GrabYourPitchforks
Copy link
Member Author

Is it your intention to get this backported to 8.0?

Yes, since TSA will eventually complain if we don't. But honestly it can wait until after RC / RTM if needed.

@GrabYourPitchforks GrabYourPitchforks merged commit d28bac7 into dotnet:main Aug 30, 2023
173 checks passed
@GrabYourPitchforks
Copy link
Member Author

GrabYourPitchforks commented Aug 30, 2023

@GrabYourPitchforks
Copy link
Member Author

/backport to release/8.0

@GrabYourPitchforks GrabYourPitchforks deleted the zlib-binskim branch September 12, 2023 21:39
@github-actions
Copy link
Contributor

Started backporting to release/8.0: https://github.com/dotnet/runtime/actions/runs/6165145907

@ghost ghost locked as resolved and limited conversation to collaborators Oct 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants