Bug 140383

Summary: Fix Debug Build Error in Webcore module
Product: WebKit Reporter: Shivakumar J M <shiva.jm>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: changseok, commit-queue, gyuyoung.kim, ossy, svillar
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
ossy: review-, ossy: commit-queue-
Patch-Updated-Review1 none

Description Shivakumar J M 2015-01-12 23:00:24 PST
Got below debug build error for 32-bit efl port:

CMakeFiles/WebCore.dir/platform/linux/MemoryPressureHandlerLinux.cpp.o -c ../../Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp
In file included from ../../Source/WTF/wtf/PossiblyNull.h:29:0,
                 from ../../Source/WTF/wtf/FastMalloc.h:26,
                 from ../../Source/WebCore/config.h:75,
                 from ../../Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp:27:
../../Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp: In member function ‘void WebCore::MemoryPressureHandler::ReliefLogger::platformLog()’:
../../Source/WTF/wtf/Assertions.h:346:105: error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘ssize_t {aka int}’ [-Werror=format=]
 #define LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
                                                                                                         ^
../../Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp:212:9: note: in expansion of macro ‘LOG’
         LOG(MemoryPressure, "Pressure relief: %s: -dirty %ld bytes (from %ld to %ld)", m_logString, (memoryDiff * -1), m_initialMemory, currentMemory);
         ^
../../Source/WTF/wtf/Assertions.h:346:105: error: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘size_t {aka unsigned int}’ [-Werror=format=]
 #define LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
                                                                                                         ^
../../Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp:212:9: note: in expansion of macro ‘LOG’
         LOG(MemoryPressure, "Pressure relief: %s: -dirty %ld bytes (from %ld to %ld)", m_logString, (memoryDiff * -1), m_initialMemory, currentMemory);
         ^
../../Source/WTF/wtf/Assertions.h:346:105: error: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘size_t {aka unsigned int}’ [-Werror=format=]
 #define LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
                                                                                                         ^
../../Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp:212:9: note: in expansion of macro ‘LOG’
         LOG(MemoryPressure, "Pressure relief: %s: -dirty %ld bytes (from %ld to %ld)", m_logString, (memoryDiff * -1), m_initialMemory, currentMemory);
         ^
../../Source/WTF/wtf/Assertions.h:346:105: error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘ssize_t {aka int}’ [-Werror=format=]
 #define LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
                                                                                                         ^
../../Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp:214:9: note: in expansion of macro ‘LOG’
         LOG(MemoryPressure, "Pressure relief: %s: +dirty %ld bytes (from %ld to %ld)", m_logString, memoryDiff, m_initialMemory, currentMemory);
         ^
../../Source/WTF/wtf/Assertions.h:346:105: error: format ‘%ld’ expects argument of type ‘long int’, but argument 5 has type ‘size_t {aka unsigned int}’ [-Werror=format=]
 #define LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
                                                                                                         ^
../../Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp:214:9: note: in expansion of macro ‘LOG’
         LOG(MemoryPressure, "Pressure relief: %s: +dirty %ld bytes (from %ld to %ld)", m_logString, memoryDiff, m_initialMemory, currentMemory);
         ^
../../Source/WTF/wtf/Assertions.h:346:105: error: format ‘%ld’ expects argument of type ‘long int’, but argument 6 has type ‘size_t {aka unsigned int}’ [-Werror=format=]
 #define LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
                                                                                                         ^
../../Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp:214:9: note: in expansion of macro ‘LOG’
         LOG(MemoryPressure, "Pressure relief: %s: +dirty %ld bytes (from %ld to %ld)", m_logString, memoryDiff, m_initialMemory, currentMemory);
         ^
../../Source/WTF/wtf/Assertions.h:346:105: error: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘size_t {aka unsigned int}’ [-Werror=format=]
 #define LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_PREFIX, channel), __VA_ARGS__)
                                                                                                         ^
../../Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp:216:9: note: in expansion of macro ‘LOG’
         LOG(MemoryPressure, "Pressure relief: %s: =dirty (at %ld bytes)", m_logString, currentMemory);
         ^
cc1plus: all warnings being treated as errors
ninja: build stopped: subcommand failed.
Comment 1 Shivakumar J M 2015-01-12 23:04:27 PST
Created attachment 244498 [details]
Patch

Fixed 32 bit debug build error by using proper format specifier.
Comment 2 Shivakumar J M 2015-01-13 00:45:41 PST
Fixed 32 bit debug build error by using proper format specifier in LOG(), we can also use type cast to static_cast<long int> to fix the error.
Comment 3 Csaba Osztrogonác 2015-01-13 01:30:02 PST
Comment on attachment 244498 [details]
Patch

LGTM, r=me
Comment 4 Csaba Osztrogonác 2015-01-13 01:33:19 PST
Comment on attachment 244498 [details]
Patch

no, it won't be good, because it would break 64 bit build.
Comment 5 Csaba Osztrogonác 2015-01-13 01:36:43 PST
size_t is unsigned int on 32 bit and long unsigned int on 64 bit.
So it should be casted to long unsigned int unconditionally.
Comment 6 Shivakumar J M 2015-01-13 02:03:44 PST
Created attachment 244502 [details]
Patch-Updated-Review1

Updated the patch to use %lu and apply static_cast<unsigned long> for printing logs.
Comment 7 WebKit Commit Bot 2015-01-13 02:53:42 PST
Comment on attachment 244502 [details]
Patch-Updated-Review1

Clearing flags on attachment: 244502

Committed r178349: <http://trac.webkit.org/changeset/178349>
Comment 8 WebKit Commit Bot 2015-01-13 02:53:46 PST
All reviewed patches have been landed.  Closing bug.
Comment 9 ChangSeok Oh 2015-01-13 05:19:19 PST
Thanks for the fix. =) I didn't think 32-bit machine support.