[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da

cwzwarich at webkit.org cwzwarich at webkit.org
Wed Dec 22 18:42:47 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 43c756bba26ad605e655361c8c6430dfbf983f93
Author: cwzwarich at webkit.org <cwzwarich at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Dec 16 04:35:13 2010 +0000

    Reviewed by Darin Adler.
    
    Clang -Wcast-align gives an error in WebBasePluginPackage.mm
    https://bugs.webkit.org/show_bug.cgi?id=51144
    
    Fix an alignment issue. OSSwapInt32 takes data that is 32-bit aligned on ARM, but
    we were calling it on a byte array 32 bits at a time. While this is okay in practice,
    since TCMalloc won't give us a non-32-bit aligned block array of bytes and Vector's
    inline storage is at the beginning of the Vector, it is still better to fix this
    and silence the warning.
    
    * Plugins/WebBasePluginPackage.mm:
    (swapIntsInHeader):
    (-[WebBasePluginPackage isNativeLibraryData:]):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@74172 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/mac/ChangeLog b/WebKit/mac/ChangeLog
index ffd1fed..dfdff5f 100644
--- a/WebKit/mac/ChangeLog
+++ b/WebKit/mac/ChangeLog
@@ -1,3 +1,20 @@
+2010-12-15  Cameron Zwarich  <zwarich at apple.com>
+
+        Reviewed by Darin Adler.
+
+        Clang -Wcast-align gives an error in WebBasePluginPackage.mm
+        https://bugs.webkit.org/show_bug.cgi?id=51144
+
+        Fix an alignment issue. OSSwapInt32 takes data that is 32-bit aligned on ARM, but
+        we were calling it on a byte array 32 bits at a time. While this is okay in practice,
+        since TCMalloc won't give us a non-32-bit aligned block array of bytes and Vector's
+        inline storage is at the beginning of the Vector, it is still better to fix this
+        and silence the warning.
+
+        * Plugins/WebBasePluginPackage.mm:
+        (swapIntsInHeader):
+        (-[WebBasePluginPackage isNativeLibraryData:]):
+
 2010-12-14  Mark Rowe  <mrowe at apple.com>
 
         Reviewed by Sam Weinig.
diff --git a/WebKit/mac/Plugins/WebBasePluginPackage.mm b/WebKit/mac/Plugins/WebBasePluginPackage.mm
index 78b0a7f..08c3e60 100644
--- a/WebKit/mac/Plugins/WebBasePluginPackage.mm
+++ b/WebKit/mac/Plugins/WebBasePluginPackage.mm
@@ -343,31 +343,32 @@ static NSString *pathByResolvingSymlinksAndAliases(NSString *thePath)
         equalIgnoringCase(pluginInfo.file, JavaCFMPluginFilename);
 }
 
-static inline void swapIntsInHeader(uint8_t* bytes, unsigned length)
+static inline void swapIntsInHeader(uint32_t* rawData, size_t length)
 {
-    for (unsigned i = 0; i < length; i += 4) 
-        *(uint32_t*)(bytes + i) = OSSwapInt32(*(uint32_t *)(bytes + i));
+    for (size_t i = 0; i < length; ++i) 
+        rawData[i] = OSSwapInt32(rawData[i]);
 }
 
 - (BOOL)isNativeLibraryData:(NSData *)data
 {
-    Vector<uint8_t, 512> bytes([data length]);
-    memcpy(bytes.data(), [data bytes], bytes.size());
+    NSUInteger sizeInBytes = [data length];
+    Vector<uint32_t, 128> rawData((sizeInBytes - 1) / 4 + 1);
+    memcpy(rawData.data(), [data bytes], sizeInBytes);
     
     unsigned numArchs = 0;
     struct fat_arch singleArch = { 0, 0, 0, 0, 0 };
     struct fat_arch* archs = 0;
        
-    if (bytes.size() >= sizeof(struct mach_header_64)) {
-        uint32_t magic = *reinterpret_cast<uint32_t*>(bytes.data());
+    if (sizeInBytes >= sizeof(struct mach_header_64)) {
+        uint32_t magic = *rawData.data();
         
         if (magic == MH_MAGIC || magic == MH_CIGAM) {
             // We have a 32-bit thin binary
-            struct mach_header* header = (struct mach_header*)bytes.data();
+            struct mach_header* header = (struct mach_header*)rawData.data();
 
             // Check if we need to swap the bytes
             if (magic == MH_CIGAM)
-                swapIntsInHeader(bytes.data(), bytes.size());
+                swapIntsInHeader(rawData.data(), rawData.size());
     
             singleArch.cputype = header->cputype;
             singleArch.cpusubtype = header->cpusubtype;
@@ -376,11 +377,11 @@ static inline void swapIntsInHeader(uint8_t* bytes, unsigned length)
             numArchs = 1;
         } else if (magic == MH_MAGIC_64 || magic == MH_CIGAM_64) {
             // We have a 64-bit thin binary
-            struct mach_header_64* header = (struct mach_header_64*)bytes.data();
+            struct mach_header_64* header = (struct mach_header_64*)rawData.data();
 
             // Check if we need to swap the bytes
             if (magic == MH_CIGAM_64)
-                swapIntsInHeader(bytes.data(), bytes.size());
+                swapIntsInHeader(rawData.data(), rawData.size());
             
             singleArch.cputype = header->cputype;
             singleArch.cpusubtype = header->cpusubtype;
@@ -392,12 +393,12 @@ static inline void swapIntsInHeader(uint8_t* bytes, unsigned length)
 
             // Check if we need to swap the bytes
             if (magic == FAT_CIGAM)
-                swapIntsInHeader(bytes.data(), bytes.size());
+                swapIntsInHeader(rawData.data(), rawData.size());
             
-            archs = (struct fat_arch*)(bytes.data() + sizeof(struct fat_header));            
-            numArchs = ((struct fat_header *)bytes.data())->nfat_arch;
+            archs = (struct fat_arch*)(rawData.data() + sizeof(struct fat_header));            
+            numArchs = ((struct fat_header *)rawData.data())->nfat_arch;
             
-            unsigned maxArchs = (bytes.size() - sizeof(struct fat_header)) / sizeof(struct fat_arch);
+            unsigned maxArchs = (sizeInBytes - sizeof(struct fat_header)) / sizeof(struct fat_arch);
             if (numArchs > maxArchs)
                 numArchs = maxArchs;
         }            

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list