bug fixes from PVS Studio (static analysis)

- Hal, please check out SkPDFCanon... was this unused?
  - Cary, please SkOpContour... is it right that allDone isn't necessary?
  - Brian, the rest?

Bug: chromium:805881

Change-Id: I7cbbcf44f4460a114f4ed2a59ed3856203049cdc
Reviewed-on: https://skia-review.googlesource.com/99960
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Hal Canary <halcanary@google.com>
Reviewed-by: Cary Clark <caryclark@google.com>
Commit-Queue: Mike Klein <mtklein@chromium.org>
This commit is contained in:
Mike Klein 2018-01-25 17:32:51 -05:00 committed by Skia Commit-Bot
parent 5a907a7cce
commit 1d746208a1
6 changed files with 6 additions and 13 deletions

View File

@ -771,9 +771,6 @@ bool SkPathRef::isValid() const {
if (nullptr == fPoints && 0 != fFreeSpace) { if (nullptr == fPoints && 0 != fFreeSpace) {
return false; return false;
} }
if (nullptr == fPoints && 0 != fFreeSpace) {
return false;
}
if (nullptr == fPoints && fPointCnt) { if (nullptr == fPoints && fPointCnt) {
return false; return false;
} }

View File

@ -3314,7 +3314,7 @@ static inline bool can_blit_framebuffer_for_copy_surface(
// have filtered such cases out. // have filtered such cases out.
SkASSERT(GrPixelConfigIsSint(dst->config()) == GrPixelConfigIsSint(src->config())); SkASSERT(GrPixelConfigIsSint(dst->config()) == GrPixelConfigIsSint(src->config()));
const GrGLTexture* dstTex = static_cast<const GrGLTexture*>(dst->asTexture()); const GrGLTexture* dstTex = static_cast<const GrGLTexture*>(dst->asTexture());
const GrGLTexture* srcTex = static_cast<const GrGLTexture*>(dst->asTexture()); const GrGLTexture* srcTex = static_cast<const GrGLTexture*>(src->asTexture());
const GrRenderTarget* dstRT = dst->asRenderTarget(); const GrRenderTarget* dstRT = dst->asRenderTarget();
const GrRenderTarget* srcRT = src->asRenderTarget(); const GrRenderTarget* srcRT = src->asRenderTarget();
if (dstTex && dstTex->target() != GR_GL_TEXTURE_2D) { if (dstTex && dstTex->target() != GR_GL_TEXTURE_2D) {

View File

@ -274,10 +274,10 @@ GrGLProgram* GrGLProgramBuilder::finalize() {
// store shader in cache // store shader in cache
sk_sp<SkData> key = SkData::MakeWithoutCopy(desc()->asKey(), desc()->keyLength()); sk_sp<SkData> key = SkData::MakeWithoutCopy(desc()->asKey(), desc()->keyLength());
GrGLenum binaryFormat; GrGLenum binaryFormat;
std::unique_ptr<char> binary(new char[length]); std::unique_ptr<char[]> binary(new char[length]);
GL_CALL(GetProgramBinary(programID, length, &length, &binaryFormat, binary.get())); GL_CALL(GetProgramBinary(programID, length, &length, &binaryFormat, binary.get()));
size_t dataLength = sizeof(inputs) + sizeof(binaryFormat) + length; size_t dataLength = sizeof(inputs) + sizeof(binaryFormat) + length;
std::unique_ptr<uint8_t> data((uint8_t*) malloc(dataLength)); std::unique_ptr<uint8_t[]> data(new uint8_t[dataLength]);
size_t offset = 0; size_t offset = 0;
memcpy(data.get() + offset, &inputs, sizeof(inputs)); memcpy(data.get() + offset, &inputs, sizeof(inputs));
offset += sizeof(inputs); offset += sizeof(inputs);

View File

@ -273,7 +273,7 @@ public:
SkString str; SkString str;
str.appendf("# combined: %d\n", fRects.count()); str.appendf("# combined: %d\n", fRects.count());
for (int i = 0; i < fRects.count(); ++i) { for (int i = 0; i < fRects.count(); ++i) {
const RectInfo& geo = fRects[0]; const RectInfo& geo = fRects[i];
str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", i, str.appendf("%d: Color: 0x%08x, Rect [L: %.2f, T: %.2f, R: %.2f, B: %.2f]\n", i,
geo.fColor, geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight, geo.fColor, geo.fRect.fLeft, geo.fRect.fTop, geo.fRect.fRight,
geo.fRect.fBottom); geo.fRect.fBottom);

View File

@ -32,17 +32,13 @@ void SkOpContour::toReversePath(SkPathWriter* path) const {
SkOpSpan* SkOpContour::undoneSpan() { SkOpSpan* SkOpContour::undoneSpan() {
SkOpSegment* testSegment = &fHead; SkOpSegment* testSegment = &fHead;
bool allDone = true;
do { do {
if (testSegment->done()) { if (testSegment->done()) {
continue; continue;
} }
allDone = false;
return testSegment->undoneSpan(); return testSegment->undoneSpan();
} while ((testSegment = testSegment->next())); } while ((testSegment = testSegment->next()));
if (allDone) { fDone = true;
fDone = true;
}
return nullptr; return nullptr;
} }

View File

@ -64,6 +64,6 @@ public:
}; };
inline bool operator==(const SkPDFCanon::BitmapGlyphKey& u, const SkPDFCanon::BitmapGlyphKey& v) { inline bool operator==(const SkPDFCanon::BitmapGlyphKey& u, const SkPDFCanon::BitmapGlyphKey& v) {
return memcmp(&u, &u, sizeof(SkPDFCanon::BitmapGlyphKey)) == 0; return memcmp(&u, &v, sizeof(SkPDFCanon::BitmapGlyphKey)) == 0;
} }
#endif // SkPDFCanon_DEFINED #endif // SkPDFCanon_DEFINED