Skip to content

Fix -Wformat error in TiffDecode#5305

Merged
radarhere merged 2 commits intopython-pillow:masterfrom
lukegb:bug/format-strings
Mar 11, 2021
Merged

Fix -Wformat error in TiffDecode#5305
radarhere merged 2 commits intopython-pillow:masterfrom
lukegb:bug/format-strings

Conversation

@lukegb
Copy link
Copy Markdown
Contributor

@lukegb lukegb commented Mar 3, 2021

When building under an environment with -Werror=format, TiffDecode.c no longer builds:

src/libImaging/TiffDecode.c: In function ‘_tiffReadProc’:
src/libImaging/TiffDecode.c:59:58: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘toff_t’ {aka ‘long unsigned int’} [-Werror=format=]
src/libImaging/TiffDecode.c:59:67: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘toff_t’ {aka ‘long unsigned int’} [-Werror=format=]

src/libImaging/TiffDecode.c: In function ‘_tiffReadProc’:
src/libImaging/TiffDecode.c:59:58: error: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘toff_t’ {aka ‘long unsigned int’} [-Werror=format=]
src/libImaging/TiffDecode.c:59:67: error: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘toff_t’ {aka ‘long unsigned int’} [-Werror=format=]
@radarhere
Copy link
Copy Markdown
Member

Building normally, I find that there is currently a

warning: format specifies type 'unsigned long' but the argument has type 'toff_t' (aka 'unsigned long long') [-Wformat]

With your change, it becomes

warning: format specifies type 'int' but the argument has type 'toff_t' (aka 'unsigned long long') [-Wformat]

@radarhere radarhere merged commit f91f93e into python-pillow:master Mar 11, 2021
@lukegb
Copy link
Copy Markdown
Contributor Author

lukegb commented Mar 11, 2021

Hmm, interesting.

I suspect there's a disparity in what underlying type these are being mapped to on your system vs mine - IIRC there are special format specifiers or macros for this case, but failing that it might make sense to explicitly cast to a different type like is being done above.

@lukegb
Copy link
Copy Markdown
Contributor Author

lukegb commented Mar 11, 2021

I tried to reply by email but GitHub apparently dropped it. Oh well.

@lukegb lukegb deleted the bug/format-strings branch March 11, 2021 11:51
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