libpng: Resolve -Wno-implicit-fallthrough warnings

This commit is contained in:
Luke Street 2020-09-18 17:02:11 -04:00
parent a5f5308dc3
commit 6d74ae79ef
6 changed files with 20 additions and 12 deletions

View File

@ -163,7 +163,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
case PNG_NUMBER_FORMAT_02u: case PNG_NUMBER_FORMAT_02u:
/* Expects at least 2 digits. */ /* Expects at least 2 digits. */
mincount = 2; mincount = 2;
/* FALL THROUGH */ FALLTHROUGH;
case PNG_NUMBER_FORMAT_u: case PNG_NUMBER_FORMAT_u:
*--end = digits[number % 10]; *--end = digits[number % 10];
@ -173,7 +173,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
case PNG_NUMBER_FORMAT_02x: case PNG_NUMBER_FORMAT_02x:
/* This format expects at least two digits */ /* This format expects at least two digits */
mincount = 2; mincount = 2;
/* FALL THROUGH */ FALLTHROUGH;
case PNG_NUMBER_FORMAT_x: case PNG_NUMBER_FORMAT_x:
*--end = digits[number & 0xf]; *--end = digits[number & 0xf];

View File

@ -1909,6 +1909,12 @@ PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY); (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
#endif #endif
#if __has_attribute(fallthrough)
#define FALLTHROUGH __attribute__((fallthrough))
#else
#define FALLTHROUGH
#endif
/* Maintainer: Put new private prototypes here ^ */ /* Maintainer: Put new private prototypes here ^ */
#include "pngdebug.h" #include "pngdebug.h"

View File

@ -1872,7 +1872,7 @@ png_create_colormap_entry(png_image_read_control *display,
{ {
case 4: case 4:
entry[afirst ? 0 : 3] = (png_uint_16)alpha; entry[afirst ? 0 : 3] = (png_uint_16)alpha;
/* FALL THROUGH */ FALLTHROUGH;
case 3: case 3:
if (alpha < 65535) if (alpha < 65535)
@ -1894,7 +1894,7 @@ png_create_colormap_entry(png_image_read_control *display,
case 2: case 2:
entry[1 ^ afirst] = (png_uint_16)alpha; entry[1 ^ afirst] = (png_uint_16)alpha;
/* FALL THROUGH */ FALLTHROUGH;
case 1: case 1:
if (alpha < 65535) if (alpha < 65535)
@ -1923,6 +1923,7 @@ png_create_colormap_entry(png_image_read_control *display,
{ {
case 4: case 4:
entry[afirst ? 0 : 3] = (png_byte)alpha; entry[afirst ? 0 : 3] = (png_byte)alpha;
FALLTHROUGH;
case 3: case 3:
entry[afirst + (2 ^ bgr)] = (png_byte)blue; entry[afirst + (2 ^ bgr)] = (png_byte)blue;
entry[afirst + 1] = (png_byte)green; entry[afirst + 1] = (png_byte)green;
@ -1931,6 +1932,7 @@ png_create_colormap_entry(png_image_read_control *display,
case 2: case 2:
entry[1 ^ afirst] = (png_byte)alpha; entry[1 ^ afirst] = (png_byte)alpha;
FALLTHROUGH;
case 1: case 1:
entry[afirst] = (png_byte)green; entry[afirst] = (png_byte)green;
break; break;
@ -2851,7 +2853,7 @@ png_image_read_colormap(png_voidp argument)
case P_sRGB: case P_sRGB:
/* Change to 8-bit sRGB */ /* Change to 8-bit sRGB */
png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB); png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB);
/* FALL THROUGH */ FALLTHROUGH;
case P_FILE: case P_FILE:
if (png_ptr->bit_depth > 8) if (png_ptr->bit_depth > 8)
@ -3170,7 +3172,7 @@ png_image_read_colormapped(png_voidp argument)
break; break;
/* goto bad_output; */ /* goto bad_output; */
/* FALL THROUGH */ FALLTHROUGH;
default: default:
bad_output: bad_output:

View File

@ -49,8 +49,8 @@ png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action)
case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */ case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */
png_warning(png_ptr, png_warning(png_ptr,
"Can't discard critical data on CRC error"); "Can't discard critical data on CRC error");
FALLTHROUGH;
case PNG_CRC_ERROR_QUIT: /* Error/quit */ case PNG_CRC_ERROR_QUIT: /* Error/quit */
case PNG_CRC_DEFAULT: case PNG_CRC_DEFAULT:
default: default:
png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK; png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;

View File

@ -2938,7 +2938,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
case 2: case 2:
png_ptr->user_chunk_cache_max = 1; png_ptr->user_chunk_cache_max = 1;
png_chunk_benign_error(png_ptr, "no space in chunk cache"); png_chunk_benign_error(png_ptr, "no space in chunk cache");
/* FALL THROUGH */ FALLTHROUGH;
case 1: case 1:
/* NOTE: prior to 1.6.0 this case resulted in an unknown critical /* NOTE: prior to 1.6.0 this case resulted in an unknown critical
* chunk being skipped, now there will be a hard error below. * chunk being skipped, now there will be a hard error below.
@ -2947,7 +2947,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
default: /* not at limit */ default: /* not at limit */
--(png_ptr->user_chunk_cache_max); --(png_ptr->user_chunk_cache_max);
/* FALL THROUGH */ FALLTHROUGH;
case 0: /* no limit */ case 0: /* no limit */
# endif /* USER_LIMITS */ # endif /* USER_LIMITS */
/* Here when the limit isn't reached or when limits are compiled /* Here when the limit isn't reached or when limits are compiled

View File

@ -1007,7 +1007,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
case 5: case 5:
case 6: case 6:
case 7: png_app_error(png_ptr, "Unknown row filter for method 0"); case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
/* FALL THROUGH */ FALLTHROUGH;
#endif /* WRITE_FILTER */ #endif /* WRITE_FILTER */
case PNG_FILTER_VALUE_NONE: case PNG_FILTER_VALUE_NONE:
png_ptr->do_filter = PNG_FILTER_NONE; break; png_ptr->do_filter = PNG_FILTER_NONE; break;
@ -1870,7 +1870,7 @@ png_image_set_PLTE(png_image_write_control *display)
tRNS[i] = entry[afirst ? 0 : 3]; tRNS[i] = entry[afirst ? 0 : 3];
if (tRNS[i] < 255) if (tRNS[i] < 255)
num_trans = i+1; num_trans = i+1;
/* FALL THROUGH */ FALLTHROUGH;
case 3: case 3:
palette[i].blue = entry[afirst + (2 ^ bgr)]; palette[i].blue = entry[afirst + (2 ^ bgr)];
palette[i].green = entry[afirst + 1]; palette[i].green = entry[afirst + 1];
@ -1881,7 +1881,7 @@ png_image_set_PLTE(png_image_write_control *display)
tRNS[i] = entry[1 ^ afirst]; tRNS[i] = entry[1 ^ afirst];
if (tRNS[i] < 255) if (tRNS[i] < 255)
num_trans = i+1; num_trans = i+1;
/* FALL THROUGH */ FALLTHROUGH;
case 1: case 1:
palette[i].blue = palette[i].red = palette[i].green = palette[i].blue = palette[i].red = palette[i].green =
entry[afirst]; entry[afirst];