Bug 195004 - -Wformat error in SharedBuffer::tryCreateArrayBuffer
Summary: -Wformat error in SharedBuffer::tryCreateArrayBuffer
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKitGTK (show other bugs)
Version: WebKit Nightly Build
Hardware: PC Linux
: P2 Normal
Assignee: Michael Catanzaro
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-02-25 07:29 PST by Michael Catanzaro
Modified: 2019-03-03 08:45 PST (History)
4 users (show)

See Also:


Attachments
Patch (2.07 KB, patch)
2019-02-25 07:43 PST, Michael Catanzaro
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Catanzaro 2019-02-25 07:29:51 PST
Looking over a 32-bit build log from Debian, to check for potential issues with 32-bit build:

/<<PKGBUILDDIR>>/Source/WebCore/PAL/pal/FileSizeFormatter.cpp: In function 'WTF::String fileSizeDescription(uint64_t)':
/<<PKGBUILDDIR>>/Source/WebCore/PAL/pal/FileSizeFormatter.cpp:36:31: warning: format '%tu' expects argument of type 'unsigned ptrdiff_t', but argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]
         return String::format("%tu bytes", size);
                               ^~~~~~~~~~~  ~~~~

In file included from /<<PKGBUILDDIR>>/obj-i686-linux-gnu/DerivedSources/WebCore/unified-sources/UnifiedSource291.cpp:1:
/<<PKGBUILDDIR>>/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp: In function 'WTF::String WebCore::formatByteNumber(size_t)':
/<<PKGBUILDDIR>>/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp:59:27: warning: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
     return String::format("%lu", number);
                           ^~~~~  ~~~~~~

In file included from /<<PKGBUILDDIR>>/obj-i686-linux-gnu/DerivedSources/WebCore/unified-sources/UnifiedSource300.cpp:5:
/<<PKGBUILDDIR>>/Source/WebCore/platform/SharedBuffer.cpp: In member function 'WTF::RefPtr<JSC::ArrayBuffer> WebCore::SharedBuffer::tryCreateArrayBuffer() const':
/<<PKGBUILDDIR>>/Source/WebCore/platform/SharedBuffer.cpp:124:22: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'unsigned int' [-Wformat=]
         WTFLogAlways("SharedBuffer::tryCreateArrayBuffer Unable to create buffer. Requested size was %zu x %lu\n", size(), sizeof(char));
                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comment 1 Michael Catanzaro 2019-02-25 07:30:51 PST
(In reply to Michael Catanzaro from comment #0)
> Looking over a 32-bit build log from Debian, to check for potential issues
> with 32-bit build:
> 
> /<<PKGBUILDDIR>>/Source/WebCore/PAL/pal/FileSizeFormatter.cpp: In function
> 'WTF::String fileSizeDescription(uint64_t)':
> /<<PKGBUILDDIR>>/Source/WebCore/PAL/pal/FileSizeFormatter.cpp:36:31:
> warning: format '%tu' expects argument of type 'unsigned ptrdiff_t', but
> argument 2 has type 'uint64_t' {aka 'long long unsigned int'} [-Wformat=]
>          return String::format("%tu bytes", size);
>                                ^~~~~~~~~~~  ~~~~

This one's already fixed (probably by Darin).
Comment 2 Michael Catanzaro 2019-02-25 07:31:57 PST
(In reply to Michael Catanzaro from comment #0)
> In file included from
> /<<PKGBUILDDIR>>/obj-i686-linux-gnu/DerivedSources/WebCore/unified-sources/
> UnifiedSource291.cpp:1:
> /<<PKGBUILDDIR>>/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp: In
> function 'WTF::String WebCore::formatByteNumber(size_t)':
> /<<PKGBUILDDIR>>/Source/WebCore/page/linux/ResourceUsageOverlayLinux.cpp:59:
> 27: warning: format '%lu' expects argument of type 'long unsigned int', but
> argument 2 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
>      return String::format("%lu", number);
>                            ^~~~~  ~~~~~~

Ditto
Comment 3 Michael Catanzaro 2019-02-25 07:43:14 PST
Created attachment 362903 [details]
Patch
Comment 4 Darin Adler 2019-03-03 00:31:08 PST
Comment on attachment 362903 [details]
Patch

This seems fine. if we did need to log the result of sizeof there are three traditional fixes:

1) add a type cast to some known type
2) put in a local variable or constant of a known type
3) stringify the constant into the literal directly rather than using printf formatting to insert it
Comment 5 WebKit Commit Bot 2019-03-03 08:45:43 PST
Comment on attachment 362903 [details]
Patch

Clearing flags on attachment: 362903

Committed r242327: <https://trac.webkit.org/changeset/242327>
Comment 6 WebKit Commit Bot 2019-03-03 08:45:45 PST
All reviewed patches have been landed.  Closing bug.