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

[msvc] Fix warnings, mainly casting to smaller types #270

Merged
merged 1 commit into from Apr 22, 2022

Conversation

ntadej
Copy link
Collaborator

@ntadej ntadej commented Apr 3, 2022

MSVC is quite eager with warnings (which is good in my opinion). This MR cleans most of the core codebase of MSVC warnings:

  • implicit casting to smaller types (e.g. double to float)
  • some encoding stuff
  • warnings from dependencies

Note that this is mostly silencing warnings (e.g. using static_cast) but I also tried to fix some trivial cases and add some template specialisations. This should be purely technical, but let's see what also CI says.

@ntadej ntadej requested review from roblabs and birkskyum April 3, 2022 15:44
@roblabs
Copy link
Collaborator

roblabs commented Apr 6, 2022

@ntadej — I see the checks passed. Out of curiosity, do the GitHub Actions show a summary of warnings count before and after? And does that number go down with this commit?

For iOS builds I checked a sample file that was changed, map.cpp on my local build CI, and it does not show warnings (not really a perfect comparison, I know). I was looking for some sort of way to measure the code integrity for Android & iOS builds.

@ntadej
Copy link
Collaborator Author

ntadej commented Apr 6, 2022

Those warnings are actually silenced at the moment as I found them too spammy (MSVC is also quite verbose). 😊

Also as we have -Werror enabled for iOS and Android as far as I know you should not see any difference in warnings (as there are none).

Also to add I runtime tested this on Windows, macOS and iOS (Qt version) and I did not observe any visibly noticeable regressions (I tried really hard not to introduce typos that would affect functionality).

@ntadej
Copy link
Collaborator Author

ntadej commented Apr 20, 2022

@roblabs, @atierian, @birkskyum, is there anything else I should do from my side to proceed?

@roblabs roblabs merged commit 32ed70c into maplibre:main Apr 22, 2022
acalcutt added a commit to acalcutt/maplibre-gl-native that referenced this pull request May 16, 2022
acalcutt added a commit to acalcutt/maplibre-gl-native that referenced this pull request May 17, 2022
@wipfli wipfli mentioned this pull request Jul 4, 2022
@@ -122,13 +122,13 @@ IntersectStatus CollisionIndex::intersectsTileEdges(const CollisionBox& box,
const float tileY2 = tileEdges[3];

// Check left border
int minSectionLength = std::min(tileX1 - x1, x2 - tileX1);
float minSectionLength = std::min(tileX1 - x1, x2 - tileX1);
Copy link
Member

Choose a reason for hiding this comment

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

Seems to break some render tests...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why this happens is obscure to me. If you look closer there is a cast to int when this variable is copied over to the result.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Also it would be useful to actually to paste what tests this breaks to see the effect.

Comment on lines -418 to +419
(((p[0] / p[3] + 1) / 2) * size.width) + viewportPadding,
(((-p[1] / p[3] + 1) / 2) * size.height) + viewportPadding
static_cast<float>(((p[0] / p[3] + 1) / 2) * size.width) + viewportPadding,
static_cast<float>(((-p[1] / p[3] + 1) / 2) * size.height) + viewportPadding
Copy link
Member

Choose a reason for hiding this comment

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

Breaks another render test

@@ -145,7 +145,7 @@ void align(Shaping& shaping,
if (maxLineHeight != lineHeight) {
shiftY = -blockHeight * verticalAlign - Shaping::yOffset;
} else {
shiftY = (-verticalAlign * lineCount + 0.5) * lineHeight;
shiftY = (-verticalAlign * static_cast<float>(lineCount + 0.5)) * lineHeight;
Copy link
Member

Choose a reason for hiding this comment

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

Was fixed in #285

Comment on lines -266 to +271
return util::max(0.0, util::min(xCellCount - 1.0, std::floor(x * xScale)));
return util::max(size_t(0), util::min(xCellCount - 1, static_cast<size_t>(std::floor(x * xScale))));
}

template <class T>
std::size_t GridIndex<T>::convertToYCellCoord(const float y) const {
return util::max(0.0, util::min(yCellCount - 1.0, std::floor(y * yScale)));
return util::max(size_t(0), util::min(yCellCount - 1, static_cast<size_t>(std::floor(y * yScale))));
Copy link
Member

Choose a reason for hiding this comment

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

Breaks some render tests...

@wipfli wipfli mentioned this pull request Jul 4, 2022
keith pushed a commit to lyft/maplibre-gl-native that referenced this pull request Jul 22, 2022
If the checks by GitHub Actions checks are met, then it seems good to go.  Thanks for supporting FOSS4G!
@ntadej ntadej deleted the msvc-fixes2 branch April 10, 2023 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants