diff --git a/gyp/codec.gyp b/gyp/codec.gyp index e2269f2a93..4b4029bdf3 100644 --- a/gyp/codec.gyp +++ b/gyp/codec.gyp @@ -22,11 +22,6 @@ 'libpng.gyp:libpng', 'libwebp.gyp:libwebp', ], - 'cflags':[ - # FIXME: This gets around a warning: "Argument might be clobbered by longjmp". - '-Wno-clobbered', - '-Wno-unknown-warning-option', - ], 'include_dirs': [ '../include/codec', '../include/private', diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp index f4116e324f..6a1636c3cf 100644 --- a/src/codec/SkJpegCodec.cpp +++ b/src/codec/SkJpegCodec.cpp @@ -19,6 +19,12 @@ #include #include "SkJpegUtility.h" +// Same as setjmp, but introduces a new empty scope. +// This way we can avoid GCC's overactive warnings about clobbered locals. +static int setjmp_no_locals(jmp_buf env) { + return setjmp(env); +} + extern "C" { #include "jerror.h" #include "jpeglib.h" @@ -190,7 +196,7 @@ bool SkJpegCodec::ReadHeader(SkStream* stream, SkCodec** codecOut, SkAutoTDelete decoderMgr(new JpegDecoderMgr(stream)); // libjpeg errors will be caught and reported here - if (setjmp(decoderMgr->getJmpBuf())) { + if (setjmp_no_locals(decoderMgr->getJmpBuf())) { return decoderMgr->returnFalse("setjmp"); } @@ -414,7 +420,7 @@ bool SkJpegCodec::setOutputColorSpace(const SkImageInfo& dst) { * dimensions if possible */ bool SkJpegCodec::onDimensionsSupported(const SkISize& size) { - if (setjmp(fDecoderMgr->getJmpBuf())) { + if (setjmp_no_locals(fDecoderMgr->getJmpBuf())) { return fDecoderMgr->returnFalse("onDimensionsSupported/setjmp"); } @@ -466,7 +472,7 @@ SkCodec::Result SkJpegCodec::onGetPixels(const SkImageInfo& dstInfo, jpeg_decompress_struct* dinfo = fDecoderMgr->dinfo(); // Set the jump location for libjpeg errors - if (setjmp(fDecoderMgr->getJmpBuf())) { + if (setjmp_no_locals(fDecoderMgr->getJmpBuf())) { return fDecoderMgr->returnFailure("setjmp", kInvalidInput); } @@ -575,7 +581,7 @@ SkSampler* SkJpegCodec::getSampler(bool createIfNecessary) { SkCodec::Result SkJpegCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, const Options& options, SkPMColor ctable[], int* ctableCount) { // Set the jump location for libjpeg errors - if (setjmp(fDecoderMgr->getJmpBuf())) { + if (setjmp_no_locals(fDecoderMgr->getJmpBuf())) { SkCodecPrintf("setjmp: Error from libjpeg\n"); return kInvalidInput; } @@ -651,7 +657,7 @@ SkCodec::Result SkJpegCodec::onStartScanlineDecode(const SkImageInfo& dstInfo, int SkJpegCodec::onGetScanlines(void* dst, int count, size_t dstRowBytes) { // Set the jump location for libjpeg errors - if (setjmp(fDecoderMgr->getJmpBuf())) { + if (setjmp_no_locals(fDecoderMgr->getJmpBuf())) { return fDecoderMgr->returnFailure("setjmp", kInvalidInput); } // Read rows one at a time @@ -688,7 +694,7 @@ int SkJpegCodec::onGetScanlines(void* dst, int count, size_t dstRowBytes) { bool SkJpegCodec::onSkipScanlines(int count) { // Set the jump location for libjpeg errors - if (setjmp(fDecoderMgr->getJmpBuf())) { + if (setjmp_no_locals(fDecoderMgr->getJmpBuf())) { return fDecoderMgr->returnFalse("setjmp"); } @@ -803,7 +809,7 @@ SkCodec::Result SkJpegCodec::onGetYUV8Planes(const SkYUVSizeInfo& sizeInfo, void } // Set the jump location for libjpeg errors - if (setjmp(fDecoderMgr->getJmpBuf())) { + if (setjmp_no_locals(fDecoderMgr->getJmpBuf())) { return fDecoderMgr->returnFailure("setjmp", kInvalidInput); } diff --git a/src/codec/SkPngCodec.cpp b/src/codec/SkPngCodec.cpp index ee72af58ad..b8916f9de7 100644 --- a/src/codec/SkPngCodec.cpp +++ b/src/codec/SkPngCodec.cpp @@ -20,6 +20,11 @@ #include "SkTemplates.h" #include "SkUtils.h" +// This warning triggers false postives way too often in here. +#if defined(__GNUC__) && !defined(__clang__) + #pragma GCC diagnostic ignored "-Wclobbered" +#endif + /////////////////////////////////////////////////////////////////////////////// // Callback functions ///////////////////////////////////////////////////////////////////////////////