Bug 117991 - Fix cast-align warnings in FastMalloc.cpp
Summary: Fix cast-align warnings in FastMalloc.cpp
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Csaba Osztrogonác
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-25 08:03 PDT by Csaba Osztrogonác
Modified: 2013-07-03 03:20 PDT (History)
7 users (show)

See Also:


Attachments
Patch (1.89 KB, patch)
2013-07-02 08:38 PDT, Csaba Osztrogonác
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Csaba Osztrogonác 2013-06-25 08:03:05 PDT
/home/oszi/WebKit/Source/WTF/wtf/FastMalloc.cpp:3167:102: warning: cast from 'char*' to 'uint32_t* {aka unsigned int*}' increases required alignment of target type [-Wcast-align]
/home/oszi/WebKit/Source/WTF/wtf/FastMalloc.cpp:3167:194: warning: cast from 'char*' to 'uint32_t* {aka unsigned int*}' increases required alignment of target type [-Wcast-align]
/home/oszi/WebKit/Source/WTF/wtf/FastMalloc.cpp:3167:305: warning: cast from 'char*' to 'uint32_t* {aka unsigned int*}' increases required alignment of target type [-Wcast-align]
/home/oszi/WebKit/Source/WTF/wtf/FastMalloc.cpp:3167:52: warning: cast from 'char*' to 'uint32_t* {aka unsigned int*}' increases required alignment of target type [-Wcast-align]

3167: POISON_DEALLOCATION_EXPLICIT(ptr, size, startPoison, endPoison);

#define POISON_DEALLOCATION_EXPLICIT(allocation, allocationSize, startPoison, endPoison) do { \
    ASSERT((allocationSize) >= 2 * sizeof(uint32_t)); \
    reinterpret_cast<uint32_t*>(allocation)[0] = 0xbadbeef9; \
    reinterpret_cast<uint32_t*>(allocation)[1] = 0xbadbeefb; \
    if ((allocationSize) < 4 * sizeof(uint32_t)) \
        break; \
    reinterpret_cast<uint32_t*>(allocation)[2] = (startPoison) ^ PTR_TO_UINT32(allocation); \
    reinterpret_cast<uint32_t*>(allocation)[END_POISON_INDEX(allocationSize)] = (endPoison) ^ PTR_TO_UINT32(allocation); \
} while (false)

This define introduced in 
- https://trac.webkit.org/changeset/143488/trunk/Source/WTF/wtf/FastMalloc.cpp
- https://trac.webkit.org/changeset/143996/trunk/Source/WTF/wtf/FastMalloc.cpp

The question is that ptr in line 3167 is uint32_t aligned or not?
Comment 1 Csaba Osztrogonác 2013-07-01 02:23:47 PDT
Could you check if they can be a valid warnings or can we suppress 
them with using reinterpret_cast_ptr instead of reinterpret_cast ?
Comment 2 Csaba Osztrogonác 2013-07-02 07:56:35 PDT
any idea?
Comment 3 Mark Hahnenberg 2013-07-02 08:35:05 PDT
(In reply to comment #2)
> any idea?

I think this one is okay to change to reinterpret_cast_ptr too because all FastMalloc allocations are guaranteed to be at least 8 byte aligned.
Comment 4 Csaba Osztrogonác 2013-07-02 08:38:31 PDT
Created attachment 205919 [details]
Patch
Comment 5 Csaba Osztrogonác 2013-07-02 08:44:15 PDT
(In reply to comment #3)
> (In reply to comment #2)
> > any idea?
> 
> I think this one is okay to change to reinterpret_cast_ptr too because all FastMalloc allocations are guaranteed to be at least 8 byte aligned.

Thanks, I attached the patch.
Comment 6 Mark Hahnenberg 2013-07-02 09:13:25 PDT
Comment on attachment 205919 [details]
Patch

r=me
Comment 7 Csaba Osztrogonác 2013-07-03 03:19:58 PDT
Comment on attachment 205919 [details]
Patch

Clearing flags on attachment: 205919

Committed r152349: <http://trac.webkit.org/changeset/152349>
Comment 8 Csaba Osztrogonác 2013-07-03 03:20:04 PDT
All reviewed patches have been landed.  Closing bug.