RESOLVED FIXED 195004
-Wformat error in SharedBuffer::tryCreateArrayBuffer
https://bugs.webkit.org/show_bug.cgi?id=195004
Summary -Wformat error in SharedBuffer::tryCreateArrayBuffer
Michael Catanzaro
Reported 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)); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Attachments
Patch (2.07 KB, patch)
2019-02-25 07:43 PST, Michael Catanzaro
no flags
Michael Catanzaro
Comment 1 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).
Michael Catanzaro
Comment 2 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
Michael Catanzaro
Comment 3 2019-02-25 07:43:14 PST
Darin Adler
Comment 4 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
WebKit Commit Bot
Comment 5 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>
WebKit Commit Bot
Comment 6 2019-03-03 08:45:45 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.