[libpng16] Eliminated use of png_sizeof(); use sizeof() instead, and use.

a consistent style for (sizeof type) and (sizeof (array))
This commit is contained in:
Glenn Randers-Pehrson 2012-08-09 20:14:48 -05:00
parent 5f5977e708
commit 432c174b64
14 changed files with 128 additions and 119 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.6.0beta27 - August 9, 2012
Libpng 1.6.0beta27 - August 10, 2012
This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version.
@ -399,7 +399,7 @@ Version 1.6.0beta26 [July 10, 2012]
Moved scripts/chkfmt to contrib/tools.
Changed "a+w" to "u+w" in Makefile.in to fix CVE-2012-3386.
Version 1.6.0beta27 [August 9, 2012]
Version 1.6.0beta27 [August 10, 2012]
Do not compile PNG_DEPRECATED, PNG_ALLOC and PNG_PRIVATE when __GNUC__ < 3.
Do not use __restrict when GNUC is <= 3.1
Removed references to png_zalloc() and png_zfree() from the manual.
@ -413,6 +413,8 @@ Version 1.6.0beta27 [August 9, 2012]
Re-eliminated the use of strcpy() in pngtest.c. An unncessary use of
strcpy() was accidentally re-introduced in libpng16; this change replaces
it with strncpy().
Eliminated use of png_sizeof(); use sizeof() instead.
Use a consistent style for (sizeof type) and (sizeof (array))
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -4150,7 +4150,7 @@ Version 1.6.0beta26 [July 10, 2012]
Moved scripts/chkfmt to contrib/tools.
Changed "a+w" to "u+w" in Makefile.in to fix CVE-2012-3386.
Version 1.6.0beta27 [August 9, 2012]
Version 1.6.0beta27 [August 10, 2012]
Do not compile PNG_DEPRECATED, PNG_ALLOC and PNG_PRIVATE when __GNUC__ < 3.
Do not use __restrict when GNUC is <= 3.1
Removed references to png_zalloc() and png_zfree() from the manual.
@ -4164,6 +4164,8 @@ Version 1.6.0beta27 [August 9, 2012]
Re-eliminated the use of strcpy() in pngtest.c. An unncessary use of
strcpy() was accidentally re-introduced in libpng16; this change replaces
it with strncpy().
Eliminated use of png_sizeof(); use sizeof() instead.
Use a consistent style for (sizeof type) and (sizeof (array))
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -48,7 +48,7 @@ int main(int argc, const char **argv)
png_image image; /* The control structure used by libpng */
/* Initialize the 'png_image' structure. */
memset(&image, 0, sizeof image);
memset(&image, 0, (sizeof image));
/* The first argument is the file to read: */
if (png_image_begin_read_from_file(&image, argv[1]))
@ -833,7 +833,7 @@ void write_png(char *file_name /* , ... other image information ... */)
/* Set the palette if there is one. REQUIRED for indexed-color images */
palette = (png_colorp)png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH
* png_sizeof(png_color));
* (sizeof (png_color)));
/* ... Set palette colors ... */
png_set_PLTE(png_ptr, info_ptr, palette, PNG_MAX_PALETTE_LENGTH);
/* You must not free palette here, because png_set_PLTE only makes a link to
@ -968,11 +968,13 @@ void write_png(char *file_name /* , ... other image information ... */)
* use the first method if you aren't handling interlacing yourself.
*/
png_uint_32 k, height, width;
/* In this example, "image" is a one-dimensional array of bytes */
png_byte image[height*width*bytes_per_pixel];
png_bytep row_pointers[height];
if (height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
if (height > PNG_UINT_32_MAX/(sizeof (png_bytep)))
png_error (png_ptr, "Image is too tall to process in memory");
/* Set up pointers into your "image" byte array */

49
png.c
View File

@ -194,10 +194,11 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
size_t pos = 0;
char m[128];
pos = png_safecat(m, sizeof m, pos, "Application built with libpng-");
pos = png_safecat(m, sizeof m, pos, user_png_ver);
pos = png_safecat(m, sizeof m, pos, " but running with ");
pos = png_safecat(m, sizeof m, pos, png_libpng_ver);
pos = png_safecat(m, (sizeof m), pos,
"Application built with libpng-");
pos = png_safecat(m, (sizeof m), pos, user_png_ver);
pos = png_safecat(m, (sizeof m), pos, " but running with ");
pos = png_safecat(m, (sizeof m), pos, png_libpng_ver);
png_warning(png_ptr, m);
#endif
@ -231,7 +232,7 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
* build enough context to allow the user provided memory allocator (if any)
* to be called.
*/
png_memset(&create_struct, 0, sizeof create_struct);
png_memset(&create_struct, 0, (sizeof create_struct));
/* Added at libpng-1.2.6 */
# ifdef PNG_USER_LIMITS_SUPPORTED
@ -284,7 +285,7 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
if (png_user_version_check(&create_struct, user_png_ver))
{
png_structrp png_ptr = png_voidcast(png_structrp,
png_malloc_warn(&create_struct, sizeof *png_ptr));
png_malloc_warn(&create_struct, (sizeof *png_ptr)));
if (png_ptr != NULL)
{
@ -333,10 +334,10 @@ png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED)
* has always been done in 'example.c'.
*/
info_ptr = png_voidcast(png_inforp, png_malloc_base(png_ptr,
sizeof *info_ptr));
(sizeof *info_ptr)));
if (info_ptr != NULL)
png_memset(info_ptr, 0, sizeof *info_ptr);
png_memset(info_ptr, 0, (sizeof *info_ptr));
return info_ptr;
}
@ -373,7 +374,7 @@ png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr)
*info_ptr_ptr = NULL;
png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
png_memset(info_ptr, 0, sizeof *info_ptr);
png_memset(info_ptr, 0, (sizeof *info_ptr));
png_free(png_ptr, info_ptr);
}
}
@ -398,18 +399,18 @@ png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size),
if (info_ptr == NULL)
return;
if (png_sizeof(png_info) > png_info_struct_size)
if ((sizeof (png_info)) > png_info_struct_size)
{
*ptr_ptr = NULL;
/* The following line is why this API should not be used: */
free(info_ptr);
info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL,
sizeof *info_ptr));
(sizeof *info_ptr)));
*ptr_ptr = info_ptr;
}
/* Set everything to 0 */
png_memset(info_ptr, 0, sizeof *info_ptr);
png_memset(info_ptr, 0, (sizeof *info_ptr));
}
/* The following API is not called internally */
@ -748,13 +749,13 @@ png_get_copyright(png_const_structrp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
"libpng version 1.6.0beta27 - July 14, 2012" PNG_STRING_NEWLINE \
"libpng version 1.6.0beta27 - August 10, 2012" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2012 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE;
# else
return "libpng version 1.6.0beta27 - July 14, 2012\
return "libpng version 1.6.0beta27 - August 10, 2012\
Copyright (c) 1998-2012 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@ -1691,20 +1692,20 @@ profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
if (colorspace != NULL)
colorspace->flags |= PNG_COLORSPACE_INVALID;
pos = png_safecat(message, sizeof message, 0, "profile '");
pos = png_safecat(message, (sizeof message), 0, "profile '");
pos = png_safecat(message, pos+79, pos, name);
pos = png_safecat(message, sizeof message, pos, "': ");
pos = png_safecat(message, (sizeof message), pos, "': ");
# ifdef PNG_WARNINGS_SUPPORTED
{
char number[PNG_NUMBER_BUFFER_SIZE];
pos = png_safecat(message, sizeof message, pos,
pos = png_safecat(message, (sizeof message), pos,
png_format_number(number, number+(sizeof number),
PNG_NUMBER_FORMAT_x, value));
}
pos = png_safecat(message, sizeof message, pos, ": ");
pos = png_safecat(message, (sizeof message), pos, ": ");
# endif
pos = png_safecat(message, sizeof message, pos, reason);
pos = png_safecat(message, (sizeof message), pos, reason);
if (colorspace != NULL)
{
@ -3578,12 +3579,12 @@ png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
unsigned int i;
png_uint_16pp table = *ptable =
(png_uint_16pp)png_calloc(png_ptr, num * png_sizeof(png_uint_16p));
(png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p)));
for (i = 0; i < num; i++)
{
png_uint_16p sub_table = table[i] =
(png_uint_16p)png_malloc(png_ptr, 256 * png_sizeof(png_uint_16));
(png_uint_16p)png_malloc(png_ptr, 256 * (sizeof (png_uint_16)));
/* The 'threshold' test is repeated here because it can arise for one of
* the 16-bit tables even if the others don't hit it.
@ -3645,7 +3646,7 @@ png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
png_uint_32 last;
png_uint_16pp table = *ptable =
(png_uint_16pp)png_calloc(png_ptr, num * png_sizeof(png_uint_16p));
(png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p)));
/* 'num' is the number of tables and also the number of low bits of low
* bits of the input 16-bit value used to select a table. Each table is
@ -3653,7 +3654,7 @@ png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
*/
for (i = 0; i < num; i++)
table[i] = (png_uint_16p)png_malloc(png_ptr,
256 * png_sizeof(png_uint_16));
256 * (sizeof (png_uint_16)));
/* 'gamma_val' is set to the reciprocal of the value calculated above, so
* pow(out,g) is an *input* value. 'last' is the last input value set.
@ -4160,7 +4161,7 @@ int /* PRIVATE */
png_image_error(png_imagep image, png_const_charp error_message)
{
/* Utility to log an error. */
png_safecat(image->message, sizeof image->message, 0, error_message);
png_safecat(image->message, (sizeof image->message), 0, error_message);
image->warning_or_error |= PNG_IMAGE_ERROR;
png_image_free(image);
return 0;

View File

@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.6.0beta27 - July 21, 2012
* libpng version 1.6.0beta27 - August 10, 2012
*
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -551,7 +551,8 @@ typedef ptrdiff_t png_ptrdiff_t;
/* This macro makes the sizeof operator look and behave like a function, except
* that it can take a type without the enclosing () as an argument so long as
* the type contains no "," characters.
* the type contains no "," characters. As of libpng-1.6.0, this macro is no
* longer used in the libpng source code.
*/
#define png_sizeof(x) (sizeof (x))

View File

@ -555,7 +555,7 @@ png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
{
png_ptr->jmp_buf_size = 0; /* not allocated */
if (jmp_buf_size <= sizeof png_ptr->jmp_buf_local)
if (jmp_buf_size <= (sizeof png_ptr->jmp_buf_local))
png_ptr->jmp_buf_ptr = &png_ptr->jmp_buf_local;
else
@ -576,7 +576,7 @@ png_set_longjmp_fn(png_structrp png_ptr, png_longjmp_ptr longjmp_fn,
if (size == 0)
{
size = sizeof png_ptr->jmp_buf_local;
size = (sizeof png_ptr->jmp_buf_local);
if (png_ptr->jmp_buf_ptr != &png_ptr->jmp_buf_local)
{
/* This is an internal error in libpng: somehow we have been left
@ -825,7 +825,7 @@ png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message),
*/
if (image != NULL)
{
png_safecat(image->message, sizeof image->message, 0, error_message);
png_safecat(image->message, (sizeof image->message), 0, error_message);
image->warning_or_error |= PNG_IMAGE_ERROR;
/* Retrieve the jmp_buf from within the png_control, making this work for
@ -837,9 +837,10 @@ png_safe_error,(png_structp png_nonconst_ptr, png_const_charp error_message),
/* Missing longjmp buffer, the following is to help debugging: */
{
size_t pos = png_safecat(image->message, sizeof image->message, 0,
size_t pos = png_safecat(image->message, (sizeof image->message), 0,
"bad longjmp: ");
png_safecat(image->message, sizeof image->message, pos, error_message);
png_safecat(image->message, (sizeof image->message), pos,
error_message);
}
}
@ -857,7 +858,7 @@ png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
/* A warning is only logged if there is no prior warning or error. */
if (image->warning_or_error == 0)
{
png_safecat(image->message, sizeof image->message, 0, warning_message);
png_safecat(image->message, (sizeof image->message), 0, warning_message);
image->warning_or_error |= PNG_IMAGE_WARNING;
}
}

View File

@ -30,7 +30,7 @@ png_destroy_png_struct(png_structrp png_ptr)
* png_get_mem_ptr, so fake a temporary png_struct to support this.
*/
png_struct dummy_struct = *png_ptr;
memset(png_ptr, 0, sizeof *png_ptr);
memset(png_ptr, 0, (sizeof *png_ptr));
png_free(&dummy_struct, png_ptr);
# ifdef PNG_SETJMP_SUPPORTED

View File

@ -933,7 +933,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
* PNG file before the first IDAT (image data chunk).
*/
png_read_info(png_ptr, info_ptr);
if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
if (info_ptr->height > PNG_UINT_32_MAX/(sizeof (png_bytep)))
png_error(png_ptr, "Image is too high to process with png_read_png()");
/* -------------- image transformations start here ------------------- */
@ -1080,7 +1080,7 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
png_uint_32 iptr;
info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
info_ptr->height * png_sizeof(png_bytep));
info_ptr->height * (sizeof (png_bytep)));
for (iptr=0; iptr<info_ptr->height; iptr++)
info_ptr->row_pointers[iptr] = NULL;
@ -1169,7 +1169,7 @@ png_image_read_init(png_imagep image)
/* And set the rest of the structure to NULL to ensure that the various
* fields are consistent.
*/
memset(image, 0, sizeof *image);
memset(image, 0, (sizeof *image));
image->version = PNG_IMAGE_VERSION;
if (png_ptr != NULL)
@ -1179,11 +1179,11 @@ png_image_read_init(png_imagep image)
if (info_ptr != NULL)
{
png_controlp control = png_voidcast(png_controlp,
png_malloc_warn(png_ptr, sizeof *control));
png_malloc_warn(png_ptr, (sizeof *control)));
if (control != NULL)
{
png_memset(control, 0, sizeof *control);
png_memset(control, 0, (sizeof *control));
control->png_ptr = png_ptr;
control->info_ptr = info_ptr;
@ -3907,7 +3907,7 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
int result;
png_image_read_control display;
png_memset(&display, 0, sizeof display);
png_memset(&display, 0, (sizeof display));
display.image = image;
display.buffer = buffer;
display.row_stride = row_stride;

View File

@ -364,7 +364,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
if (compose)
{
/* And obtain alpha pre-multiplication by composing on black: */
png_memset(&png_ptr->background, 0, sizeof png_ptr->background);
png_memset(&png_ptr->background, 0, (sizeof png_ptr->background));
png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */
png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
@ -423,7 +423,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
int i;
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(num_palette * png_sizeof(png_byte)));
(png_uint_32)(num_palette * (sizeof (png_byte))));
for (i = 0; i < num_palette; i++)
png_ptr->quantize_index[i] = (png_byte)i;
}
@ -440,7 +440,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
/* Initialize an array to sort colors */
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(num_palette * png_sizeof(png_byte)));
(png_uint_32)(num_palette * (sizeof (png_byte))));
/* Initialize the quantize_sort array */
for (i = 0; i < num_palette; i++)
@ -574,9 +574,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
/* Initialize palette index arrays */
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(num_palette * png_sizeof(png_byte)));
(png_uint_32)(num_palette * (sizeof (png_byte))));
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(num_palette * png_sizeof(png_byte)));
(png_uint_32)(num_palette * (sizeof (png_byte))));
/* Initialize the sort array */
for (i = 0; i < num_palette; i++)
@ -586,7 +586,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
}
hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 *
png_sizeof(png_dsortp)));
(sizeof (png_dsortp))));
num_new_palette = num_palette;
@ -616,7 +616,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
{
t = (png_dsortp)png_malloc_warn(png_ptr,
(png_uint_32)(png_sizeof(png_dsort)));
(png_uint_32)(sizeof (png_dsort)));
if (t == NULL)
break;
@ -741,12 +741,12 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
png_size_t num_entries = ((png_size_t)1 << total_bits);
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
(png_uint_32)(num_entries * png_sizeof(png_byte)));
(png_uint_32)(num_entries * (sizeof (png_byte))));
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
png_sizeof(png_byte)));
(sizeof (png_byte))));
png_memset(distance, 0xff, num_entries * png_sizeof(png_byte));
png_memset(distance, 0xff, num_entries * (sizeof (png_byte)));
for (i = 0; i < num_palette; i++)
{

View File

@ -211,7 +211,7 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
png_uint_32 len;
png_byte tmpbuf[PNG_INFLATE_BUF_SIZE];
len = sizeof tmpbuf;
len = (sizeof tmpbuf);
if (len > skip)
len = skip;
skip -= len;
@ -337,7 +337,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits)
* internal error, but is very useful for debugging. i18n requirements
* are minimal.
*/
(void)png_safecat(msg, sizeof msg, 4, " using zstream");
(void)png_safecat(msg, (sizeof msg), 4, " using zstream");
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
png_chunk_warning(png_ptr, msg);
png_ptr->zowner = 0;
@ -479,8 +479,8 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish,
* make available the full buffer, up to 'remaining_space'
*/
png_ptr->zstream.next_out = local_buffer;
if (sizeof local_buffer < avail)
avail = sizeof local_buffer;
if ((sizeof local_buffer) < avail)
avail = (sizeof local_buffer);
}
if (avail_out < avail)
@ -1394,12 +1394,12 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
Byte profile_header[132];
Byte local_buffer[PNG_INFLATE_BUF_SIZE];
png_alloc_size_t size = sizeof profile_header;
png_alloc_size_t size = (sizeof profile_header);
png_ptr->zstream.next_in = (Bytef*)keyword + (keyword_length+2);
png_ptr->zstream.avail_in = read_length;
(void)png_inflate_read(png_ptr, local_buffer,
sizeof local_buffer, &length, profile_header, &size,
(sizeof local_buffer), &length, profile_header, &size,
0/*finish: don't, because the output is too small*/);
if (size == 0)
@ -1431,12 +1431,12 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (profile != NULL)
{
memcpy(profile, profile_header,
sizeof profile_header);
(sizeof profile_header));
size = 12 * tag_count;
(void)png_inflate_read(png_ptr, local_buffer,
sizeof local_buffer, &length,
(sizeof local_buffer), &length,
profile + (sizeof profile_header), &size, 0);
/* Still expect a a buffer error because we expect
@ -1455,7 +1455,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
- 12 * tag_count;
(void)png_inflate_read(png_ptr, local_buffer,
sizeof local_buffer, &length,
(sizeof local_buffer), &length,
profile + (sizeof profile_header) +
12 * tag_count, &size, 1/*finish*/);
@ -1694,7 +1694,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
}
dl = (png_int_32)(data_length / entry_size);
max_dl = PNG_SIZE_MAX / png_sizeof(png_sPLT_entry);
max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry));
if (dl > max_dl)
{
@ -1705,7 +1705,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
new_palette.nentries = (png_int_32)(data_length / entry_size);
new_palette.entries = (png_sPLT_entryp)png_malloc_warn(
png_ptr, new_palette.nentries * png_sizeof(png_sPLT_entry));
png_ptr, new_palette.nentries * (sizeof (png_sPLT_entry)));
if (new_palette.entries == NULL)
{
@ -2211,7 +2211,7 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_debug(3, "Allocating pCAL parameters array");
params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,
nparams * png_sizeof(png_charp)));
nparams * (sizeof (png_charp))));
if (params == NULL)
{
@ -3250,22 +3250,22 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
if (bytes_to_copy < 16 /*else use png_memcpy*/ &&
png_isaligned(dp, png_uint_16) &&
png_isaligned(sp, png_uint_16) &&
bytes_to_copy % sizeof (png_uint_16) == 0 &&
bytes_to_jump % sizeof (png_uint_16) == 0)
bytes_to_copy % (sizeof (png_uint_16)) == 0 &&
bytes_to_jump % (sizeof (png_uint_16)) == 0)
{
/* Everything is aligned for png_uint_16 copies, but try for
* png_uint_32 first.
*/
if (png_isaligned(dp, png_uint_32) &&
png_isaligned(sp, png_uint_32) &&
bytes_to_copy % sizeof (png_uint_32) == 0 &&
bytes_to_jump % sizeof (png_uint_32) == 0)
bytes_to_copy % (sizeof (png_uint_32)) == 0 &&
bytes_to_jump % (sizeof (png_uint_32)) == 0)
{
png_uint_32p dp32 = png_aligncast(png_uint_32p,dp);
png_const_uint_32p sp32 = png_aligncastconst(
png_const_uint_32p, sp);
unsigned int skip = (bytes_to_jump-bytes_to_copy) /
sizeof (png_uint_32);
(sizeof (png_uint_32));
do
{
@ -3273,7 +3273,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
do
{
*dp32++ = *sp32++;
c -= sizeof (png_uint_32);
c -= (sizeof (png_uint_32));
}
while (c > 0);
@ -3307,7 +3307,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
png_const_uint_16p sp16 = png_aligncastconst(
png_const_uint_16p, sp);
unsigned int skip = (bytes_to_jump-bytes_to_copy) /
sizeof (png_uint_16);
(sizeof (png_uint_16));
do
{
@ -3315,7 +3315,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
do
{
*dp16++ = *sp16++;
c -= sizeof (png_uint_16);
c -= (sizeof (png_uint_16));
}
while (c > 0);
@ -3793,7 +3793,7 @@ static int png_have_hwcap(unsigned cap)
if (!f)
return 0;
while (fread(&aux, sizeof(aux), 1, f) > 0)
while (fread(&aux, (sizeof aux), 1, f) > 0)
{
if (aux.a_type == AT_HWCAP &&
aux.a_un.a_val & cap)
@ -3935,7 +3935,7 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
else /* check for end */
{
png_ptr->zstream.next_out = tmpbuf;
png_ptr->zstream.avail_out = sizeof tmpbuf;
png_ptr->zstream.avail_out = (sizeof tmpbuf);
}
/* Use NO_FLUSH; this gives zlib the maximum opportunity to optimize the

View File

@ -201,7 +201,7 @@ png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
* version 1.2.1
*/
info_ptr->hist = png_voidcast(png_uint_16p, png_malloc_warn(png_ptr,
PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16)));
PNG_MAX_PALETTE_LENGTH * (sizeof (png_uint_16))));
if (info_ptr->hist == NULL)
{
@ -351,7 +351,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
png_memcpy(info_ptr->pcal_units, units, length);
info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,
(png_size_t)((nparams + 1) * png_sizeof(png_charp))));
(png_size_t)((nparams + 1) * (sizeof (png_charp)))));
if (info_ptr->pcal_params == NULL)
{
@ -359,7 +359,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
return;
}
png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp));
png_memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp)));
for (i = 0; i < nparams; i++)
{
@ -468,9 +468,9 @@ png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit,
char swidth[PNG_sCAL_MAX_DIGITS+1];
char sheight[PNG_sCAL_MAX_DIGITS+1];
png_ascii_from_fp(png_ptr, swidth, sizeof swidth, width,
png_ascii_from_fp(png_ptr, swidth, (sizeof swidth), width,
PNG_sCAL_PRECISION);
png_ascii_from_fp(png_ptr, sheight, sizeof sheight, height,
png_ascii_from_fp(png_ptr, sheight, (sizeof sheight), height,
PNG_sCAL_PRECISION);
png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);
@ -498,8 +498,8 @@ png_set_sCAL_fixed(png_const_structrp png_ptr, png_inforp info_ptr, int unit,
char swidth[PNG_sCAL_MAX_DIGITS+1];
char sheight[PNG_sCAL_MAX_DIGITS+1];
png_ascii_from_fixed(png_ptr, swidth, sizeof swidth, width);
png_ascii_from_fixed(png_ptr, sheight, sizeof sheight, height);
png_ascii_from_fixed(png_ptr, swidth, (sizeof swidth), width);
png_ascii_from_fixed(png_ptr, sheight, (sizeof sheight), height);
png_set_sCAL_s(png_ptr, info_ptr, unit, swidth, sheight);
}
@ -560,9 +560,9 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
* too-large sample values.
*/
png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color)));
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof(png_color));
png_memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
info_ptr->palette = png_ptr->palette;
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
@ -733,7 +733,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
old_text = info_ptr->text;
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
(png_size_t)(info_ptr->max_text * png_sizeof(png_text)));
(png_size_t)(info_ptr->max_text * (sizeof (png_text))));
if (info_ptr->text == NULL)
{
@ -744,7 +744,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
}
png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max_text *
png_sizeof(png_text)));
(sizeof (png_text))));
png_free(png_ptr, old_text);
}
@ -753,7 +753,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
info_ptr->max_text = num_text + 8;
info_ptr->num_text = 0;
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
(png_size_t)(info_ptr->max_text * png_sizeof(png_text)));
(png_size_t)(info_ptr->max_text * (sizeof (png_text))));
if (info_ptr->text == NULL)
{
/* Restore to previous condition */
@ -999,7 +999,7 @@ png_set_sPLT(png_const_structrp png_ptr,
return;
np = png_voidcast(png_sPLT_tp, png_malloc_warn(png_ptr,
(info_ptr->splt_palettes_num + nentries) * png_sizeof(png_sPLT_t)));
(info_ptr->splt_palettes_num + nentries) * (sizeof (png_sPLT_t))));
if (np == NULL)
{
@ -1008,7 +1008,7 @@ png_set_sPLT(png_const_structrp png_ptr,
}
png_memcpy(np, info_ptr->splt_palettes,
info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t));
info_ptr->splt_palettes_num * (sizeof (png_sPLT_t)));
png_free(png_ptr, info_ptr->splt_palettes);
info_ptr->splt_palettes=NULL;
@ -1026,7 +1026,7 @@ png_set_sPLT(png_const_structrp png_ptr,
* NULL, otherwise libpng will crash later on while trying to free the
* uninitialized pointers.
*/
png_memset(to, 0, sizeof *to);
png_memset(to, 0, (sizeof *to));
if (from->name == NULL || from->entries == NULL)
continue;
@ -1043,7 +1043,7 @@ png_set_sPLT(png_const_structrp png_ptr,
png_memcpy(to->name, from->name, length);
to->entries = png_voidcast(png_sPLT_entryp, png_malloc_warn(png_ptr,
from->nentries * png_sizeof(png_sPLT_entry)));
from->nentries * (sizeof (png_sPLT_entry))));
if (to->entries == NULL)
{
@ -1054,7 +1054,7 @@ png_set_sPLT(png_const_structrp png_ptr,
}
png_memcpy(to->entries, from->entries,
from->nentries * png_sizeof(png_sPLT_entry));
from->nentries * (sizeof (png_sPLT_entry)));
to->nentries = from->nentries;
to->depth = from->depth;
@ -1080,7 +1080,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
np = png_voidcast(png_unknown_chunkp, png_malloc_warn(png_ptr,
(png_size_t)(info_ptr->unknown_chunks_num + num_unknowns) *
png_sizeof(png_unknown_chunk)));
(sizeof (png_unknown_chunk))));
if (np == NULL)
{
@ -1091,7 +1091,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
png_memcpy(np, info_ptr->unknown_chunks,
(png_size_t)info_ptr->unknown_chunks_num *
png_sizeof(png_unknown_chunk));
(sizeof (png_unknown_chunk)));
png_free(png_ptr, info_ptr->unknown_chunks);
info_ptr->unknown_chunks = NULL;
@ -1101,8 +1101,8 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
png_const_unknown_chunkp from = unknowns + i;
png_memcpy(to->name, from->name, png_sizeof(from->name));
to->name[png_sizeof(to->name)-1] = '\0';
png_memcpy(to->name, from->name, (sizeof from->name));
to->name[(sizeof to->name)-1] = '\0';
to->size = from->size;
/* Note our location in the read or write sequence */
@ -1213,7 +1213,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
};
chunk_list = chunks_to_ignore;
num_chunks = (unsigned int) sizeof(chunks_to_ignore)/5;
num_chunks = (unsigned int)(sizeof chunks_to_ignore)/5;
}
if (chunk_list == NULL)

