Skip to content

Fixed comparison warning#5184

Closed
radarhere wants to merge 1 commit intopython-pillow:masterfrom
radarhere:warnings
Closed

Fixed comparison warning#5184
radarhere wants to merge 1 commit intopython-pillow:masterfrom
radarhere:warnings

Conversation

@radarhere
Copy link
Copy Markdown
Member

https://github.com/python-pillow/Pillow/runs/1649086275#step:9:118

src/libImaging/TiffDecode.c:241:22: warning: comparison of integers of different signs: 'int' and 'uint32' (aka 'unsigned int') [-Wsign-compare]
if (state->xsize != img.width || state->ysize != img.height) {
~~~~~~~~~~~~ ^ ~~~~~~~~~
src/libImaging/TiffDecode.c:241:51: warning: comparison of integers of different signs: 'int' and 'uint32' (aka 'unsigned int') [-Wsign-compare]
if (state->xsize != img.width || state->ysize != img.height) {
~~~~~~~~~~~~ ^ ~~~~~~~~~~
src/libImaging/TiffDecode.c:582:41: warning: comparison of integers of different signs: 'int' and 'unsigned int' [-Wsign-compare]
for (tile_y = 0; tile_y < current_tile_length; tile_y++) {
~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~
3 warnings generated.

@wiredfool
Copy link
Copy Markdown
Member

I'm not sure that this is the right approach for a couple of reasons.

  1. We should probably not be using the U/INT32 for these in general, they should really be tsize_t or whatever they are in libtiff, because they change over time. Some of the libtiff items have definitely changed from u/int32 -> u/int64 over the time that I've been digging into valgrind.

  2. If we're casting like that, we need to make sure that we're not going to under/overflow in the cast. Basically, it's silencing the warning, but it doesn't actually change the behavior.

@radarhere
Copy link
Copy Markdown
Member Author

Thanks.
I've updated to remove the casting change, and kept the second change.

@radarhere radarhere changed the title Fixed comparison warnings Fixed comparison warning Jan 5, 2021
@radarhere
Copy link
Copy Markdown
Member Author

This looks like it became part of #5364.

@radarhere radarhere closed this Apr 1, 2021
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.

2 participants