Page 1 of 1

coders/png.c:1184:3: warning: 'jmpbuf' is deprecated

Posted: 2011-02-11T18:17:23-07:00
by yecril71pl
Fix wanted.
From libpng CHANGES:
version 1.4.0beta103 [November 21, 2009]
Make the 'png_jmpbuf' macro expand to a call that records the correct longjmp function as well as returning a pointer to the setjmp jmp_buf buffer, and marked direct access to jmpbuf 'deprecated'. (John Bowler)
An attempt is made in coders/png.c:

Code: Select all

#if PNG_LIBPNG_VER < 10500
  longjmp(ping->jmpbuf,1);
#else
  png_longjmp(ping,1);
#endif
but it fails:
CC coders/coders_png_la-png.lo
coders/png.c: In function 'PNGErrorHandler':
coders/png.c:1184:3: warning: 'jmpbuf' is deprecated (declared at /usr/include/png.h:1098)
The assumption about PNG_LIBPNG_VER is too tight; I have libpng 1.4.4 and it fails.
Changes:
version 1.4.0beta103 [November 21, 2009]
Make the 'png_jmpbuf' macro expand to a call that records the correct longjmp function as well as returning a pointer to the setjmp jmp_buf buffer, and marked direct access to jmpbuf 'deprecated'. (John Bowler)
So it should probably be PNG_LIBPNG_VER < 10401.

Re: coders/png.c:1184:3: warning: 'jmpbuf' is deprecated

Posted: 2011-02-11T19:14:50-07:00
by glennrp
With 1.4.x you get the "deprecated" warning. It just means
the code won't work with libpng-1.5 if you don't change it. We changed it.

Version 1.5.0beta08 [February 19, 2010]
Added exported png_longjmp() function.

Re: coders/png.c:1184:3: warning: 'jmpbuf' is deprecated

Posted: 2011-02-12T08:58:33-07:00
by yecril71pl
This snippet should work for libpng 1.4:

Code: Select all

#if +(PNG_LIBPNG_VER) < 10500
#ifdef png_jmpbuf
  longjmp (png_jmpbuf (ping), 1);
#else
  longjmp (ping->jmpbuf, 1);
#endif
#else
  png_longjmp (ping, 1);
#endif
or even

Code: Select all

#if +(PNG_LIBPNG_VER) < 10500
#define MAGICK_PNG_LONGJMP png_longjmp
#elif defined (png_jmpbuf)
#define MAGICK_PNG_LONGJMP(P_S, P_L)  (longjmp (png_jmpbuf ((P_S)), (P_L)))
#else
#define MAGICK_PNG_LONGJMP(P_S, P_L) (longjmp ((P_S) -> jmpbuf, (P_L)))
#endif