diff options
author | mtklein <mtklein@chromium.org> | 2016-07-28 11:57:30 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-07-28 11:57:31 -0700 |
commit | 03f704a343d7a82974f977eda8789a8c721c93e5 (patch) | |
tree | 23ba2c5a1886c53475cad6804373b169bf70092c /src | |
parent | 50d1847815ac5525347c4a86e822f321b944d39d (diff) |
Silence -Wclobbered in each file that needs it.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2184823009
Review-Url: https://codereview.chromium.org/2184823009
Diffstat (limited to 'src')
-rw-r--r-- | src/codec/SkJpegCodec.cpp | 20 | ||||
-rw-r--r-- | src/codec/SkPngCodec.cpp | 5 |
2 files changed, 18 insertions, 7 deletions
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 <stdio.h> #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<JpegDecoderMgr> 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 /////////////////////////////////////////////////////////////////////////////// |