Bug 43876

Summary: REGRESSION(65135): format specifier warnings
Product: WebKit Reporter: Csaba Osztrogonác <ossy>
Component: WebCore Misc.Assignee: Csaba Osztrogonác <ossy>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, ukai
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Bug Depends on:    
Bug Blocks: 43191    
Attachments:
Description Flags
Patch ap: review+

Csaba Osztrogonác
Reported 2010-08-11 13:43:01 PDT
warnings introduced in http://trac.webkit.org/changeset/65135: 32 bit release build: ../../../WebCore/websockets/WebSocketChannel.cpp:218: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 2 has type ‘size_t’ WebCore/websockets/WebSocketChannel.cpp:218: m_context->addMessage(JSMessageSource, LogMessageType, ErrorMessageLevel, String::format("WebSocket frame (at %lu bytes) is too long.", newBufferSize), 0, m_handshake.clientOrigin()); 32 bit debug build: ../../../WebCore/websockets/WebSocketChannel.cpp:205: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 3 has type ‘size_t’ ../../../WebCore/websockets/WebSocketChannel.cpp:205: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 4 has type ‘size_t’ ../../../WebCore/websockets/WebSocketChannel.cpp:218: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 2 has type ‘size_t’ ../../../WebCore/websockets/WebSocketChannel.cpp:258: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 3 has type ‘size_t’ ../../../WebCore/websockets/WebSocketChannel.cpp:280: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 3 has type ‘size_t’ ../../../WebCore/websockets/WebSocketChannel.cpp:288: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 3 has type ‘size_t’ ../../../WebCore/websockets/WebSocketChannel.cpp:294: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 3 has type ‘size_t’ ../../../WebCore/websockets/WebSocketChannel.cpp:294: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 4 has type ‘size_t’ ../../../WebCore/websockets/WebSocketChannel.cpp:304: warning: format ‘%lu’ expects type ‘long unsigned int’, but argument 4 has type ‘size_t’ 205: LOG(Network, "WebSocket buffer overflow (%lu+%lu)", m_bufferSize, len); 258: LOG(Network, "remaining in read buf %lu", m_bufferSize); 280: LOG(Network, "frame length overflow %lu", length); 288: LOG(Network, "frame length overflow %lu+%u", newLength, lengthMsgByte); 294: LOG(Network, "frame length integer wrap %lu->%lu", length, newLength); 304: LOG(Network, "frame buffer pointer wrap %p+%lu->%p", p, length, p + length); The problem is that size_t is unsigned int (4 bytes) and not unsigned long int (8 bytes) on 32 bit systems. Accordingly using %lu on 32 bit systems is incorrect, we have to use %u or %lu depends on sizeof(size_t) instead of hard coded %lu.
Attachments
Patch (4.21 KB, patch)
2010-08-11 21:57 PDT, Fumitoshi Ukai
ap: review+
Csaba Osztrogonác
Comment 1 2010-08-11 14:04:45 PDT
My first idea was replace %lu with %zu. But unfortunately Windows can't handle z modifier, but I. We can fix it with #if guards, but in my opinion it is too ugly: #if OS(WINDOWS) LOG( ... %Iu ... ); #else LOG( ... %zu ... ); #endif Have you got any idea how could we fix it correctly?
Alexey Proskuryakov
Comment 2 2010-08-11 14:08:49 PDT
We could add a macro that expands to either %Iu or %zu, or we could cast the values to unsigned long.
Fumitoshi Ukai
Comment 3 2010-08-11 21:57:35 PDT
Fumitoshi Ukai
Comment 4 2010-08-11 23:31:48 PDT
Note You need to log in before you can comment on or make changes to this bug.