fix warnings on Mac in tests
Fix these class of warnings:
- unused functions
- unused locals
- sign mismatch
- missing function prototypes
- missing newline at end of file
- 64 to 32 bit truncation
The changes prefer to link in dead code in the debug build
with 'if (false)' than to comment it out, but trivial cases
are commented out or sometimes deleted if it appears to be
a copy/paste error.
Review URL: https://codereview.appspot.com/6301045
git-svn-id: http://skia.googlecode.com/svn/trunk@4175 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tests/BitmapCopyTest.cpp b/tests/BitmapCopyTest.cpp
index 27a145e..690497a 100644
--- a/tests/BitmapCopyTest.cpp
+++ b/tests/BitmapCopyTest.cpp
@@ -80,7 +80,7 @@
}
}
-SkColorTable* init_ctable() {
+static SkColorTable* init_ctable() {
static const SkColor colors[] = {
SK_ColorBLACK, SK_ColorRED, SK_ColorGREEN, SK_ColorBLUE, SK_ColorWHITE
};
@@ -102,7 +102,7 @@
// Utility function to read the value of a given pixel in bm. All
// values converted to uint32_t for simplification of comparisons.
-uint32_t getPixel(int x, int y, const SkBitmap& bm) {
+static uint32_t getPixel(int x, int y, const SkBitmap& bm) {
uint32_t val = 0;
uint16_t val16;
uint8_t val8, shift;
@@ -137,7 +137,7 @@
// Utility function to set value of any pixel in bm.
// bm.getConfig() specifies what format 'val' must be
// converted to, but at present uint32_t can handle all formats.
-void setPixel(int x, int y, uint32_t val, SkBitmap& bm) {
+static void setPixel(int x, int y, uint32_t val, SkBitmap& bm) {
uint16_t val16;
uint8_t val8, shift;
SkAutoLockPixels lock(bm);
@@ -174,7 +174,7 @@
// Utility to return string containing name of each format, to
// simplify diagnostic output.
-const char* getSkConfigName(const SkBitmap& bm) {
+static const char* getSkConfigName(const SkBitmap& bm) {
switch (bm.getConfig()) {
case SkBitmap::kNo_Config: return "SkBitmap::kNo_Config";
case SkBitmap::kA1_Config: return "SkBitmap::kA1_Config";
@@ -211,7 +211,7 @@
// A function to verify that two bitmaps contain the same pixel values
// at all coordinates indicated by coords. Simplifies verification of
// copied bitmaps.
-void reportCopyVerification(const SkBitmap& bm1, const SkBitmap& bm2,
+static void reportCopyVerification(const SkBitmap& bm1, const SkBitmap& bm2,
Coordinates& coords,
const char* msg,
skiatest::Reporter* reporter){
@@ -232,7 +232,7 @@
}
// Writes unique pixel values at locations specified by coords.
-void writeCoordPixels(SkBitmap& bm, const Coordinates& coords) {
+static void writeCoordPixels(SkBitmap& bm, const Coordinates& coords) {
for (int i = 0; i < coords.length; ++i)
setPixel(coords[i]->fX, coords[i]->fY, i, bm);
}
diff --git a/tests/CanvasTest.cpp b/tests/CanvasTest.cpp
index 899c34e..f35d05b 100644
--- a/tests/CanvasTest.cpp
+++ b/tests/CanvasTest.cpp
@@ -722,6 +722,7 @@
*/
}
+// unused
static void TestProxyCanvasStateConsistency(
skiatest::Reporter* reporter,
CanvasTestStep* testStep,
@@ -744,6 +745,7 @@
testStep);
}
+// unused
static void TestNWayCanvasStateConsistency(
skiatest::Reporter* reporter,
CanvasTestStep* testStep,
@@ -799,18 +801,26 @@
SkPicture::kFlattenMutableNonTexturePixelRefs_RecordingFlag);
TestDeferredCanvasStateConsistency(reporter, testStep, referenceCanvas);
- // The following test code is commented out because SkProxyCanvas is
+ // The following test code is disabled because SkProxyCanvas is
// missing a lot of virtual overrides on get* methods, which are used
// to verify canvas state.
// Issue: http://code.google.com/p/skia/issues/detail?id=500
-
- //TestProxyCanvasStateConsistency(reporter, testStep, referenceCanvas);
- // The following test code is commented out because SkNWayCanvas does not
+ if (false) { // avoid bit rot, suppress warning
+ TestProxyCanvasStateConsistency(reporter, testStep, referenceCanvas);
+ }
+
+ // The following test code is disabled because SkNWayCanvas does not
// report correct clipping and device bounds information
// Issue: http://code.google.com/p/skia/issues/detail?id=501
+
+ if (false) { // avoid bit rot, suppress warning
+ TestNWayCanvasStateConsistency(reporter, testStep, referenceCanvas);
+ }
- //TestNWayCanvasStateConsistency(reporter, testStep, referenceCanvas);
+ if (false) { // avoid bit rot, suppress warning
+ test_clipVisitor(reporter, &referenceCanvas);
+ }
}
static void TestCanvas(skiatest::Reporter* reporter) {
diff --git a/tests/ClipCacheTest.cpp b/tests/ClipCacheTest.cpp
index a0888d8..ae3337e 100644
--- a/tests/ClipCacheTest.cpp
+++ b/tests/ClipCacheTest.cpp
@@ -13,6 +13,7 @@
static const int Y_SIZE = 12;
////////////////////////////////////////////////////////////////////////////////
+// note: this is unused
static GrTexture* createTexture(GrContext* context) {
unsigned char textureData[X_SIZE][Y_SIZE][4];
@@ -59,6 +60,9 @@
// push, pop, set, canReuse & getters
static void test_cache(skiatest::Reporter* reporter, GrContext* context) {
+ if (false) { // avoid bit rot, suppress warning
+ createTexture(context);
+ }
GrClipMaskCache cache;
cache.setContext(context);
diff --git a/tests/ClipperTest.cpp b/tests/ClipperTest.cpp
index d739d31..724ff56 100644
--- a/tests/ClipperTest.cpp
+++ b/tests/ClipperTest.cpp
@@ -22,8 +22,8 @@
SkCanvas canvas(bm);
canvas.clipRect(SkRect::MakeWH(SkIntToScalar(4), SkIntToScalar(2)));
- canvas.drawLine(SkFloatToScalar(1.5), SkFloatToScalar(1.5),
- SkFloatToScalar(3.5), SkFloatToScalar(3.5), paint);
+ canvas.drawLine(SkFloatToScalar(1.5f), SkFloatToScalar(1.5f),
+ SkFloatToScalar(3.5f), SkFloatToScalar(3.5f), paint);
/**
* We had a bug where we misinterpreted the bottom of the clip, and
@@ -144,7 +144,7 @@
}
-void TestClipper(skiatest::Reporter* reporter) {
+static void TestClipper(skiatest::Reporter* reporter) {
test_intersectline(reporter);
test_edgeclipper(reporter);
test_hairclipping(reporter);
diff --git a/tests/DataRefTest.cpp b/tests/DataRefTest.cpp
index 6a42485..56c5d11 100644
--- a/tests/DataRefTest.cpp
+++ b/tests/DataRefTest.cpp
@@ -26,7 +26,7 @@
REPORTER_ASSERT(reporter, !memcmp(ref->data(), data, len));
}
-void TestDataRef(skiatest::Reporter* reporter) {
+static void TestDataRef(skiatest::Reporter* reporter) {
const char* str = "We the people, in order to form a more perfect union.";
const int N = 10;
diff --git a/tests/EmptyPathTest.cpp b/tests/EmptyPathTest.cpp
index b126076..4cff190 100644
--- a/tests/EmptyPathTest.cpp
+++ b/tests/EmptyPathTest.cpp
@@ -39,7 +39,7 @@
size_t count = DIMENSION * DIMENSION;
const SkPMColor* ptr = bm.getAddr32(0, 0);
- SkPMColor andValue = ~0;
+ SkPMColor andValue = ~0U;
SkPMColor orValue = 0;
for (size_t i = 0; i < count; ++i) {
SkPMColor c = ptr[i];
diff --git a/tests/FillPathTest.cpp b/tests/FillPathTest.cpp
index b14f5bc..22ceb19 100644
--- a/tests/FillPathTest.cpp
+++ b/tests/FillPathTest.cpp
@@ -38,9 +38,9 @@
int width = 200;
int expected_lines = 5;
clip.set(0, height - expected_lines, width, height);
- path.moveTo(0.0, 0.0);
+ path.moveTo(0.0f, 0.0f);
path.quadTo(SkIntToScalar(width/2), SkIntToScalar(height),
- SkIntToScalar(width), 0.0);
+ SkIntToScalar(width), 0.0f);
path.close();
path.setFillType(SkPath::kInverseWinding_FillType);
SkScan::FillPath(path, clip, &blitter);
diff --git a/tests/FontHostTest.cpp b/tests/FontHostTest.cpp
index 234d177..e35e73f 100644
--- a/tests/FontHostTest.cpp
+++ b/tests/FontHostTest.cpp
@@ -26,6 +26,9 @@
static void test_tables(skiatest::Reporter* reporter, SkTypeface* face) {
SkFontID fontID = face->uniqueID();
+ if (false) { // avoid bit rot, suppress warning
+ REPORTER_ASSERT(reporter, fontID);
+ }
int count = face->countTables();
diff --git a/tests/GeometryTest.cpp b/tests/GeometryTest.cpp
index 9a0f78f..12cc816 100644
--- a/tests/GeometryTest.cpp
+++ b/tests/GeometryTest.cpp
@@ -28,6 +28,9 @@
SkScalar tValues[3];
// make sure we don't assert internally
int count = SkChopCubicAtMaxCurvature(src, dst, tValues);
+ if (false) { // avoid bit rot, suppress warning
+ REPORTER_ASSERT(reporter, count);
+ }
}
diff --git a/tests/MathTest.cpp b/tests/MathTest.cpp
index a7ecfa1..3deb79a 100644
--- a/tests/MathTest.cpp
+++ b/tests/MathTest.cpp
@@ -73,9 +73,20 @@
return dst + ((src - dst) * a31 >> 5);
}
+// suppress unused code warning
+static int (*blend_functions[])(int, int, int) = {
+ blend31,
+ blend31_slow,
+ blend31_round,
+ blend31_old
+};
+
static void test_blend31() {
int failed = 0;
int death = 0;
+ if (false) { // avoid bit rot, suppress warning
+ failed = (*blend_functions[0])(0,0,0);
+ }
for (int src = 0; src <= 255; src++) {
for (int dst = 0; dst <= 255; dst++) {
for (int a = 0; a <= 31; a++) {
@@ -599,7 +610,7 @@
#endif
// disable for now
-// test_blend31();
+ if (false) test_blend31(); // avoid bit rot, suppress warning
}
#include "TestClassDef.h"
diff --git a/tests/Matrix44Test.cpp b/tests/Matrix44Test.cpp
index 9846e7d..9e589e6 100644
--- a/tests/Matrix44Test.cpp
+++ b/tests/Matrix44Test.cpp
@@ -76,7 +76,7 @@
}
}
-void TestMatrix44(skiatest::Reporter* reporter) {
+static void TestMatrix44(skiatest::Reporter* reporter) {
#ifdef SK_SCALAR_IS_FLOAT
SkMatrix44 mat, inverse, iden1, iden2, rot;
@@ -139,9 +139,9 @@
0, 0, 0, 1);
}
-#if 0 // working on making this pass
- test_common_angles(reporter);
-#endif
+ if (false) { // avoid bit rot, suppress warning (working on making this pass)
+ test_common_angles(reporter);
+ }
#endif
}
diff --git a/tests/MatrixTest.cpp b/tests/MatrixTest.cpp
index 6cf9006..979f6ce 100644
--- a/tests/MatrixTest.cpp
+++ b/tests/MatrixTest.cpp
@@ -100,7 +100,7 @@
REPORTER_ASSERT(reporter, memcmp(buffer, buffer2, size1) == 0);
}
-void test_matrix_max_stretch(skiatest::Reporter* reporter) {
+static void test_matrix_max_stretch(skiatest::Reporter* reporter) {
SkMatrix identity;
identity.reset();
REPORTER_ASSERT(reporter, SK_Scalar1 == identity.getMaxStretch());
@@ -218,7 +218,7 @@
SkScalarSquare(tol));
}
-void test_matrix_is_similarity_transform(skiatest::Reporter* reporter) {
+static void test_matrix_is_similarity_transform(skiatest::Reporter* reporter) {
SkMatrix mat;
// identity
@@ -347,7 +347,7 @@
REPORTER_ASSERT(reporter, isSimilarityTransformation(mat));
}
-void TestMatrix(skiatest::Reporter* reporter) {
+static void TestMatrix(skiatest::Reporter* reporter) {
SkMatrix mat, inverse, iden1, iden2;
mat.reset();
diff --git a/tests/PDFPrimitivesTest.cpp b/tests/PDFPrimitivesTest.cpp
index 000ebea..2423d56 100644
--- a/tests/PDFPrimitivesTest.cpp
+++ b/tests/PDFPrimitivesTest.cpp
@@ -240,7 +240,7 @@
SimpleCheckObjectOutput(reporter, realHalf.get(), "0.5");
#if defined(SK_SCALAR_IS_FLOAT)
- SkRefPtr<SkPDFScalar> bigScalar = new SkPDFScalar(110999.75);
+ SkRefPtr<SkPDFScalar> bigScalar = new SkPDFScalar(110999.75f);
bigScalar->unref(); // SkRefPtr and new both took a reference.
#if !defined(SK_ALLOW_LARGE_PDF_SCALARS)
SimpleCheckObjectOutput(reporter, bigScalar.get(), "111000");
diff --git a/tests/ParsePathTest.cpp b/tests/ParsePathTest.cpp
index 831cd8e..116dbd0 100644
--- a/tests/ParsePathTest.cpp
+++ b/tests/ParsePathTest.cpp
@@ -27,18 +27,18 @@
#endif
}
+static struct {
+ const char* fStr;
+ const SkRect fBounds;
+} gRec[] = {
+ { "", { 0, 0, 0, 0 } },
+ { "M0,0L10,10", { 0, 0, SkIntToScalar(10), SkIntToScalar(10) } },
+ { "M-5.5,-0.5 Q 0 0 6,6.50",
+ { SkFloatToScalar(-5.5f), SkFloatToScalar(-0.5f),
+ SkFloatToScalar(6), SkFloatToScalar(6.5f) } }
+};
+
static void TestParsePath(skiatest::Reporter* reporter) {
- static const struct {
- const char* fStr;
- SkRect fBounds;
- } gRec[] = {
- { "", { 0, 0, 0, 0 } },
- { "M0,0L10,10", { 0, 0, SkIntToScalar(10), SkIntToScalar(10) } },
- { "M-5.5,-0.5 Q 0 0 6,6.50",
- { SkFloatToScalar(-5.5f), SkFloatToScalar(-0.5f),
- SkFloatToScalar(6), SkFloatToScalar(6.5f) } }
- };
-
for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) {
SkPath path;
bool success = SkParsePath::FromSVGString(gRec[i].fStr, &path);
@@ -51,13 +51,13 @@
}
SkRect r;
- r.set(0, 0, SkFloatToScalar(10), SkFloatToScalar(10.5));
+ r.set(0, 0, SkFloatToScalar(10), SkFloatToScalar(10.5f));
SkPath p;
p.addRect(r);
test_to_from(reporter, p);
p.addOval(r);
test_to_from(reporter, p);
- p.addRoundRect(r, SkFloatToScalar(4), SkFloatToScalar(4.5));
+ p.addRoundRect(r, SkFloatToScalar(4), SkFloatToScalar(4.5f));
test_to_from(reporter, p);
}
diff --git a/tests/PathCoverageTest.cpp b/tests/PathCoverageTest.cpp
index 4f2f1be..9734f75 100644
--- a/tests/PathCoverageTest.cpp
+++ b/tests/PathCoverageTest.cpp
@@ -66,22 +66,22 @@
}
}
-uint32_t quadraticPointCount_EE(const SkPoint points[], SkScalar tol) {
+static uint32_t quadraticPointCount_EE(const SkPoint points[], SkScalar tol) {
int distance = estimate_distance(points);
return estimate_pointCount(distance);
}
-uint32_t quadraticPointCount_EC(const SkPoint points[], SkScalar tol) {
+static uint32_t quadraticPointCount_EC(const SkPoint points[], SkScalar tol) {
int distance = estimate_distance(points);
return compute_pointCount(SkIntToScalar(distance), tol);
}
-uint32_t quadraticPointCount_CE(const SkPoint points[], SkScalar tol) {
+static uint32_t quadraticPointCount_CE(const SkPoint points[], SkScalar tol) {
SkScalar distance = compute_distance(points);
return estimate_pointCount(SkScalarRound(distance));
}
-uint32_t quadraticPointCount_CC(const SkPoint points[], SkScalar tol) {
+static uint32_t quadraticPointCount_CC(const SkPoint points[], SkScalar tol) {
SkScalar distance = compute_distance(points);
return compute_pointCount(distance, tol);
}
@@ -123,6 +123,13 @@
quadraticPointCount_CC(path, SkIntToScalar(1));
uint32_t estimatedCount =
quadraticPointCount_EE(path, SkIntToScalar(1));
+
+ if (false) { // avoid bit rot, suppress warning
+ computedCount =
+ quadraticPointCount_EC(path, SkIntToScalar(1));
+ estimatedCount =
+ quadraticPointCount_CE(path, SkIntToScalar(1));
+ }
// Allow estimated to be high by a factor of two, but no less than
// the computed value.
bool isAccurate = (estimatedCount >= computedCount) &&
diff --git a/tests/PathTest.cpp b/tests/PathTest.cpp
index 73bdef0..9d9903f 100644
--- a/tests/PathTest.cpp
+++ b/tests/PathTest.cpp
@@ -1375,7 +1375,7 @@
REPORTER_ASSERT(reporter, path.isOval(NULL));
}
-void TestPath(skiatest::Reporter* reporter) {
+static void TestPath(skiatest::Reporter* reporter) {
{
SkSize size;
size.fWidth = 3.4f;
diff --git a/tests/PointTest.cpp b/tests/PointTest.cpp
index db9c803..efae223 100644
--- a/tests/PointTest.cpp
+++ b/tests/PointTest.cpp
@@ -34,7 +34,7 @@
REPORTER_ASSERT(reporter, SkScalarNearlyEqual(newLength, SK_Scalar1));
}
-void PointTest(skiatest::Reporter* reporter) {
+static void PointTest(skiatest::Reporter* reporter) {
test_length(reporter, SkIntToScalar(3), SkIntToScalar(4), SkIntToScalar(5));
test_length(reporter, SkFloatToScalar(0.6f), SkFloatToScalar(0.8f),
SK_Scalar1);
diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp
index 4b3f671..536d0c5 100644
--- a/tests/ReadWriteAlphaTest.cpp
+++ b/tests/ReadWriteAlphaTest.cpp
@@ -12,7 +12,7 @@
static const int X_SIZE = 12;
static const int Y_SIZE = 12;
-void ReadWriteAlphaTest(skiatest::Reporter* reporter, GrContext* context) {
+static void ReadWriteAlphaTest(skiatest::Reporter* reporter, GrContext* context) {
#if SK_SCALAR_IS_FIXED
// GPU device known not to work in the fixed pt build.
diff --git a/tests/SortTest.cpp b/tests/SortTest.cpp
index 166cff2..4a5631d 100644
--- a/tests/SortTest.cpp
+++ b/tests/SortTest.cpp
@@ -10,7 +10,7 @@
#include "SkTSort.h"
extern "C" {
- int compare_int(const void* a, const void* b) {
+ static int compare_int(const void* a, const void* b) {
return *(const int*)a - *(const int*)b;
}
}
@@ -44,6 +44,9 @@
SkTHeapSort<int>(array, count);
check_sort(reporter, "Heap", array, count);
}
+ if (false) { // avoid bit rot, suppress warning
+ compare_int(array, array);
+ }
}
// need tests for SkStrSearch
diff --git a/tests/StringTest.cpp b/tests/StringTest.cpp
index ebf7006..08bd280 100644
--- a/tests/StringTest.cpp
+++ b/tests/StringTest.cpp
@@ -28,7 +28,7 @@
va_end(args); \
} while (0)
-void printfAnalog(char* buffer, int size, const char format[], ...) {
+static void printfAnalog(char* buffer, int size, const char format[], ...) {
ARGS_TO_BUFFER(format, buffer, size);
}
diff --git a/tests/XfermodeTest.cpp b/tests/XfermodeTest.cpp
index 966da51..a851b29 100644
--- a/tests/XfermodeTest.cpp
+++ b/tests/XfermodeTest.cpp
@@ -9,7 +9,7 @@
#include "SkColor.h"
#include "SkXfermode.h"
-SkPMColor bogusXfermodeProc(SkPMColor src, SkPMColor dst) {
+static SkPMColor bogusXfermodeProc(SkPMColor src, SkPMColor dst) {
return 42;
}