[devel] Fix gcc -pendantic warnings, handle Cygwin longjmp fix png_read_png

This commit is contained in:
John Bowler 2011-02-12 08:58:21 -06:00 committed by Glenn Randers-Pehrson
parent 6a6d79fc00
commit 9c69360e97
3 changed files with 55 additions and 44 deletions

38
png.h
View File

@ -797,35 +797,33 @@ typedef struct png_struct_def png_struct;
typedef PNG_CONST png_struct FAR * png_const_structp; typedef PNG_CONST png_struct FAR * png_const_structp;
typedef png_struct FAR * png_structp; typedef png_struct FAR * png_structp;
typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp), ); typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));
typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t), ); typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t));
typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp), ); typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));
typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,
int), ); int));
typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32,
int), ); int));
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED #ifdef PNG_PROGRESSIVE_READ_SUPPORTED
typedef PNG_CALLBACK(void, *png_progressive_info_ptr, typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));
(png_structp, png_infop), ); typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));
typedef PNG_CALLBACK(void, *png_progressive_end_ptr, typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep,
(png_structp, png_infop), ); png_uint_32, int));
typedef PNG_CALLBACK(void, *png_progressive_row_ptr,
(png_structp, png_bytep, png_uint_32, int), );
#endif #endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
typedef PNG_CALLBACK(void, *png_user_transform_ptr, typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop,
(png_structp, png_row_infop, png_bytep), ); png_bytep));
#endif #endif
#ifdef PNG_USER_CHUNKS_SUPPORTED #ifdef PNG_USER_CHUNKS_SUPPORTED
typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,
png_unknown_chunkp), ); png_unknown_chunkp));
#endif #endif
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED #ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp), ); typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp));
#endif #endif
#ifdef PNG_SETJMP_SUPPORTED #ifdef PNG_SETJMP_SUPPORTED
@ -882,8 +880,8 @@ typedef PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)),
* following. * following.
*/ */
typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,
png_alloc_size_t), ); png_alloc_size_t));
typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp), ); typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));
typedef png_struct FAR * FAR * png_structpp; typedef png_struct FAR * FAR * png_structpp;

View File

