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@1386 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/ClockFaceView.cpp b/samplecode/ClockFaceView.cpp
index 6d4ef97..c829b69 100644
--- a/samplecode/ClockFaceView.cpp
+++ b/samplecode/ClockFaceView.cpp
@@ -17,7 +17,7 @@
     unsigned g = SkGetPackedG32(c);
     unsigned b = SkGetPackedB32(c);
 
-    unsigned x = r * 5 + g * 7 + b * 4 >> 4;
+    unsigned x = (r * 5 + g * 7 + b * 4) >> 4;
 
     return SkPackARGB32(0, x, x, x) | (c & (SK_A32_MASK << SK_A32_SHIFT));
 }
diff --git a/samplecode/SampleAARects.cpp b/samplecode/SampleAARects.cpp
index b42c1e9..34a33b0 100644
--- a/samplecode/SampleAARects.cpp
+++ b/samplecode/SampleAARects.cpp
@@ -70,7 +70,7 @@
         SkScalar dx = SkIntToScalar(80);
         SkScalar dy = SkIntToScalar(100);
         SkMatrix matrix;
-        for (int p = 0; p < SK_ARRAY_COUNT(paints); ++p) {
+        for (size_t p = 0; p < SK_ARRAY_COUNT(paints); ++p) {
             for (int stroke = 0; stroke < 2; ++stroke) {
                 paints[p].setStyle(stroke ? SkPaint::kStroke_Style : SkPaint::kFill_Style);
                 for (int a = 0; a < 3; ++ a) {
diff --git a/samplecode/SampleAll.cpp b/samplecode/SampleAll.cpp
index 75d1a31..abbf8f9 100644
--- a/samplecode/SampleAll.cpp
+++ b/samplecode/SampleAll.cpp
@@ -408,7 +408,7 @@
 			pos2[index].set(SkIntToScalar(index * 10), SkIntToScalar(20));
 		
         // shaders
-        SkPoint linearPoints[] = { 0, 0, SkIntToScalar(40), SkIntToScalar(40) };
+        SkPoint linearPoints[] = { { 0, 0, }, { SkIntToScalar(40), SkIntToScalar(40) } };
         SkColor linearColors[] = { SK_ColorRED, SK_ColorBLUE };
         SkScalar* linearPos = NULL;
         int linearCount = 2;
@@ -624,7 +624,7 @@
     }
     
     SkShader* shaderTest() {
-        SkPoint pts[] = {0, 0, SkIntToScalar(100), 0 };
+        SkPoint pts[] = { { 0, 0, }, { SkIntToScalar(100), 0 } };
         SkColor colors[] = { SK_ColorRED, SK_ColorBLUE };
         SkShader* shaderA = SkGradientShader::CreateLinear(pts, colors, NULL, 
             2, SkShader::kClamp_TileMode);
@@ -647,7 +647,7 @@
 	}
 
     void drawRaster(SkCanvas* canvas)  {
-        for (int index = 0; index < SK_ARRAY_COUNT(gRastProcs); index++)
+        for (size_t index = 0; index < SK_ARRAY_COUNT(gRastProcs); index++)
             drawOneRaster(canvas);
     }
     
@@ -665,7 +665,7 @@
 
         SkString str("GOOGLE");
 
-        for (int i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) {
+        for (size_t i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) {
             apply_shader(&paint, i);
             
           //  paint.setMaskFilter(NULL);
diff --git a/samplecode/SampleArc.cpp b/samplecode/SampleArc.cpp
index 504d8d8..8e3ad88 100644
--- a/samplecode/SampleArc.cpp
+++ b/samplecode/SampleArc.cpp
@@ -97,7 +97,7 @@
             225, 90
         };
         
-        for (int i = 0; i < SK_ARRAY_COUNT(gAngles); i += 2) {
+        for (size_t i = 0; i < SK_ARRAY_COUNT(gAngles); i += 2) {
             paint.setColor(SK_ColorBLACK);
             drawRectWithLines(canvas, r, paint);
 
diff --git a/samplecode/SampleAvoid.cpp b/samplecode/SampleAvoid.cpp
index 9536350..868a67c 100644
--- a/samplecode/SampleAvoid.cpp
+++ b/samplecode/SampleAvoid.cpp
@@ -23,7 +23,7 @@
                                                  SK_ARRAY_COUNT(colors),
                                                  SkShader::kMirror_TileMode);
 #else
-        SkPoint pts[] = { SkIntToScalar(W)/2, SkIntToScalar(H)/2 };
+        SkPoint pts[] = { { SkIntToScalar(W)/2, SkIntToScalar(H)/2 } };
         fShader = SkGradientShader::CreateRadial(pts[0], SkIntToScalar(H)/5,
                                                  colors, NULL,
                                                  SK_ARRAY_COUNT(colors),
diff --git a/samplecode/SampleBitmapRect.cpp b/samplecode/SampleBitmapRect.cpp
index 2d56db9..002b2b9 100644
--- a/samplecode/SampleBitmapRect.cpp
+++ b/samplecode/SampleBitmapRect.cpp
@@ -25,7 +25,7 @@
     canvas.drawColor(SK_ColorRED);
     SkPaint paint;
     paint.setAntiAlias(true);
-    const SkPoint pts[] = { 0, 0, 64, 64 };
+    const SkPoint pts[] = { { 0, 0 }, { 64, 64 } };
     const SkColor colors[] = { SK_ColorWHITE, SK_ColorBLUE };
     paint.setShader(SkGradientShader::CreateLinear(pts, colors, NULL, 2,
                                        SkShader::kClamp_TileMode))->unref();
diff --git a/samplecode/SampleComplexClip.cpp b/samplecode/SampleComplexClip.cpp
index 8ee078b..672d055 100644
--- a/samplecode/SampleComplexClip.cpp
+++ b/samplecode/SampleComplexClip.cpp
@@ -88,7 +88,7 @@
         canvas->save();
 
         for (int invA = 0; invA < 2; ++invA) {
-            for (int op = 0; op < SK_ARRAY_COUNT(gOps); ++op) {
+            for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); ++op) {
                 int idx = invA * SK_ARRAY_COUNT(gOps) + op;
                 if (!(idx % 3)) {
                     canvas->restore();
diff --git a/samplecode/SampleDitherBitmap.cpp b/samplecode/SampleDitherBitmap.cpp
index 91199c2..0d62446 100644
--- a/samplecode/SampleDitherBitmap.cpp
+++ b/samplecode/SampleDitherBitmap.cpp
@@ -16,7 +16,7 @@
 
 static void draw_gradient(SkCanvas* canvas) {
     SkRect r = { 0, 0, SkIntToScalar(256), SkIntToScalar(32) };
-    SkPoint pts[] = { r.fLeft, r.fTop, r.fRight, r.fTop };
+    SkPoint pts[] = { { r.fLeft, r.fTop }, { r.fRight, r.fTop } };
     SkColor colors[] = { 0xFF000000, 0xFFFF0000 };
     SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2,
                                                  SkShader::kClamp_TileMode);
diff --git a/samplecode/SampleDrawLooper.cpp b/samplecode/SampleDrawLooper.cpp
index abe2c70..30879f7 100644
--- a/samplecode/SampleDrawLooper.cpp
+++ b/samplecode/SampleDrawLooper.cpp
@@ -35,7 +35,7 @@
         info.fPaintBits = SkLayerDrawLooper::kStyle_Bit | SkLayerDrawLooper::kMaskFilter_Bit;
         info.fColorMode = SkXfermode::kSrc_Mode;
         
-        for (int i = 0; i < SK_ARRAY_COUNT(gParams); i++) {
+        for (size_t i = 0; i < SK_ARRAY_COUNT(gParams); i++) {
             info.fOffset.set(gParams[i].fOffset, gParams[i].fOffset);
             SkPaint* paint = fLooper->addLayer(info);
             paint->setAntiAlias(true);
diff --git a/samplecode/SampleEffects.cpp b/samplecode/SampleEffects.cpp
index 158a89f..a63c08d 100644
--- a/samplecode/SampleEffects.cpp
+++ b/samplecode/SampleEffects.cpp
@@ -44,7 +44,7 @@
 
 static void paint_proc3(SkPaint* paint) {
     SkColor colors[] = { SK_ColorRED, COLOR, SK_ColorBLUE };
-    SkPoint pts[] = { 3, 0, 7, 5 };
+    SkPoint pts[] = { { 3, 0 }, { 7, 5 } };
     paint->setShader(SkGradientShader::CreateLinear(pts, colors, NULL, SK_ARRAY_COUNT(colors),
                                         SkShader::kMirror_TileMode))->unref();
 }
diff --git a/samplecode/SampleLayers.cpp b/samplecode/SampleLayers.cpp
index f1e8dd8..6fc9c83 100644
--- a/samplecode/SampleLayers.cpp
+++ b/samplecode/SampleLayers.cpp
@@ -22,7 +22,7 @@
 
 static void make_paint(SkPaint* paint) {
     SkColor colors[] = { 0, SK_ColorWHITE };
-    SkPoint pts[] = { 0, 0, 0, SK_Scalar1*20 };
+    SkPoint pts[] = { { 0, 0 }, { 0, SK_Scalar1*20 } };
     SkShader* s = SkGradientShader::CreateLinear(pts, colors, NULL, 2, SkShader::kClamp_TileMode);
     
     paint->setShader(s)->unref();
diff --git a/samplecode/SampleLineClipper.cpp b/samplecode/SampleLineClipper.cpp
index 2635a30..d0a8667 100644
--- a/samplecode/SampleLineClipper.cpp
+++ b/samplecode/SampleLineClipper.cpp
@@ -155,7 +155,7 @@
     SkPoint     fPts[4];
 
     void randPts() {
-        for (int i = 0; i < SK_ARRAY_COUNT(fPts); i++) {
+        for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); i++) {
             fPts[i].set(fRand.nextUScalar1() * 640,
                         fRand.nextUScalar1() * 480);
         }
diff --git a/samplecode/SampleMeasure.cpp b/samplecode/SampleMeasure.cpp
index 70b8812..eb7a288 100644
--- a/samplecode/SampleMeasure.cpp
+++ b/samplecode/SampleMeasure.cpp
@@ -46,7 +46,7 @@
     SkRect      bounds;
 
     SkPaint p(paint);
-    for (int i = 0; i < SK_ARRAY_COUNT(gSettings); i++) {
+    for (size_t i = 0; i < SK_ARRAY_COUNT(gSettings); i++) {
         p.setLinearText(gSettings[i].fLinearText);
         p.setDevKernText(gSettings[i].fDevKernText);
         SkScalar scale = gSettings[i].fScale;
diff --git a/samplecode/SamplePatch.cpp b/samplecode/SamplePatch.cpp
index 0bfaa5a..ea365c7 100644
--- a/samplecode/SamplePatch.cpp
+++ b/samplecode/SamplePatch.cpp
@@ -42,7 +42,8 @@
 }
 
 static SkShader* make_shader1(const SkIPoint& size) {
-    SkPoint pts[] = { 0, 0, SkIntToScalar(size.fX), SkIntToScalar(size.fY) };
+    SkPoint pts[] = { { 0, 0, },
+                      { SkIntToScalar(size.fX), SkIntToScalar(size.fY) } };
     SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED };
     return SkGradientShader::CreateLinear(pts, colors, NULL,
                     SK_ARRAY_COUNT(colors), SkShader::kMirror_TileMode, NULL);
@@ -316,7 +317,7 @@
     }
 
     virtual SkView::Click* onFindClickHandler(SkScalar x, SkScalar y) {
-        for (int i = 0; i < SK_ARRAY_COUNT(fPts); i++) {
+        for (size_t i = 0; i < SK_ARRAY_COUNT(fPts); i++) {
             if (hittest(fPts[i], x, y)) {
                 return new PtClick(this, i);
             }
diff --git a/samplecode/SamplePath.cpp b/samplecode/SamplePath.cpp
index 4fef377..cd45ed9 100644
--- a/samplecode/SamplePath.cpp
+++ b/samplecode/SamplePath.cpp
@@ -168,9 +168,9 @@
             SkPaint::kRound_Join
         };
 
-        for (int i = 0; i < SK_ARRAY_COUNT(gJoins); i++) {
+        for (size_t i = 0; i < SK_ARRAY_COUNT(gJoins); i++) {
             canvas->save();
-            for (int j = 0; j < SK_ARRAY_COUNT(fPath); j++) {
+            for (size_t j = 0; j < SK_ARRAY_COUNT(fPath); j++) {
                 this->drawPath(canvas, fPath[j], gJoins[i]);
                 canvas->translate(SkIntToScalar(200), 0);
             }
diff --git a/samplecode/SamplePolyToPoly.cpp b/samplecode/SamplePolyToPoly.cpp
index 29a47f7..aea0cb4 100644
--- a/samplecode/SamplePolyToPoly.cpp
+++ b/samplecode/SamplePolyToPoly.cpp
@@ -13,8 +13,12 @@
 	PolyToPolyView() {
         // tests
         {
-            SkPoint src[] = { 0, 0, SK_Scalar1, 0, 0, SK_Scalar1 };
-            SkPoint dst[] = { 0, 0, 2*SK_Scalar1, 0, 0, 2*SK_Scalar1 };
+            SkPoint src[] = { { 0, 0 },
+                              { SK_Scalar1, 0 },
+                              { 0, SK_Scalar1 } };
+            SkPoint dst[] = { { 0, 0 },
+                              { 2*SK_Scalar1, 0 },
+                              { 0, 2*SK_Scalar1 } };
             SkMatrix m1, m2;
             bool success;
 
@@ -42,14 +46,14 @@
 
             {
                 const SkPoint src[] = {
-                    SkIntToScalar(1), SkIntToScalar(0),
-                    SkIntToScalar(4), SkIntToScalar(7),
-                    SkIntToScalar(10), SkIntToScalar(2)
+                    { SkIntToScalar(1), SkIntToScalar(0) },
+                    { SkIntToScalar(4), SkIntToScalar(7) },
+                    { SkIntToScalar(10), SkIntToScalar(2) }
                 };
                 const SkPoint dst[] = {
-                    SkIntToScalar(4), SkIntToScalar(2),
-                    SkIntToScalar(45), SkIntToScalar(26),
-                    SkIntToScalar(32), SkIntToScalar(17)
+                    { SkIntToScalar(4), SkIntToScalar(2) },
+                    { SkIntToScalar(45), SkIntToScalar(26) },
+                    { SkIntToScalar(32), SkIntToScalar(17) }
                 };
 
                 SkMatrix m0, m1;
diff --git a/samplecode/SampleRegion.cpp b/samplecode/SampleRegion.cpp
index 272c722..822bd6f 100644
--- a/samplecode/SampleRegion.cpp
+++ b/samplecode/SampleRegion.cpp
@@ -235,7 +235,7 @@
         
         canvas->translate(0, SkIntToScalar(200));
 
-        for (int op = 0; op < SK_ARRAY_COUNT(gOps); op++) {
+        for (size_t op = 0; op < SK_ARRAY_COUNT(gOps); op++) {
             canvas->drawText(gOps[op].fName, strlen(gOps[op].fName), SkIntToScalar(75), SkIntToScalar(50), textPaint);
 
             this->drawRgnOped(canvas, gOps[op].fOp, gOps[op].fColor);
diff --git a/samplecode/SampleShaderText.cpp b/samplecode/SampleShaderText.cpp
index 790137c..2748b55 100644
--- a/samplecode/SampleShaderText.cpp
+++ b/samplecode/SampleShaderText.cpp
@@ -11,7 +11,7 @@
 
     SkCanvas    canvas(*bm);
     SkScalar s = SkIntToScalar(w < h ? w : h);
-    SkPoint     pts[] = { 0, 0, s, s };
+    SkPoint     pts[] = { { 0, 0 }, { s, s } };
     SkColor     colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
     SkScalar    pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
     SkPaint     paint;
diff --git a/samplecode/SampleSlides.cpp b/samplecode/SampleSlides.cpp
index f57cb5a..3d2a61e 100644
--- a/samplecode/SampleSlides.cpp
+++ b/samplecode/SampleSlides.cpp
@@ -324,7 +324,8 @@
 }
 
 static SkShader* make_shader1(const SkIPoint& size) {
-    SkPoint pts[] = { 0, 0, SkIntToScalar(size.fX), SkIntToScalar(size.fY) };
+    SkPoint pts[] = { { 0, 0 },
+                      { SkIntToScalar(size.fX), SkIntToScalar(size.fY) } };
     SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED };
     return SkGradientShader::CreateLinear(pts, colors, NULL,
                                           SK_ARRAY_COUNT(colors), SkShader::kMirror_TileMode, NULL);
@@ -439,7 +440,7 @@
     paint.setDither(true);
     paint.setFilterBitmap(true);
     
-    for (int i = 0; i < SK_ARRAY_COUNT(fRecs); i++) {
+    for (size_t i = 0; i < SK_ARRAY_COUNT(fRecs); i++) {
         canvas->save();
         
         paint.setShader(NULL);
@@ -725,7 +726,7 @@
     paint.setTextSize(75);
     paint.setAntiAlias(true);
     paint.setColor(SK_ColorBLUE);
-    for (int i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) {
+    for (size_t i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) {
         apply_shader(&paint, i);
         canvas->drawText(str, len, x, y, paint);
         y += 80;
diff --git a/samplecode/SampleText.cpp b/samplecode/SampleText.cpp
index a2d6dd2..2676530 100644
--- a/samplecode/SampleText.cpp
+++ b/samplecode/SampleText.cpp
@@ -112,7 +112,7 @@
         mm = m;
     }
 
-    SkDEBUGCODE(int length2 =) paint.breakText(text, length, width, &mm);
+    SkDEBUGCODE(size_t length2 =) paint.breakText(text, length, width, &mm);
     SkASSERT(length2 == length);
     SkASSERT(mm == width);
 }
diff --git a/samplecode/SampleTextEffects.cpp b/samplecode/SampleTextEffects.cpp
index 733dd31..f256b2e 100644
--- a/samplecode/SampleTextEffects.cpp
+++ b/samplecode/SampleTextEffects.cpp
@@ -354,7 +354,7 @@
 
         paint.setTypeface(fFace);
 
-        for (int i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) {
+        for (size_t i = 0; i < SK_ARRAY_COUNT(gRastProcs); i++) {
             apply_shader(&paint, i);
 
           //  paint.setMaskFilter(NULL);
diff --git a/samplecode/SampleTiling.cpp b/samplecode/SampleTiling.cpp
index b3c73d7..4752ed1 100644
--- a/samplecode/SampleTiling.cpp
+++ b/samplecode/SampleTiling.cpp
@@ -22,7 +22,7 @@
     bm->eraseColor(0);
     
     SkCanvas    canvas(*bm);
-    SkPoint     pts[] = { 0, 0, SkIntToScalar(w), SkIntToScalar(h) };
+    SkPoint     pts[] = { { 0, 0 }, { SkIntToScalar(w), SkIntToScalar(h) } };
     SkColor     colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE };
     SkScalar    pos[] = { 0, SK_Scalar1/2, SK_Scalar1 };
     SkPaint     paint;
@@ -62,7 +62,7 @@
 	TilingView()
             : fLooper(SkIntToScalar(1), SkIntToScalar(2), SkIntToScalar(2),
                       0x88000000) {
-        for (int i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) {
+        for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) {
             makebm(&fTexture[i], gConfigs[i], gWidth, gHeight);
         }
     }
@@ -99,8 +99,8 @@
         }
 
         if (textCanvas) {
-            for (int kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
-                for (int ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
+            for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
+                for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
                     SkPaint p;
                     SkString str;
                     p.setAntiAlias(true);
@@ -118,11 +118,11 @@
         
         y += SkIntToScalar(16);
 
-        for (int i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) {
-            for (int j = 0; j < SK_ARRAY_COUNT(gFilters); j++) {
+        for (size_t i = 0; i < SK_ARRAY_COUNT(gConfigs); i++) {
+            for (size_t j = 0; j < SK_ARRAY_COUNT(gFilters); j++) {
                 x = SkIntToScalar(10);
-                for (int kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
-                    for (int ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
+                for (size_t kx = 0; kx < SK_ARRAY_COUNT(gModes); kx++) {
+                    for (size_t ky = 0; ky < SK_ARRAY_COUNT(gModes); ky++) {
                         SkPaint paint;
                         setup(&paint, fTexture[i], gFilters[j], gModes[kx], gModes[ky]);
                         paint.setDither(true);
diff --git a/samplecode/SampleVertices.cpp b/samplecode/SampleVertices.cpp
index 4557cc4..74e757f 100644
--- a/samplecode/SampleVertices.cpp
+++ b/samplecode/SampleVertices.cpp
@@ -38,7 +38,8 @@
 }
 
 static SkShader* make_shader1(const SkIPoint& size) {
-    SkPoint pts[] = { 0, 0, SkIntToScalar(size.fX), SkIntToScalar(size.fY) };
+    SkPoint pts[] = { { 0, 0 },
+                      { SkIntToScalar(size.fX), SkIntToScalar(size.fY) } };
     SkColor colors[] = { SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorRED };
     return SkGradientShader::CreateLinear(pts, colors, NULL,
                     SK_ARRAY_COUNT(colors), SkShader::kMirror_TileMode, NULL);
@@ -88,7 +89,7 @@
         paint.setDither(true);
         paint.setFilterBitmap(true);
 
-        for (int i = 0; i < SK_ARRAY_COUNT(fRecs); i++) {
+        for (size_t i = 0; i < SK_ARRAY_COUNT(fRecs); i++) {
             canvas->save();
 
             paint.setShader(NULL);