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
Merged

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

@radarhere radarhere commented Mar 4, 2021

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]

src/libImaging/TiffDecode.c Outdated Show resolved Hide resolved
@radarhere radarhere merged commit f91f93e into python-pillow:master Mar 11, 2021
51 of 53 checks passed
@lukegb
Copy link
Contributor Author

@lukegb 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 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 Mar 11, 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
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants