-
Notifications
You must be signed in to change notification settings - Fork 120
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
Fix warning sign compare #80
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5f6319a
fix unused-parameter warning in samples
Bogumil-Sapinski-Mobica 28f1bda
Revert "fix unused-parameter warning in samples"
Bogumil-Sapinski-Mobica 681a02c
fixed warnings caused by comparing signed and unsigned int
Bogumil-Sapinski-Mobica 06ba952
fixed formatting
Bogumil-Sapinski-Mobica 8988c0f
fixing warning sign-compare other way
Bogumil-Sapinski-Mobica 1347fc6
formatting
Bogumil-Sapinski-Mobica File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
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.
Given there are changes below to
reinterpret_cast
these back toint
in one location below is this the correct change? Should the other side of whatever was triggering the warning be changed?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.
Reinterpret_cast was enforced by stb_image library which seams to be an old C-style code which uses
signed int
whereunsigned int
will suffice. As it is external library I could not change it. However Image class is a good place to set a boundary between new/old code.Reinterpret cast is done while loading the image from file so there is no danger of loosing the data.
I would concern about writing image with stb as it is doing implicit cast from size_t 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.
This seems like a superficial problem to me. While on an academic level I agree with "don't use signed types where values can't be negative", as ill fate, 3rd parties and legacy C compatibility may have it, sometimes a cleanup is just too much hassle.
Yes, the SDK lib chose
int
to interface nicely with stb. Should we change the choice of lib in the future, because the SDK utilities don't leak to users, we are always free to reevaluate that choice. Your proposed changes while seem fine at first, it is an extreme level of "running with scissors".int
andsize_t
aren't even the same size, so casting their pointers and expecting to get the right value ventures into endianness and two's complement territory and/or knowing how much our languages (and their particular versions) shield us from them. I really don't think this part of the code, which is otherwise warning-free without turningwidth
into asize_t
is worth the hassle to reason about such matters.Minimally, it ought to be
unsigned int
to make sure that stb's choice ofint
is always matched at least in size on every arch. Yet again, while almost every other day I'd air on the side of choosing the most restrictive yet adequate number representation, I don't think this is the case where we should practice that.