From 71d7f7f002332b9904bf12eb3f1908883f99120e Mon Sep 17 00:00:00 2001 From: brucedawson Date: Thu, 26 Feb 2015 13:28:53 -0800 Subject: [PATCH] Initialize three locals to avoid the risk of uninitialized reads. /analyze recently reported two new warnings about reading from potentially uninitialized local variables: src\third_party\skia\src\gpu\grclipmaskmanager.cpp(290) : warning C6001: Using uninitialized memory 'requiresAA'. src\third_party\skia\src\gpu\grclipmaskmanager.cpp(336) : warning C6001: Using uninitialized memory 'genID'. It is not clear whether the uninitialized reads can actually happen, but the guarantees seem sufficiently non-obvious that the prudent thing to do to guarantee future stability is to initialized them -- it's cheap. I also initialized initialState because it seemed to fall in the same class, despite there being no warning for it. BUG=427616 Review URL: https://codereview.chromium.org/957133002 --- src/gpu/GrClipMaskManager.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gpu/GrClipMaskManager.cpp b/src/gpu/GrClipMaskManager.cpp index 0084c2b..a39c4a3 100644 --- a/src/gpu/GrClipMaskManager.cpp +++ b/src/gpu/GrClipMaskManager.cpp @@ -218,10 +218,10 @@ bool GrClipMaskManager::setupClipping(GrPipelineBuilder* pipelineBuilder, } GrReducedClip::ElementList elements(16); - int32_t genID; - GrReducedClip::InitialState initialState; + int32_t genID = 0; + GrReducedClip::InitialState initialState = GrReducedClip::kAllIn_InitialState; SkIRect clipSpaceIBounds; - bool requiresAA; + bool requiresAA = false; GrRenderTarget* rt = pipelineBuilder->getRenderTarget(); // GrDrawTarget should have filtered this for us @@ -239,7 +239,6 @@ bool GrClipMaskManager::setupClipping(GrPipelineBuilder* pipelineBuilder, // we should have handled this case above SkASSERT(false); case GrClip::kIRect_ClipType: { - initialState = GrReducedClip::kAllIn_InitialState; clipSpaceIBounds = clip.irect(); SkNEW_INSERT_AT_LLIST_HEAD(&elements, Element, @@ -247,7 +246,6 @@ bool GrClipMaskManager::setupClipping(GrPipelineBuilder* pipelineBuilder, SkRegion::kIntersect_Op, false)); } break; case GrClip::kRect_ClipType: { - initialState = GrReducedClip::kAllIn_InitialState; clipSpaceIBounds.setLTRB(SkScalarCeilToInt(clip.rect().fLeft), SkScalarCeilToInt(clip.rect().fTop), SkScalarCeilToInt(clip.rect().fRight), -- 2.7.4