From b470c2140c02a4c8df2fed02c325b5a6a77027be Mon Sep 17 00:00:00 2001 From: "commit-bot@chromium.org" Date: Wed, 19 Mar 2014 22:58:52 +0000 Subject: [PATCH] Silence warning after f5e315ccf1a. (clang 3.3): ../tools/PictureRenderer.cpp:350:13: error: variable 'hash' is used uninitialized whenever 'if' condition is false [-Werror,-Wsometimes-uninitialized] if (!generatedHash) { ^~~~~~~~~~~~~~ ../tools/PictureRenderer.cpp:354:53: note: uninitialized use occurs here jsonSummaryPtr->add(outputFilename.c_str(), hash); ^~~~ ../tools/PictureRenderer.cpp:350:9: note: remove the 'if' if its condition is always true if (!generatedHash) { ^~~~~~~~~~~~~~~~~~~~ ../tools/PictureRenderer.cpp:334:18: note: initialize the variable 'hash' to silence this warning uint64_t hash; ^ = 0 The warning is wrong, but the compiler does have a point: generatedHash is always false at that point. R=epoger@google.com Author: fmalita@chromium.org Review URL: https://codereview.chromium.org/196823004 git-svn-id: http://skia.googlecode.com/svn/trunk@13869 2bbb7eff-a529-9590-31e7-b0007b416f81 --- tools/PictureRenderer.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp index f62a05d..9cb43f7 100644 --- a/tools/PictureRenderer.cpp +++ b/tools/PictureRenderer.cpp @@ -347,10 +347,10 @@ static bool write(SkCanvas* canvas, const SkString& outputDir, const SkString& i // we could combine results of different config types without conflicting filenames. if (NULL != jsonSummaryPtr) { - if (!generatedHash) { - SkAssertResult(SkBitmapHasher::ComputeDigest(bitmap, &hash)); - generatedHash = true; - } + SkASSERT(!generatedHash); + SkAssertResult(SkBitmapHasher::ComputeDigest(bitmap, &hash)); + generatedHash = true; + jsonSummaryPtr->add(outputFilename.c_str(), hash); } -- 2.7.4