2011-04-11 Tony Chang <tony@chromium.org>
authortony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Apr 2011 18:36:13 +0000 (18:36 +0000)
committertony@chromium.org <tony@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 11 Apr 2011 18:36:13 +0000 (18:36 +0000)
        Reviewed by Eric Seidel.

        fix crc computation on 64 bit machines
        https://bugs.webkit.org/show_bug.cgi?id=58243

        unsigned long is dependenct on CPU architecture, so use unsigned which is always 32 bits

        * DumpRenderTree/CyclicRedundancyCheck.cpp:
        (makeCrcTable):
        (computeCrc):
        * DumpRenderTree/CyclicRedundancyCheck.h:
        * DumpRenderTree/PixelDumpSupport.cpp:
        (appendIntToVector):
        (convertChecksumToPNGComment):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83461 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/DumpRenderTree/CyclicRedundancyCheck.cpp
Tools/DumpRenderTree/CyclicRedundancyCheck.h
Tools/DumpRenderTree/PixelDumpSupport.cpp

index 5678a21..cbe90ee 100644 (file)
@@ -1,3 +1,20 @@
+2011-04-11  Tony Chang  <tony@chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        fix crc computation on 64 bit machines
+        https://bugs.webkit.org/show_bug.cgi?id=58243
+
+        unsigned long is dependenct on CPU architecture, so use unsigned which is always 32 bits
+
+        * DumpRenderTree/CyclicRedundancyCheck.cpp:
+        (makeCrcTable):
+        (computeCrc):
+        * DumpRenderTree/CyclicRedundancyCheck.h:
+        * DumpRenderTree/PixelDumpSupport.cpp:
+        (appendIntToVector):
+        (convertChecksumToPNGComment):
+
 2011-04-10  Kimmo Kinnunen  <kimmo.t.kinnunen@nokia.com>
 
         Reviewed by Eric Seidel.
index b9291e9..361ea0f 100644 (file)
 
 #include <wtf/Vector.h>
 
-static void makeCrcTable(unsigned long crcTable[256])
+static void makeCrcTable(unsigned crcTable[256])
 {
-    for (unsigned long i = 0; i < 256; i++) {
-        unsigned long c = i;
+    for (unsigned i = 0; i < 256; i++) {
+        unsigned c = i;
         for (int k = 0; k < 8; k++) {
             if (c & 1)
                 c = -306674912 ^ ((c >> 1) & 0x7fffffff);
@@ -47,16 +47,16 @@ static void makeCrcTable(unsigned long crcTable[256])
     }
 }
 
-unsigned long computeCrc(const Vector<unsigned char>& buffer)
+unsigned computeCrc(const Vector<unsigned char>& buffer)
 {
-    static unsigned long crcTable[256];
+    static unsigned crcTable[256];
     static bool crcTableComputed = false;
     if (!crcTableComputed) {
         makeCrcTable(crcTable);
         crcTableComputed = true;
     }
 
-    unsigned long crc = 0xffffffffL;
+    unsigned crc = 0xffffffffL;
     for (size_t i = 0; i < buffer.size(); ++i)
         crc = crcTable[(crc ^ buffer[i]) & 0xff] ^ ((crc >> 8) & 0x00ffffffL);
     return crc ^ 0xffffffffL;
index c3a739d..ef1d78e 100644 (file)
@@ -33,6 +33,6 @@
 
 #include <wtf/Vector.h>
 
-unsigned long computeCrc(const Vector<unsigned char>&);
+unsigned computeCrc(const Vector<unsigned char>&);
 
 #endif
index a0c2729..e274839 100644 (file)
@@ -74,7 +74,7 @@ void dumpWebViewAsPixelsAndCompareWithExpected(const std::string& expectedHash)
       dumpBitmap(context.get(), actualHash);
 }
 
-static void appendIntToVector(int number, Vector<unsigned char>& vector)
+static void appendIntToVector(unsigned number, Vector<unsigned char>& vector)
 {
     size_t offset = vector.size();
     vector.grow(offset + 4);
@@ -97,7 +97,7 @@ static void convertChecksumToPNGComment(const char* checksum, Vector<unsigned ch
     Vector<unsigned char> dataToCrc;
     dataToCrc.append(textCommentPrefix + 4, prefixLength - 4); // Don't include the chunk length in the crc.
     dataToCrc.append(checksum, checksumLength);
-    unsigned long crc32 = computeCrc(dataToCrc);
+    unsigned crc32 = computeCrc(dataToCrc);
 
     appendIntToVector(crc32, bytesToAdd);
 }