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

Fixed format warning #5535

Merged
merged 1 commit into from Jun 14, 2021
Merged

Fixed format warning #5535

merged 1 commit into from Jun 14, 2021

Conversation

radarhere
Copy link
Member

@radarhere radarhere commented Jun 10, 2021

Helps #5526

In master at the moment, there is a warning at https://github.com/python-pillow/Pillow/runs/2757774272?check_suite_focus=true#step:9:112

src/libImaging/TiffDecode.c:59:60: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 3 has type ‘toff_t’ {aka ‘long unsigned int’} [-Wformat=]
   59 |         TIFFError("_tiffReadProc", "Invalid Read at loc %llu, eof: %llu", state->loc, state->eof);

If I try to fix that by changing it to '%lu', it fixes that job, but starts failing in another -

src/libImaging/TiffDecode.c:59:73: warning: format specifies type 'unsigned long' but the argument has type 'toff_t' (aka 'unsigned long long') [-Wformat]
        TIFFError("_tiffReadProc", "Invalid Read at loc %lu, eof: %lu", state->loc, state->eof);

So instead, this PR casts the arguments to unsigned long long.

@radarhere radarhere mentioned this pull request Jun 10, 2021
@kmilos
Copy link
Contributor

kmilos commented Jun 10, 2021

Perhaps it's neater to use platform agnostic macros from inttypes.h that correspond to uint64_t (i.e. %PRIu64) now that libtiff switched to standard types as well?

@radarhere
Copy link
Member Author

Feel free to show that I'm doing it wrong, but if I try that, I see https://github.com/radarhere/Pillow/runs/2798905046?check_suite_focus=true#step:9:112

src/libImaging/TiffDecode.c:60:58: warning: unknown conversion type character ‘P’ in format [-Wformat=]
   60 |         TIFFError("_tiffReadProc", "Invalid Read at loc %PRlu64, eof: %PRlu64", state->loc, state->eof);

@kmilos
Copy link
Contributor

kmilos commented Jun 11, 2021

I think you use it w/ concatenation, like

TIFFError("_tiffReadProc", "Invalid Read at loc %" PRIu64 ", eof: %" PRIu64, state->loc, state->eof);

(note the capital "i" in PRI as in print, not small case "L")

And probably no need to explicitly include inttypes.h, tiffio.h (tiffconf.h) already pulls it in for you...

@radarhere radarhere changed the title Fixed warning by casting Fixed format warning Jun 11, 2021
@hugovk hugovk merged commit 8f55c95 into python-pillow:master Jun 14, 2021
@radarhere radarhere deleted the tiff_format branch June 14, 2021 12:09
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

3 participants