@ -282,23 +282,15 @@
# endif # endif
#endif #endif
/* THe following complexity is concerned with getting the 'attributes' of the /* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat
* declared function in the correct place. This potentially requires a separate * 'attributes' as a storage class - the attributes go at the start of the
* PNG_EXPORT function for every compiler. * function definition, and attributes are always appended regardless of the
* compiler. This considerably simplifies these macros but may cause problems
* if any compilers both need function attributes and fail to handle them as
* a storage class (this is unlikely.)
*/ */
#ifndef PNG_FUNCTION #ifndef PNG_FUNCTION
# if defined(__GNUC__) # define PNG_FUNCTION(type, name, args, attributes) attributes type name args
# define PNG_FUNCTION(type, name, args, attributes)\
attributes type name args
# else /* !GNUC */
# ifdef _MSC_VER
# define PNG_FUNCTION(type, name, args, attributes)\
attributes type name args
# else /* !MSC */
# define PNG_FUNCTION(type, name, args, attributes)\
type name args
# endif
# endif
#endif #endif
#ifndef PNG_EXPORT_TYPE #ifndef PNG_EXPORT_TYPE
@ -311,12 +303,17 @@
*/ */
#ifndef PNG_EXPORTA #ifndef PNG_EXPORTA
# define PNG_EXPORTA(ordinal, type, name, args, attributes)\ # define PNG_EXPORTA(ordinal, type, name, args, attributes)\
extern PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args),\ PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), extern\
attributes) attributes)
#endif #endif
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
* so make something non-empty to satisfy the requirement:
*/
#define PNG_EMPTY /*empty list*/
#define PNG_EXPORT(ordinal, type, name, args)\ #define PNG_EXPORT(ordinal, type, name, args)\
PNG_EXPORTA(ordinal, type, name, args, ) PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
/* Use PNG_REMOVED to comment out a removed interface. */ /* Use PNG_REMOVED to comment out a removed interface. */
#ifndef PNG_REMOVED #ifndef PNG_REMOVED
@ -324,8 +321,7 @@
#endif #endif
#ifndef PNG_CALLBACK #ifndef PNG_CALLBACK
# define PNG_CALLBACK(type, name, args, attributes)\ # define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
type (PNGCBAPI name) PNGARG(args) attributes
#endif #endif
/* Support for compiler specific function attributes. These are used /* Support for compiler specific function attributes. These are used
@ -355,7 +351,21 @@
# define PNG_NORETURN __attribute__((__noreturn__)) # define PNG_NORETURN __attribute__((__noreturn__))
# endif # endif
# ifndef PNG_PTR_NORETURN # ifndef PNG_PTR_NORETURN
# define PNG_PTR_NORETURN __attribute__((__noreturn__)) /* It's not enough to have the compiler be the correct compiler at
* this point - it's necessary for the library (which defines
* the type of the library longjmp) to also be the GNU library.
* This is because many systems use the GNU compiler with a
* non-GNU libc implementation. Min/GW headers are also compatible
* with GCC as well as uclibc, so it seems best to exclude known
* problem libcs here rather than just including known libcs.
*
* NOTE: this relies on the only use of PNG_PTR_NORETURN being with
* the system longjmp. If the same type is used elsewhere then this
* will need to be changed.
*/
# if !defined(__CYGWIN__)
# define PNG_PTR_NORETURN __attribute__((__noreturn__))
# endif
# endif # endif
# ifndef PNG_ALLOCATED # ifndef PNG_ALLOCATED
# define PNG_ALLOCATED __attribute__((__malloc__)) # define PNG_ALLOCATED __attribute__((__malloc__))
@ -380,7 +390,7 @@
# define PNG_PRIVATE \ # define PNG_PRIVATE \
__attribute__((__deprecated__)) __attribute__((__deprecated__))
# endif # endif
# endif /* PNG_PRIVATE */ # endif
# endif /* PNGLIB_BUILD */ # endif /* PNGLIB_BUILD */
# endif /* __GNUC__ */ # endif /* __GNUC__ */
# ifdef _MSC_VER /* may need to check value */ # ifdef _MSC_VER /* may need to check value */
@ -410,9 +420,9 @@
# endif # endif
# ifndef PNG_PRIVATE # ifndef PNG_PRIVATE
# define PNG_PRIVATE __declspec(deprecated) # define PNG_PRIVATE __declspec(deprecated)
# endif /* PNG_PRIVATE */ # endif
# endif /* PNGLIB_BUILD */ # endif /* PNGLIB_BUILD */
# endif /* __GNUC__ */ # endif /* _MSC_VER */
#endif /* PNG_PEDANTIC_WARNINGS */ #endif /* PNG_PEDANTIC_WARNINGS */
#ifndef PNG_DEPRECATED #ifndef PNG_DEPRECATED
@ -424,6 +434,9 @@
#ifndef PNG_NORETURN #ifndef PNG_NORETURN
# define PNG_NORETURN /* This function does not return */ # define PNG_NORETURN /* This function does not return */
#endif #endif
#ifndef PNG_PTR_NORETURN
# define PNG_PTR_NORETURN /* This function does not return */
#endif
#ifndef PNG_ALLOCATED #ifndef PNG_ALLOCATED
# define PNG_ALLOCATED /* The result of the function is new memory */ # define PNG_ALLOCATED /* The result of the function is new memory */
#endif #endif

View File

@ -979,7 +979,7 @@ store_pool_delete(png_store *ps, store_pool *pool)
next->next = NULL; next->next = NULL;
fprintf(stderr, "\t%lu bytes @ %p\n", fprintf(stderr, "\t%lu bytes @ %p\n",
(unsigned long)next->size, next+1); (unsigned long)next->size, (PNG_CONST void*)(next+1));
/* The NULL means this will always return, even if the memory is /* The NULL means this will always return, even if the memory is
* corrupted. * corrupted.
*/ */