Skip to content

Commit

Permalink
Merge r242327 - -Wformat error in SharedBuffer::tryCreateArrayBuffer
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=195004

Reviewed by Darin Adler.

Seems C++ has no format specifier appropriate for printing the result of sizeof. We should
just not try to print it. Anyway, that's easy in this case, because sizeof(char) is
guaranteed to be 1. This code was an attempt to be pedantic to account for mythical systems
with char larger than one byte, but perhaps it didn't realize sizeof always returns
multiples of char and so sizeof(char) is always one even on such mythical systems.

Note the sizeof(char) use two lines up is left since it's not clear that switching it to 1
would actually be more readable.

* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::tryCreateArrayBuffer const):
  • Loading branch information
mcatanzaro authored and carlosgcampos committed Mar 6, 2019
1 parent 8fd34b4 commit 2f327f8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,22 @@
2019-03-03 Michael Catanzaro <mcatanzaro@igalia.com>

-Wformat error in SharedBuffer::tryCreateArrayBuffer
https://bugs.webkit.org/show_bug.cgi?id=195004

Reviewed by Darin Adler.

Seems C++ has no format specifier appropriate for printing the result of sizeof. We should
just not try to print it. Anyway, that's easy in this case, because sizeof(char) is
guaranteed to be 1. This code was an attempt to be pedantic to account for mythical systems
with char larger than one byte, but perhaps it didn't realize sizeof always returns
multiples of char and so sizeof(char) is always one even on such mythical systems.

Note the sizeof(char) use two lines up is left since it's not clear that switching it to 1
would actually be more readable.

* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::tryCreateArrayBuffer const):

2019-02-27 Darin Adler <darin@apple.com>

Fixed makeString(float) to do shortest-form serialization without first converting to double
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/platform/SharedBuffer.cpp
Expand Up @@ -135,7 +135,7 @@ RefPtr<ArrayBuffer> SharedBuffer::tryCreateArrayBuffer() const
{
auto arrayBuffer = ArrayBuffer::tryCreateUninitialized(static_cast<unsigned>(size()), sizeof(char));
if (!arrayBuffer) {
WTFLogAlways("SharedBuffer::tryCreateArrayBuffer Unable to create buffer. Requested size was %zu x %lu\n", size(), sizeof(char));
WTFLogAlways("SharedBuffer::tryCreateArrayBuffer Unable to create buffer. Requested size was %zu\n", size());
return nullptr;
}

Expand Down

0 comments on commit 2f327f8

Please sign in to comment.