pnggroup / libpng

LIBPNG: Portable Network Graphics support, official libpng repository
http://libpng.sf.net
Other
1.25k stars 611 forks source link

Simplify width check in png_check_IHDR. #539

Closed cjacek closed 7 months ago

cjacek commented 7 months ago

This fixes a warning on Clang with MSVC target. In this case, clang defines _MSC_VER, not __GNUC__, but it's still a subject to the same warning. I could change the condition of png_gt to something like defined(__GNUC__) || defined(__clang__), but we could also simplify things by adding a pointer size check. This way, the problematic tautological gt expression is entirely skipped by the compiler by constant folding the first expression.

I noticed it in a build of the version bundled in Wine, the patch avoids the warning both on GCC and Clang (both in GNUC and MSVC modes).

jbowler commented 7 months ago

@ctruta: I'll supply a PR which removes the offensive (compilist) code and works without the enormous complexity of the suggested change.

jbowler commented 7 months ago

Fix is in #540; same code but make the mask a (png_alloc_size_t) not an (unsigned) so that PR does actually fix a bug on 16-bit systems.

cjacek commented 7 months ago

Thanks!