Fix Valgrind reports of test branching on uninitialized data.

Fixes reports like:
[07:10:01.235147] [ 71/188] (9) Serialization
[07:10:01.235186] ==20052== Thread 3:
[07:10:01.235223] ==20052== Conditional jump or move depends on uninitialised value(s)
[07:10:01.235259] ==20052==    at 0x546632: SkRRect::setRectRadii(SkRect const&, SkPoint const*) (SkRect.h:426)
[07:10:01.735876] ==20052==    by 0x546FB7: SkRRect::readFromMemory(void const*, unsigned long) (SkRRect.cpp:362)
[07:10:01.735965] ==20052==    by 0x47F87F: Tests(skiatest::Reporter*) (SerializationTest.cpp:20)
[07:10:01.736007] ==20052==    by 0x480367: skiatest::SerializationClass::onRun(skiatest::Reporter*) (SerializationTest.cpp:212)
[07:10:01.736048] ==20052==    by 0x4881DA: skiatest::Test::run() (Test.cpp:109)
[07:10:01.736086] ==20052==    by 0x482516: SkTestRunnable::run() (skia_test.cpp:155)
[07:10:01.736122] ==20052==    by 0x6236E5: SkThreadPool::Loop(void*) (SkThreadPool.cpp:97)
[07:10:01.736158] ==20052==    by 0x62DDB2: thread_start(void*) (SkThreadUtils_pthread.cpp:66)
[07:10:01.736192] ==20052==    by 0x4E39E99: start_thread (pthread_create.c:308)
[07:10:01.736228] ==20052==    by 0x6A5BCCC: clone (clone.S:112)
[07:10:01.736262] ==20052==  Uninitialised value was created by a stack allocation
[07:10:01.736296] ==20052==    at 0x47EC6A: Tests(skiatest::Reporter*) (SerializationTest.cpp:155)



git-svn-id: http://skia.googlecode.com/svn/trunk@12419 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bungeman@google.com 2013-11-27 17:00:12 +00:00
Родитель 09800bc983
Коммит a9a4b04a98
1 изменённых файлов: 11 добавлений и 5 удалений

Просмотреть файл

@ -173,37 +173,43 @@ static void Tests(skiatest::Reporter* reporter) {
// Test rrect serialization
{
// SkRRect does not initialize anything.
// An uninitialized SkRRect can be serialized,
// but will branch on uninitialized data when deserialized.
SkRRect rrect;
SkRect rect = SkRect::MakeXYWH(1, 2, 20, 30);
SkVector corners[4] = { {1, 2}, {2, 3}, {3,4}, {4,5} };
rrect.setRectRadii(rect, corners);
TestAlignment(&rrect, reporter);
}
// Test readByteArray
{
unsigned char data[kArraySize] = {0};
unsigned char data[kArraySize] = { 1, 2, 3 };
TestArraySerialization(data, reporter);
}
// Test readColorArray
{
SkColor data[kArraySize];
SkColor data[kArraySize] = { SK_ColorBLACK, SK_ColorWHITE, SK_ColorRED };
TestArraySerialization(data, reporter);
}
// Test readIntArray
{
int32_t data[kArraySize];
int32_t data[kArraySize] = { 1, 2, 4, 8 };
TestArraySerialization(data, reporter);
}
// Test readPointArray
{
SkPoint data[kArraySize];
SkPoint data[kArraySize] = { {6, 7}, {42, 128} };
TestArraySerialization(data, reporter);
}
// Test readScalarArray
{
SkScalar data[kArraySize];
SkScalar data[kArraySize] = { SK_Scalar1, SK_ScalarHalf, SK_ScalarMax };
TestArraySerialization(data, reporter);
}
}