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

Fix -Wformat error in TiffDecode #5305

Merged
merged 2 commits into from Mar 11, 2021

Conversation

lukegb
Copy link
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
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
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
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.

None yet

2 participants