diff --git a/png.c b/png.c index 4928ec4dd..982051dbb 100644 --- a/png.c +++ b/png.c @@ -1634,14 +1634,15 @@ png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ, int preferred) { - if (colorspace->flags & PNG_COLORSPACE_INVALID) + if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0) return 0; /* The consistency check is performed on the chromaticities; this factors out * variations because of the normalization (or not) of the end point Y * values. */ - if (preferred < 2 && (colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS)) + if (preferred < 2 && + (colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) { /* The end points must be reasonably close to any we already have. The * following allows an error of up to +/-.001 diff --git a/pngget.c b/pngget.c index debcfad8b..ed00f8b4b 100644 --- a/pngget.c +++ b/pngget.c @@ -182,7 +182,8 @@ png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp info_ptr) { #ifdef PNG_READ_pHYs_SUPPORTED - if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs)) + if (png_ptr != NULL && info_ptr != NULL && + (info_ptr->valid & PNG_INFO_pHYs) != 0) { png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio"); diff --git a/pngpread.c b/pngpread.c index cfed62d0c..e7eca1f87 100644 --- a/pngpread.c +++ b/pngpread.c @@ -232,7 +232,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) png_error(png_ptr, "Missing IHDR before IDAT"); else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE && - !(png_ptr->mode & PNG_HAVE_PLTE)) + (png_ptr->mode & PNG_HAVE_PLTE) == 0) png_error(png_ptr, "Missing PLTE before IDAT"); png_ptr->mode |= PNG_HAVE_IDAT; diff --git a/pngread.c b/pngread.c index 2c19651ae..f5ea01e2d 100644 --- a/pngread.c +++ b/pngread.c @@ -126,7 +126,7 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) png_ptr->mode |= PNG_HAVE_IDAT; } - else if (png_ptr->mode & PNG_HAVE_IDAT) + else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0) png_ptr->mode |= PNG_AFTER_IDAT; /* This should be a binary subdivision search or a hash for @@ -315,7 +315,7 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) png_debug(1, "in png_do_read_intrapixel"); if ( - (row_info->color_type & PNG_COLOR_MASK_COLOR)) + (row_info->color_type & PNG_COLOR_MASK_COLOR) != 0) { int bytes_per_pixel; png_uint_32 row_width = row_info->width; @@ -401,38 +401,38 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) { /* Check for transforms that have been set but were defined out */ #if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED) - if (png_ptr->transformations & PNG_INVERT_MONO) + if ((png_ptr->transformations & PNG_INVERT_MONO) != 0) png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined"); #endif #if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED) - if (png_ptr->transformations & PNG_FILLER) + if ((png_ptr->transformations & PNG_FILLER) != 0) png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined"); #endif #if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && \ !defined(PNG_READ_PACKSWAP_SUPPORTED) - if (png_ptr->transformations & PNG_PACKSWAP) + if ((png_ptr->transformations & PNG_PACKSWAP) != 0) png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined"); #endif #if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED) - if (png_ptr->transformations & PNG_PACK) + if ((png_ptr->transformations & PNG_PACK) != 0) png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined"); #endif #if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) - if (png_ptr->transformations & PNG_SHIFT) + if ((png_ptr->transformations & PNG_SHIFT) != 0) png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined"); #endif #if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED) - if (png_ptr->transformations & PNG_BGR) + if ((png_ptr->transformations & PNG_BGR) != 0) png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined"); #endif #if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED) - if (png_ptr->transformations & PNG_SWAP_BYTES) + if ((png_ptr->transformations & PNG_SWAP_BYTES) != 0) png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined"); #endif } @@ -445,7 +445,8 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) * untransformed) and, because of the libpng API for interlaced images, this * means we must transform before de-interlacing. */ - if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE)) + if (png_ptr->interlaced != 0 && + (png_ptr->transformations & PNG_INTERLACE) != 0) { switch (png_ptr->pass) { @@ -549,7 +550,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) memcpy(png_ptr->prev_row, png_ptr->row_buf, row_info.rowbytes + 1); #ifdef PNG_MNG_FEATURES_SUPPORTED - if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && + if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING)) { /* Intrapixel differencing */ @@ -575,8 +576,8 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) #ifdef PNG_READ_INTERLACING_SUPPORTED /* Expand interlaced rows to full size */ - if (png_ptr->interlaced && - (png_ptr->transformations & PNG_INTERLACE)) + if (png_ptr->interlaced != 0 && + (png_ptr->transformations & PNG_INTERLACE) != 0) { if (png_ptr->pass < 6) png_do_read_interlace(&row_info, png_ptr->row_buf + 1, png_ptr->pass, @@ -707,7 +708,8 @@ png_read_image(png_structrp png_ptr, png_bytepp image) } else { - if (png_ptr->interlaced && !(png_ptr->transformations & PNG_INTERLACE)) + if (png_ptr->interlaced != 0 && + (png_ptr->transformations & PNG_INTERLACE) == 0) { /* Caller called png_start_read_image or png_read_update_info without * first turning on the PNG_INTERLACE transform. We can fix this here, @@ -909,7 +911,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) else png_handle_unknown(png_ptr, info_ptr, length, PNG_HANDLE_CHUNK_AS_DEFAULT); - } while (!(png_ptr->mode & PNG_HAVE_IEND)); + } while ((png_ptr->mode & PNG_HAVE_IEND) == 0); } #endif /* PNG_SEQUENTIAL_READ_SUPPORTED */ @@ -1734,7 +1736,7 @@ png_create_colormap_entry(png_image_read_control *display, png_uint_32 alpha, int encoding) { png_imagep image = display->image; - const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) ? + const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ? P_LINEAR : P_sRGB; const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 && (red != green || green != blue); @@ -1850,7 +1852,7 @@ png_create_colormap_entry(png_image_read_control *display, # define afirst 0 # endif # ifdef PNG_FORMAT_BGR_SUPPORTED - const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) ? 2 : 0; + const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0; # else # define bgr 0 # endif @@ -2062,7 +2064,7 @@ png_image_read_colormap(png_voidp argument) const png_structrp png_ptr = image->opaque->png_ptr; const png_uint_32 output_format = image->format; - const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) ? + const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ? P_LINEAR : P_sRGB; unsigned int cmap_entries; @@ -3243,7 +3245,8 @@ png_image_read_composite(png_voidp argument) png_uint_32 height = image->height; png_uint_32 width = image->width; ptrdiff_t step_row = display->row_bytes; - unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1; + unsigned int channels = + (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1; int pass; for (pass = 0; pass < passes; ++pass) @@ -3542,7 +3545,7 @@ png_image_read_background(png_voidp argument) # ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED if (preserve_alpha != 0 && - (image->format & PNG_FORMAT_FLAG_AFIRST)) + (image->format & PNG_FORMAT_FLAG_AFIRST) != 0) swap_alpha = 1; # endif diff --git a/pngrtran.c b/pngrtran.c index cb7582138..8d7904cb9 100644 --- a/pngrtran.c +++ b/pngrtran.c @@ -4838,7 +4838,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) */ !((png_ptr->transformations & PNG_COMPOSE) && ((png_ptr->num_trans != 0) || - (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) && + (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) && #endif /* Because png_init_read_transformations transforms the palette, unless * RGB_TO_GRAY will do the transform. diff --git a/pngrutil.c b/pngrutil.c index 663467a6f..1710da638 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -220,8 +220,8 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip) if (png_crc_error(png_ptr) != 0) { if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0 ? - !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) : - (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE)) + (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) == 0 : + (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE) != 0) { png_chunk_warning(png_ptr, "CRC error"); } diff --git a/pngwrite.c b/pngwrite.c index 23d9f4fa5..4410797de 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1750,7 +1750,7 @@ png_write_image_16bit(png_voidp argument) display->first_row); png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row); png_uint_16p row_end; - const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1; + const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1; int aindex = 0; png_uint_32 y = image->height; @@ -1907,7 +1907,7 @@ png_write_image_8bit(png_voidp argument) display->first_row); png_bytep output_row = png_voidcast(png_bytep, display->local_row); png_uint_32 y = image->height; - const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) ? 3 : 1; + const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1; if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0) { @@ -2012,7 +2012,7 @@ png_image_set_PLTE(png_image_write_control *display) # endif # ifdef PNG_FORMAT_BGR_SUPPORTED - const int bgr = (format & PNG_FORMAT_FLAG_BGR) ? 2 : 0; + const int bgr = (format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0; # else # define bgr 0 # endif diff --git a/pngwutil.c b/pngwutil.c index fdd5be8a0..4fbf6b815 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -848,8 +848,8 @@ png_write_IHDR(png_structrp png_ptr, png_uint_32 width, png_uint_32 height, */ if ( #ifdef PNG_MNG_FEATURES_SUPPORTED - !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && - ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) && + !((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) != 0 && + ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) == 0) && (color_type == PNG_COLOR_TYPE_RGB || color_type == PNG_COLOR_TYPE_RGB_ALPHA) && (filter_type == PNG_INTRAPIXEL_DIFFERENCING)) &&