Bug 58172 - Fix -Wcast-align warning in WebBasePluginPackage.mm
Summary: Fix -Wcast-align warning in WebBasePluginPackage.mm
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Misc. (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: David Kilzer (:ddkilzer)
Depends on:
Reported: 2011-04-08 16:10 PDT by David Kilzer (:ddkilzer)
Modified: 2011-04-13 12:31 PDT (History)
4 users (show)

See Also:

Patch (2.25 KB, patch)
2011-04-08 16:10 PDT, David Kilzer (:ddkilzer)
ddkilzer: review-
Details | Formatted Diff | Diff
Patch v2 (3.49 KB, patch)
2011-04-08 17:31 PDT, David Kilzer (:ddkilzer)
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Kilzer (:ddkilzer) 2011-04-08 16:10:58 PDT
Created attachment 88891 [details]

Reviewed by NOBODY (OOPS!).

Fixes the following warning with -Wcast-align enabled:

Source/WebKit/mac/Plugins/WebBasePluginPackage.mm:402:21:{402:21-402:93}{402:39-402:93}: error: cast from 'uint8_t *' (aka 'unsigned char *') to 'struct fat_arch *' increases required alignment from 1 to 4 [-Werror,-Wcast-align,3]
archs = (struct fat_arch*)((uint8_t*)rawData.data() + sizeof(struct fat_header));

* Plugins/WebBasePluginPackage.mm:
(-[WebBasePluginPackage isNativeLibraryData:]): Remove cast to
(uint8_t*).  The rawData Vector uses a type of uint32_t, and
struct fat_header contains two uint32_t data members, so there
is no need to cast to uint8_t* here.
 2 files changed, 19 insertions(+), 1 deletions(-)
Comment 1 WebKit Review Bot 2011-04-08 16:13:46 PDT
Attachment 88891 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebKit/mac/ChangeLog', u'Source/Web..." exit_code: 1

Source/WebKit/mac/ChangeLog:1:  ChangeLog entry has no bug number  [changelog/bugnumber] [5]
Total errors found: 1 in 2 files

If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 2 David Kilzer (:ddkilzer) 2011-04-08 16:40:17 PDT
Comment on attachment 88891 [details]

Cameron pointed out that my pointer math is incorrect.  New patch forthcoming.
Comment 3 David Kilzer (:ddkilzer) 2011-04-08 17:31:22 PDT
Created attachment 88907 [details]
Patch v2
Comment 4 David Kilzer (:ddkilzer) 2011-04-13 12:31:10 PDT
Committed r83755: <http://trac.webkit.org/changeset/83755>