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
This commit is contained in:
caryclark@google.com 2012-06-06 12:03:39 +00:00
parent 06c279e42a
commit 42639cddc3
21 changed files with 91 additions and 50 deletions

View File

@ -80,7 +80,7 @@ static void init_src(const SkBitmap& bitmap, const SkColorTable* ct) {
}
}
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 @@ struct Pair {
// 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 @@ uint32_t getPixel(int x, int y, const SkBitmap& bm) {
// 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 @@ void setPixel(int x, int y, uint32_t val, SkBitmap& bm) {
// 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 @@ struct Coordinates {
// 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 @@ void reportCopyVerification(const SkBitmap& bm1, const SkBitmap& bm2,
}
// 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);
}

View File

@ -722,6 +722,7 @@ static void TestDeferredCanvasStateConsistency(
*/
}
// unused
static void TestProxyCanvasStateConsistency(
skiatest::Reporter* reporter,
CanvasTestStep* testStep,
@ -744,6 +745,7 @@ static void TestProxyCanvasStateConsistency(
testStep);
}
// unused
static void TestNWayCanvasStateConsistency(
skiatest::Reporter* reporter,
CanvasTestStep* testStep,
@ -799,18 +801,26 @@ static void TestOverrideStateConsistency(skiatest::Reporter* reporter,
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);
if (false) { // avoid bit rot, suppress warning
TestProxyCanvasStateConsistency(reporter, testStep, referenceCanvas);
}
// The following test code is commented out because SkNWayCanvas does not
// 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
//TestNWayCanvasStateConsistency(reporter, testStep, referenceCanvas);
if (false) { // avoid bit rot, suppress warning
TestNWayCanvasStateConsistency(reporter, testStep, referenceCanvas);
}
if (false) { // avoid bit rot, suppress warning
test_clipVisitor(reporter, &referenceCanvas);
}
}
static void TestCanvas(skiatest::Reporter* reporter) {

View File

@ -13,6 +13,7 @@ static const int X_SIZE = 12;
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 @@ static void check_state(skiatest::Reporter* reporter,
// 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);

View File

@ -22,8 +22,8 @@ static void test_hairclipping(skiatest::Reporter* reporter) {
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 @@ static void test_intersectline(skiatest::Reporter* reporter) {
}
void TestClipper(skiatest::Reporter* reporter) {
static void TestClipper(skiatest::Reporter* reporter) {
test_intersectline(reporter);
test_edgeclipper(reporter);
test_hairclipping(reporter);

View File

@ -26,7 +26,7 @@ static void assert_data(skiatest::Reporter* reporter, SkData* ref,
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;

View File

@ -39,7 +39,7 @@ static void drawAndTest(skiatest::Reporter* reporter, const SkPath& path,
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];

View File

@ -38,9 +38,9 @@ static void TestFillPathInverse(skiatest::Reporter* reporter) {
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);

View File

@ -26,6 +26,9 @@ static const struct TagSize {
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();

View File

@ -28,6 +28,9 @@ static void testChopCubic(skiatest::Reporter* reporter) {
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);
}
}

View File

@ -73,9 +73,20 @@ static int blend31_old(int src, int dst, int a31) {
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 @@ static void TestMath(skiatest::Reporter* reporter) {
#endif
// disable for now
// test_blend31();
if (false) test_blend31(); // avoid bit rot, suppress warning
}
#include "TestClassDef.h"

View File

@ -76,7 +76,7 @@ static void test_common_angles(skiatest::Reporter* reporter) {
}
}
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 @@ void TestMatrix44(skiatest::Reporter* reporter) {
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
}

View File

@ -100,7 +100,7 @@ static void test_flatten(skiatest::Reporter* reporter, const SkMatrix& m) {
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 @@ static bool isSimilarityTransformation(const SkMatrix& matrix,
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 @@ void test_matrix_is_similarity_transform(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, isSimilarityTransformation(mat));
}
void TestMatrix(skiatest::Reporter* reporter) {
static void TestMatrix(skiatest::Reporter* reporter) {
SkMatrix mat, inverse, iden1, iden2;
mat.reset();

View File

@ -240,7 +240,7 @@ static void TestPDFPrimitives(skiatest::Reporter* reporter) {
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");

View File

@ -27,18 +27,18 @@ static void test_to_from(skiatest::Reporter* reporter, const SkPath& path) {
#endif
}
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) } }
};
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) {
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 @@ static void TestParsePath(skiatest::Reporter* reporter) {
}
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);
}

View File

@ -66,22 +66,22 @@ static inline uint32_t compute_pointCount(SkScalar d, SkScalar tol) {
}
}
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 @@ static bool one_d_pe(const int* array, const unsigned int count,
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) &&

View File

@ -1375,7 +1375,7 @@ static void test_oval(skiatest::Reporter* reporter) {
REPORTER_ASSERT(reporter, path.isOval(NULL));
}
void TestPath(skiatest::Reporter* reporter) {
static void TestPath(skiatest::Reporter* reporter) {
{
SkSize size;
size.fWidth = 3.4f;

View File

@ -34,7 +34,7 @@ static void test_Normalize(skiatest::Reporter* reporter,
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);

View File

@ -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.

View File

@ -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 @@ static void TestSort(skiatest::Reporter* reporter) {
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

View File

@ -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);
}

View File

@ -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;
}