diff options
author | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-05-19 19:58:58 +0000 |
---|---|---|
committer | senorblanco@chromium.org <senorblanco@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2011-05-19 19:58:58 +0000 |
commit | ea50a0403048cfc1bdf789820449a819d37fea38 (patch) | |
tree | 7e3117f7a5a7f25e3a6ec4374489f98f368a27a5 | |
parent | e847e2062ff048692bed5e57da3168ed42af706c (diff) | |
download | src-ea50a0403048cfc1bdf789820449a819d37fea38.tar.gz |
The plain Makefile was using -Wall, but the gyp build wasn't. This CL turns on
-Wall -Wextra and -Wno-unused in common.gypi. This revealed a lot of warnings
(and some actual bugs), all of which I fixed here. This is pretty mindless
stuff for the most part (order of intialization, missing initializers, && within
||, etc), but will allow us to build cleanly with -Wall and -Wextra (and
-Werror, if we so choose).
I put defaults into switches that were missing cases. I could put in the actual
missing enums instead if that's desired. I could also assert on missing enums
instead of break, if that's desired. I wasn't sure how to test the stuff in
"animator", so that should be looked at a bit more closely.
Review URL: http://codereview.appspot.com/4547055/
git-svn-id: http://skia.googlecode.com/svn/trunk/src@1386 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | animator/SkDisplayApply.cpp | 8 | ||||
-rw-r--r-- | animator/SkDisplayXMLParser.cpp | 4 | ||||
-rw-r--r-- | animator/SkDump.cpp | 2 | ||||
-rw-r--r-- | animator/SkScript.cpp | 4 | ||||
-rw-r--r-- | animator/SkScriptDecompile.cpp | 10 | ||||
-rw-r--r-- | animator/SkScriptRuntime.cpp | 2 | ||||
-rw-r--r-- | animator/SkScriptTokenizer.cpp | 85 | ||||
-rw-r--r-- | svg/SkSVGParser.cpp | 6 | ||||
-rw-r--r-- | utils/unix/SkOSWindow_Unix.cpp | 2 | ||||
-rw-r--r-- | views/SkBorderView.cpp | 6 | ||||
-rw-r--r-- | views/SkView.cpp | 2 | ||||
-rw-r--r-- | views/SkWidgetViews.cpp | 4 |
12 files changed, 71 insertions, 64 deletions
diff --git a/animator/SkDisplayApply.cpp b/animator/SkDisplayApply.cpp index b9e65f74..8aca71f2 100644 --- a/animator/SkDisplayApply.cpp +++ b/animator/SkDisplayApply.cpp @@ -294,7 +294,7 @@ bool SkApply::enable(SkAnimateMaker& maker) { if ((mode == kMode_immediate || mode == kMode_create) && scope == NULL) return false; // !!! error? bool enableMe = scope && (scope->hasEnable() || scope->isApply() || scope->isDrawable() == false); - if (mode == kMode_immediate && enableMe || mode == kMode_create) + if ((mode == kMode_immediate && enableMe) || mode == kMode_create) activate(maker); // for non-drawables like post, prime them here if (mode == kMode_immediate && enableMe) fActive->enable(); @@ -479,7 +479,7 @@ void SkApply::endSave(int index) { } else { SkScriptValue scriptValue; bool success = target->getProperty(info->propertyIndex(), &scriptValue); - SkASSERT(success = true); + SkASSERT(success == true); last[0] = scriptValue.fOperand; scriptValue.fOperand = fActive->fSaveRestore[activeIndex][0]; target->setProperty(info->propertyIndex(), scriptValue); @@ -624,8 +624,8 @@ bool SkApply::interpolate(SkAnimateMaker& maker, SkMSec rawTime) { SkInterpolatorBase::Result interpResult = fActive->fInterpolators[inner]->timeToValues( innerTime, values.get()); result |= (interpResult != SkInterpolatorBase::kFreezeEnd_Result); - if ((transition != SkApply::kTransition_reverse && interpResult == SkInterpolatorBase::kFreezeEnd_Result || - transition == SkApply::kTransition_reverse && fLastTime == 0) && state.fUnpostedEndEvent) { + if (((transition != SkApply::kTransition_reverse && interpResult == SkInterpolatorBase::kFreezeEnd_Result) || + (transition == SkApply::kTransition_reverse && fLastTime == 0)) && state.fUnpostedEndEvent) { // SkDEBUGF(("interpolate: post on end\n")); state.fUnpostedEndEvent = false; maker.postOnEnd(animate, state.fBegin + state.fDuration); diff --git a/animator/SkDisplayXMLParser.cpp b/animator/SkDisplayXMLParser.cpp index a94b8480..db6c8384 100644 --- a/animator/SkDisplayXMLParser.cpp +++ b/animator/SkDisplayXMLParser.cpp @@ -304,8 +304,8 @@ const SkMemberInfo* SkDisplayXMLParser::searchContainer(const SkMemberInfo* info } return info; next: - if (type == SkType_Drawable || type == SkType_Displayable && - container->fDisplayable->isDrawable()) { + if (type == SkType_Drawable || (type == SkType_Displayable && + container->fDisplayable->isDrawable())) { rectNext: if (fParents.count() > 1) { Parent* parent = fParents.end() - 2; diff --git a/animator/SkDump.cpp b/animator/SkDump.cpp index eac956c1..426a1e64 100644 --- a/animator/SkDump.cpp +++ b/animator/SkDump.cpp @@ -58,7 +58,7 @@ bool SkDump::enable(SkAnimateMaker& maker ) { maker.fEvents.dump(maker); if ((hasAttr |= (name.size() > 0)) == true) maker.dump(name.c_str()); - if (displayList > 0 || displayList != 0 && hasAttr == false) + if (displayList > 0 || (displayList != 0 && hasAttr == false)) maker.fDisplayList.dump(&maker); return true; } diff --git a/animator/SkScript.cpp b/animator/SkScript.cpp index f81147d4..efb89a58 100644 --- a/animator/SkScript.cpp +++ b/animator/SkScript.cpp @@ -305,8 +305,8 @@ twoChar: } while (true); signed char topPrecedence = gPrecedence[compare]; SkASSERT(topPrecedence != -1); - if (topPrecedence > precedence || topPrecedence == precedence && - gOpAttributes[op].fLeftType == kNoType) { + if (topPrecedence > precedence || (topPrecedence == precedence && + gOpAttributes[op].fLeftType == kNoType)) { break; } if (processOp() == false) diff --git a/animator/SkScriptDecompile.cpp b/animator/SkScriptDecompile.cpp index d582d335..98db1fb3 100644 --- a/animator/SkScriptDecompile.cpp +++ b/animator/SkScriptDecompile.cpp @@ -114,7 +114,7 @@ static size_t gOperandNamesSize = sizeof(gOperandNames) / sizeof(gOperandNames[0 // check to see that there are no missing or duplicate entries void SkScriptEngine2::ValidateDecompileTable() { SkScriptEngine2::TypeOp op = SkScriptEngine2::kNop; - int index; + size_t index; for (index = 0; index < gOpNamesSize; index++) { SkASSERT(gOpNames[index].fOp == op); op = (SkScriptEngine2::TypeOp) (op + 1); @@ -132,9 +132,9 @@ void SkScriptEngine2::decompile(const unsigned char* start, size_t length) { SkASSERT(length > 0); const unsigned char* opCode = start; do { - SkASSERT(opCode - start < length); + SkASSERT((size_t)(opCode - start) < length); SkScriptEngine2::TypeOp op = (SkScriptEngine2::TypeOp) *opCode++; - SkASSERT(op < gOpNamesSize); + SkASSERT((size_t)op < gOpNamesSize); SkDebugf("%d: %s", opCode - start - 1, gOpNames[op].fName); switch (op) { case SkScriptEngine2::kCallback: { @@ -184,7 +184,7 @@ void SkScriptEngine2::decompile(const unsigned char* start, size_t length) { SkOperand2::OpType type; memcpy(&type, opCode, sizeof(type)); opCode += sizeof(type); - int index = 0; + size_t index = 0; if (type == 0) SkDebugf(" type: %s", gOperandNames[index].fName); else { @@ -211,6 +211,8 @@ void SkScriptEngine2::decompile(const unsigned char* start, size_t length) { goto done; case SkScriptEngine2::kNop: SkASSERT(0); + default: + break; } SkDebugf("\n"); } while (true); diff --git a/animator/SkScriptRuntime.cpp b/animator/SkScriptRuntime.cpp index 6d8c208d..12841983 100644 --- a/animator/SkScriptRuntime.cpp +++ b/animator/SkScriptRuntime.cpp @@ -304,6 +304,8 @@ bool SkScriptRuntime::executeTokens(unsigned char* opCode) { goto done; case SkScriptEngine2::kNop: SkASSERT(0); + default: + break; } } while (true); done: diff --git a/animator/SkScriptTokenizer.cpp b/animator/SkScriptTokenizer.cpp index efd18729..edcc2af4 100644 --- a/animator/SkScriptTokenizer.cpp +++ b/animator/SkScriptTokenizer.cpp @@ -8,34 +8,34 @@ #include "SkOpArray.h" const SkScriptEngine2::OperatorAttributes SkScriptEngine2::gOpAttributes[] = { -{ SkOperand2::kNoType }, +{ SkOperand2::kNoType, SkOperand2::kNoType, kNoBias, kResultIsNotBoolean }, { SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar | SkOperand2::kString), - SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar | SkOperand2::kString), kTowardsString }, // kAdd -{ SkOperand2::kS32, SkOperand2::kS32, kNoBias }, // kBitAnd -{ SkOperand2::kNoType, SkOperand2::kS32, kNoBias }, // kBitNot -{ SkOperand2::kS32, SkOperand2::kS32, kNoBias }, // kBitOr + SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar | SkOperand2::kString), kTowardsString, kResultIsNotBoolean }, // kAdd +{ SkOperand2::kS32, SkOperand2::kS32, kNoBias, kResultIsNotBoolean }, // kBitAnd +{ SkOperand2::kNoType, SkOperand2::kS32, kNoBias, kResultIsNotBoolean }, // kBitNot +{ SkOperand2::kS32, SkOperand2::kS32, kNoBias, kResultIsNotBoolean }, // kBitOr { SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar), - SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar), kNoBias }, // kDivide + SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar), kNoBias, kResultIsNotBoolean }, // kDivide { SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar | SkOperand2::kString), SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar |SkOperand2:: kString), kTowardsNumber, kResultIsBoolean }, // kEqual -{ SkOperand2::kS32 }, // kFlipOps +{ SkOperand2::kS32, SkOperand2::kNoType, kNoBias, kResultIsNotBoolean }, // kFlipOps { SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar | SkOperand2::kString), SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar | SkOperand2::kString), kTowardsNumber, kResultIsBoolean }, // kGreaterEqual -{ SkOperand2::kNoType, SkOperand2::kS32, kNoBias }, // kLogicalAnd (really, ToBool) -{ SkOperand2::kNoType, SkOperand2::kS32, kNoBias }, // kLogicalNot -{ SkOperand2::kS32, SkOperand2::kS32, kNoBias }, // kLogicalOr -{ SkOperand2::kNoType, SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar), kNoBias }, // kMinus +{ SkOperand2::kNoType, SkOperand2::kS32, kNoBias, kResultIsNotBoolean }, // kLogicalAnd (really, ToBool) +{ SkOperand2::kNoType, SkOperand2::kS32, kNoBias, kResultIsNotBoolean }, // kLogicalNot +{ SkOperand2::kS32, SkOperand2::kS32, kNoBias, kResultIsNotBoolean }, // kLogicalOr +{ SkOperand2::kNoType, SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar), kNoBias, kResultIsNotBoolean }, // kMinus { SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar), - SkOperand2::OpType(SkOperand2::kS32 |SkOperand2:: kScalar), kNoBias }, // kModulo + SkOperand2::OpType(SkOperand2::kS32 |SkOperand2:: kScalar), kNoBias, kResultIsNotBoolean }, // kModulo { SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar), - SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar), kNoBias }, // kMultiply -{ SkOperand2::kS32, SkOperand2::kS32, kNoBias }, // kShiftLeft -{ SkOperand2::kS32, SkOperand2::kS32, kNoBias }, // kShiftRight + SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar), kNoBias, kResultIsNotBoolean }, // kMultiply +{ SkOperand2::kS32, SkOperand2::kS32, kNoBias, kResultIsNotBoolean }, // kShiftLeft +{ SkOperand2::kS32, SkOperand2::kS32, kNoBias, kResultIsNotBoolean }, // kShiftRight { SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar), - SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar), kNoBias }, // kSubtract -{ SkOperand2::kS32, SkOperand2::kS32, kNoBias } // kXor + SkOperand2::OpType(SkOperand2::kS32 | SkOperand2::kScalar), kNoBias, kResultIsNotBoolean }, // kSubtract +{ SkOperand2::kS32, SkOperand2::kS32, kNoBias, kResultIsNotBoolean } // kXor }; #define kBracketPrecedence 16 @@ -308,8 +308,8 @@ twoChar: } while (true); signed char topPrecedence = gPrecedence[compare]; SkASSERT(topPrecedence != -1); - if (topPrecedence > precedence || topPrecedence == precedence && - gOpAttributes[op].fLeftType == SkOperand2::kNoType) { + if (topPrecedence > precedence || (topPrecedence == precedence && + gOpAttributes[op].fLeftType == SkOperand2::kNoType)) { break; } processOp(); @@ -1051,7 +1051,8 @@ bool SkScriptEngine2::processOp() { fOpStack.pop(&op); op = (Op) (op & ~kArtificialOp); const OperatorAttributes* attributes = &gOpAttributes[op]; - SkScriptValue2 value1 = { 0 }; + SkScriptValue2 value1; + memset(&value1, 0, sizeof(SkScriptValue2)); SkScriptValue2 value2; fValueStack.pop(&value2); value2.fIsWritten = SkScriptValue2::kUnwritten; @@ -1230,7 +1231,7 @@ bool SkScriptEngine2::ConvertTo(SkScriptEngine2* engine, SkOperand2::OpType toTy SkScalar SkScriptEngine2::IntToScalar(int32_t s32) { SkScalar scalar; - if (s32 == SK_NaN32) + if (s32 == (int32_t) SK_NaN32) scalar = SK_ScalarNaN; else if (SkAbs32(s32) == SK_MaxS32) scalar = SkSign32(s32) * SK_ScalarMax; @@ -1261,21 +1262,21 @@ bool SkScriptEngine2::ValueToString(const SkScriptValue2& value, SkString* strin #ifdef SK_DEBUG -#define testInt(expression) { #expression, SkOperand2::kS32, expression } +#define testInt(expression) { #expression, SkOperand2::kS32, expression, 0, NULL } #ifdef SK_SCALAR_IS_FLOAT -#define testScalar(expression) { #expression, SkOperand2::kScalar, 0, (float) expression } -#define testRemainder(exp1, exp2) { #exp1 "%" #exp2, SkOperand2::kScalar, 0, fmodf(exp1, exp2) } +#define testScalar(expression) { #expression, SkOperand2::kScalar, 0, (float) expression, NULL } +#define testRemainder(exp1, exp2) { #exp1 "%" #exp2, SkOperand2::kScalar, 0, fmodf(exp1, exp2), NULL } #else #ifdef SK_CAN_USE_FLOAT -#define testScalar(expression) { #expression, SkOperand2::kScalar, 0, (int) ((expression) * 65536.0f) } -#define testRemainder(exp1, exp2) { #exp1 "%" #exp2, SkOperand2::kScalar, 0, (int) (fmod(exp1, exp2) * 65536.0f) } +#define testScalar(expression) { #expression, SkOperand2::kScalar, 0, (int) ((expression) * 65536.0f), NULL } +#define testRemainder(exp1, exp2) { #exp1 "%" #exp2, SkOperand2::kScalar, 0, (int) (fmod(exp1, exp2) * 65536.0f), NULL } #endif #endif -#define testTrue(expression) { #expression, SkOperand2::kS32, 1 } -#define testFalse(expression) { #expression, SkOperand2::kS32, 0 } +#define testTrue(expression) { #expression, SkOperand2::kS32, 1, 0, NULL } +#define testFalse(expression) { #expression, SkOperand2::kS32, 0, 0, NULL } static const SkScriptNAnswer2 scriptTests[] = { - testInt(1||0&&3), + testInt(1||(0&&3)), #ifdef SK_CAN_USE_FLOAT testScalar(- -5.5- -1.5), testScalar(1.0+5), @@ -1307,12 +1308,12 @@ static const SkScriptNAnswer2 scriptTests[] = { { "'123'+\"456\"", SkOperand2::kString, 0, 0, "123456" }, { "123+\"456\"", SkOperand2::kString, 0, 0, "123456" }, { "'123'+456", SkOperand2::kString, 0, 0, "123456" }, - { "'123'|\"456\"", SkOperand2::kS32, 123|456 }, - { "123|\"456\"", SkOperand2::kS32, 123|456 }, - { "'123'|456", SkOperand2::kS32, 123|456 }, - { "'2'<11", SkOperand2::kS32, 1 }, - { "2<'11'", SkOperand2::kS32, 1 }, - { "'2'<'11'", SkOperand2::kS32, 0 }, + { "'123'|\"456\"", SkOperand2::kS32, 123|456, 0, NULL }, + { "123|\"456\"", SkOperand2::kS32, 123|456, 0, NULL }, + { "'123'|456", SkOperand2::kS32, 123|456, 0, NULL }, + { "'2'<11", SkOperand2::kS32, 1, 0, NULL }, + { "2<'11'", SkOperand2::kS32, 1, 0, NULL }, + { "'2'<'11'", SkOperand2::kS32, 0, 0, NULL }, testInt(123), testInt(-345), testInt(+678), @@ -1461,15 +1462,15 @@ static const SkScriptNAnswer2 scriptTests[] = { // logic testInt(1?2:3), testInt(0?2:3), - testInt(1&&2||3), - testInt(1&&0||3), - testInt(1&&0||0), - testInt(1||0&&3), - testInt(0||0&&3), - testInt(0||1&&3), + testInt((1&&2)||3), + testInt((1&&0)||3), + testInt((1&&0)||0), + testInt(1||(0&&3)), + testInt(0||(0&&3)), + testInt(0||(1&&3)), testInt(0&&1?2:3) #ifdef SK_CAN_USE_FLOAT - , { "123.5", SkOperand2::kScalar, 0, SkIntToScalar(123) + SK_Scalar1/2 } + , { "123.5", SkOperand2::kScalar, 0, SkIntToScalar(123) + SK_Scalar1/2, NULL } #endif }; diff --git a/svg/SkSVGParser.cpp b/svg/SkSVGParser.cpp index df861780..f4ad1987 100644 --- a/svg/SkSVGParser.cpp +++ b/svg/SkSVGParser.cpp @@ -76,8 +76,8 @@ void SkSVGParser::Delete(SkTDArray<SkSVGElement*>& fChildren) { int SkSVGParser::findAttribute(SkSVGBase* element, const char* attrValue, size_t len, bool isPaint) { const SkSVGAttribute* attributes; - int count = element->getAttributes(&attributes); - int result = 0; + size_t count = element->getAttributes(&attributes); + size_t result = 0; while (result < count) { if (strncmp(attributes->fName, attrValue, len) == 0 && strlen(attributes->fName) == len) { SkASSERT(result == (attributes->fOffset - @@ -200,7 +200,7 @@ bool SkSVGParser::onStartElementLen(const char name[], size_t len) { } else if (fInSVG == false) return false; const char* nextColon = strchr(name, ':'); - if (nextColon && nextColon - name < len) + if (nextColon && (size_t)(nextColon - name) < len) return false; SkSVGTypes type = GetType(name, len); // SkASSERT(type >= 0); diff --git a/utils/unix/SkOSWindow_Unix.cpp b/utils/unix/SkOSWindow_Unix.cpp index 4ec0c743..ae881d51 100644 --- a/utils/unix/SkOSWindow_Unix.cpp +++ b/utils/unix/SkOSWindow_Unix.cpp @@ -76,7 +76,7 @@ void SkOSWindow::post_linuxevent() long event_mask = NoEventMask; XClientMessageEvent event; event.type = ClientMessage; - Atom myAtom; + Atom myAtom(0); event.message_type = myAtom; event.format = 32; event.data.l[0] = 0; diff --git a/views/SkBorderView.cpp b/views/SkBorderView.cpp index 3a9c4492..74a24775 100644 --- a/views/SkBorderView.cpp +++ b/views/SkBorderView.cpp @@ -5,8 +5,10 @@ #include "SkTime.h" #include "SkStackViewLayout.h" -SkBorderView::SkBorderView() : fTop(SkIntToScalar(0)), fLeft(SkIntToScalar(0)), - fRight(SkIntToScalar(0)), fBottom(SkIntToScalar(0)) +SkBorderView::SkBorderView() : fLeft(SkIntToScalar(0)), + fRight(SkIntToScalar(0)), + fTop(SkIntToScalar(0)), + fBottom(SkIntToScalar(0)) { fAnim.setHostEventSink(this); init_skin_anim(kBorder_SkinEnum, &fAnim); diff --git a/views/SkView.cpp b/views/SkView.cpp index 7969d3d2..1cd63394 100644 --- a/views/SkView.cpp +++ b/views/SkView.cpp @@ -552,7 +552,7 @@ SkView* SkView::attachChildToFront(SkView* child) { SkASSERT(child != this); - if (child == NULL || fFirstChild && fFirstChild->fPrevSibling == child) + if (child == NULL || (fFirstChild && fFirstChild->fPrevSibling == child)) goto DONE; child->ref(); diff --git a/views/SkWidgetViews.cpp b/views/SkWidgetViews.cpp index 109e6206..27053074 100644 --- a/views/SkWidgetViews.cpp +++ b/views/SkWidgetViews.cpp @@ -117,7 +117,7 @@ void SkWidgetView::setLabel(const char label[]) void SkWidgetView::setLabel(const char label[], size_t len) { - if (label == NULL && fLabel.size() != 0 || !fLabel.equals(label, len)) + if ((label == NULL && fLabel.size() != 0) || !fLabel.equals(label, len)) { SkString tmp(label, len); @@ -368,7 +368,7 @@ SkView* SkWidgetFactory(const char name[]) }; - for (int i = 0; i < SK_ARRAY_COUNT(gNames); i++) + for (size_t i = 0; i < SK_ARRAY_COUNT(gNames); i++) if (!strcmp(gNames[i], name)) return SkWidgetFactory((SkWidgetEnum)i); |