From 88b7470c075d0e9da72f0f3f6f55729d221f4ecc Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Fri, 12 Aug 2016 19:13:44 +0200 Subject: [PATCH] gsdx: use const qualifier to avoid gcc (false positive) warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit variable might be clobbered by ‘longjmp’ or ‘vfork’ Only remains warning for 2 variables: success & image --- plugins/GSdx/GSPng.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/plugins/GSdx/GSPng.cpp b/plugins/GSdx/GSPng.cpp index 62b7e7d4b5..2f05774640 100644 --- a/plugins/GSdx/GSPng.cpp +++ b/plugins/GSdx/GSPng.cpp @@ -42,15 +42,17 @@ struct { namespace GSPng { bool SaveFile(const string& file, Format fmt, uint8* image, uint8* row, - int width, int height, int pitch, int compression, + int width, int height, int pitch, int _compression, bool rb_swapped = false, bool first_image = false) { int channel_bit_depth = pixel[fmt].channel_bit_depth; int bytes_per_pixel_in = pixel[fmt].bytes_per_pixel_in; - int type = first_image ? pixel[fmt].type : PNG_COLOR_TYPE_GRAY; - int offset = first_image ? 0 : pixel[fmt].bytes_per_pixel_out; - int bytes_per_pixel_out = first_image ? pixel[fmt].bytes_per_pixel_out : bytes_per_pixel_in - offset; + const int type = first_image ? pixel[fmt].type : PNG_COLOR_TYPE_GRAY; + const int offset = first_image ? 0 : pixel[fmt].bytes_per_pixel_out; + const int bytes_per_pixel_out = first_image ? pixel[fmt].bytes_per_pixel_out : bytes_per_pixel_in - offset; + + const int compression = (_compression < 0 || _compression > Z_BEST_COMPRESSION) ? Z_BEST_SPEED : _compression; FILE *fp = fopen(file.c_str(), "wb"); if (fp == nullptr) @@ -71,9 +73,6 @@ namespace GSPng { if (setjmp(png_jmpbuf(png_ptr))) throw GSDXRecoverableError(); - if (compression < 0 || compression > Z_BEST_COMPRESSION) - compression = Z_BEST_SPEED; - png_init_io(png_ptr, fp); png_set_compression_level(png_ptr, compression); png_set_IHDR(png_ptr, info_ptr, width, height, channel_bit_depth, type,