View File

@ -462,7 +462,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
memory_infop pinfo;
png_set_mem_fn(png_ptr, NULL, NULL, NULL);
pinfo = (memory_infop)png_malloc(png_ptr,
png_sizeof(*pinfo));
(sizeof *pinfo));
pinfo->size = size;
current_allocation += size;
total_allocation += size;
@ -1047,12 +1047,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_set_tIME(write_ptr, write_info_ptr, mod_time);
#ifdef PNG_TIME_RFC1123_SUPPORTED
if (png_convert_to_rfc1123_buffer(tIME_string, mod_time))
tIME_string[png_sizeof(tIME_string) - 1] = '\0';
tIME_string[(sizeof tIME_string) - 1] = '\0';
else
{
strncpy(tIME_string, "*** invalid time ***", sizeof tIME_string);
tIME_string[(sizeof tIME_string)-1] = '\0';
strncpy(tIME_string, "*** invalid time ***", (sizeof tIME_string));
tIME_string[(sizeof tIME_string) - 1] = '\0';
}
tIME_chunk_present++;
@ -1256,7 +1256,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_set_tIME(write_ptr, write_end_info_ptr, mod_time);
#ifdef PNG_TIME_RFC1123_SUPPORTED
if (png_convert_to_rfc1123_buffer(tIME_string, mod_time))
tIME_string[png_sizeof(tIME_string) - 1] = '\0';
tIME_string[(sizeof tIME_string) - 1] = '\0';
else
{

View File

@ -1116,7 +1116,7 @@ png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method,
if (num_weights > 0)
{
png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(png_sizeof(png_byte) * num_weights));
(png_uint_32)((sizeof (png_byte)) * num_weights));
/* To make sure that the weighting starts out fairly */
for (i = 0; i < num_weights; i++)
@ -1125,10 +1125,10 @@ png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method,
}
png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(png_sizeof(png_uint_16) * num_weights));
(png_uint_32)((sizeof (png_uint_16)) * num_weights));
png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(png_sizeof(png_uint_16) * num_weights));
(png_uint_32)((sizeof (png_uint_16)) * num_weights));
for (i = 0; i < num_weights; i++)
{
@ -1146,10 +1146,10 @@ png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method,
if (png_ptr->filter_costs == NULL)
{
png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
(png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST));
png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,
(png_uint_32)(png_sizeof(png_uint_16) * PNG_FILTER_VALUE_LAST));
(png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST));
}
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
@ -1586,11 +1586,11 @@ png_image_write_init(png_imagep image)
if (info_ptr != NULL)
{
png_controlp control = png_voidcast(png_controlp,
png_malloc_warn(png_ptr, sizeof *control));
png_malloc_warn(png_ptr, (sizeof *control)));
if (control != NULL)
{
png_memset(control, 0, sizeof *control);
png_memset(control, 0, (sizeof *control));
control->png_ptr = png_ptr;
control->info_ptr = info_ptr;
@ -1907,8 +1907,8 @@ png_image_set_PLTE(png_image_write_control *display)
png_color palette[256];
png_byte tRNS[256];
memset(tRNS, 255, sizeof tRNS);
memset(palette, 0, sizeof palette);
memset(tRNS, 255, (sizeof tRNS));
memset(palette, 0, (sizeof palette));
for (i=num_trans=0; i<entries; ++i)
{
@ -2154,7 +2154,7 @@ png_image_write_main(png_voidp argument)
ptrdiff_t row_bytes = display->row_stride;
if (linear)
row_bytes *= sizeof (png_uint_16);
row_bytes *= (sizeof (png_uint_16));
if (row_bytes < 0)
row += (image->height-1) * (-row_bytes);
@ -2239,7 +2239,7 @@ png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
*/
image->opaque->png_ptr->io_ptr = file;
png_memset(&display, 0, sizeof display);
png_memset(&display, 0, (sizeof display));
display.image = image;
display.buffer = buffer;
display.row_stride = row_stride;

View File

@ -324,7 +324,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
* internal error, but is very useful for debugging. i18n requirements
* are minimal.
*/
(void)png_safecat(msg, sizeof msg, 10, " using zstream");
(void)png_safecat(msg, (sizeof msg), 10, " using zstream");
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
png_warning(png_ptr, msg);
@ -537,7 +537,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
png_ptr->zstream.next_in = PNGZ_INPUT_CAST(comp->input);
png_ptr->zstream.avail_in = 0; /* Set below */
png_ptr->zstream.next_out = comp->output;
png_ptr->zstream.avail_out = sizeof comp->output;
png_ptr->zstream.avail_out = (sizeof comp->output);
output_len = png_ptr->zstream.avail_out;
@ -654,7 +654,7 @@ png_write_compressed_data_out(png_structrp png_ptr, compression_state *comp)
{
png_uint_32 output_len = comp->output_len;
png_const_bytep output = comp->output;
png_uint_32 avail = sizeof comp->output;
png_uint_32 avail = (sizeof comp->output);
png_compression_buffer *next = png_ptr->zbuffer_list;
for (;;)
@ -1828,7 +1828,7 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
total_len = purpose_len + units_len + 10;
params_len = (png_size_tp)png_malloc(png_ptr,
(png_alloc_size_t)(nparams * png_sizeof(png_size_t)));
(png_alloc_size_t)(nparams * (sizeof (png_size_t))));
/* Find the length of each parameter, making sure we don't count the
* null terminator for the last parameter.