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

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
User avatar
yecril71pl
Posts: 81
Joined: 2011-02-08T11:06:09-07:00
Authentication code: 8675308
Location: Warsaw, Poland
Contact:

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

Post 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.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

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

Post 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.
User avatar
yecril71pl
Posts: 81
Joined: 2011-02-08T11:06:09-07:00
Authentication code: 8675308
Location: Warsaw, Poland
Contact:

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

Post 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
Post Reply