⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 278619 in webkit


Ignore:
Timestamp:
Jun 8, 2021, 10:35:15 AM (5 years ago)
Author:
Chris Dumez
Message:

Reduce use of reinterpret_cast<> in the codebase
https://bugs.webkit.org/show_bug.cgi?id=226743

Reviewed by Darin Adler.

Source/WebCore:

  • Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp:

(WebCore::CDMSessionClearKey::generateKeyRequest):

  • Modules/fetch/FetchBody.cpp:

(WebCore::FetchBody::take):

  • Modules/fetch/FetchBodyConsumer.cpp:

(WebCore::FetchBodyConsumer::resolve):
(WebCore::FetchBodyConsumer::takeAsBlob):
(WebCore::FetchBodyConsumer::takeAsText):

  • Modules/mediastream/RTCDataChannelRemoteHandler.cpp:

(WebCore::RTCDataChannelRemoteHandler::readyToSend):
(WebCore::RTCDataChannelRemoteHandler::sendStringData):
(WebCore::RTCDataChannelRemoteHandler::sendRawData):

  • Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp:

(WebCore::copyBusData):

  • Modules/webauthn/AuthenticatorResponseData.h:

(WebCore::encodeArrayBuffer):
(WebCore::decodeArrayBuffer):

  • Modules/websockets/WebSocketChannel.cpp:

(WebCore::WebSocketChannel::startClosingHandshake):
(WebCore::WebSocketChannel::processOutgoingFrameQueue):

  • Modules/websockets/WebSocketHandshake.cpp:

(WebCore::WebSocketHandshake::getExpectedWebSocketAccept):
(WebCore::headerHasValidHTTPVersion):

  • bindings/js/ScriptBufferSourceProvider.h:
  • bindings/js/SerializedScriptValue.cpp:

(WebCore::CloneDeserializer::readString):

  • contentextensions/SerializedNFA.cpp:

(WebCore::ContentExtensions::SerializedNFA::pointerAtOffsetInFile const):

  • dom/Node.cpp:

(WebCore::hashPointer):

  • dom/TextEncoder.cpp:

(WebCore::TextEncoder::encode const):

  • dom/TextEncoderStreamEncoder.cpp:

(WebCore::TextEncoderStreamEncoder::flush):

  • editing/cocoa/WebContentReaderCocoa.mm:

(WebCore::sanitizeMarkupWithArchive):

  • html/canvas/WebGLRenderingContextBase.cpp:

(WebCore::WebGLRenderingContextBase::texImageArrayBufferViewHelper):

  • inspector/DOMPatchSupport.cpp:

(WebCore::addStringToSHA1):

  • loader/TextResourceDecoder.cpp:

(WebCore::TextResourceDecoder::textFromUTF8):

  • loader/cache/CachedScript.cpp:

(WebCore::CachedScript::script):

  • page/cocoa/ResourceUsageOverlayCocoa.mm:

(WebCore::showText):

  • platform/SharedBufferChunkReader.cpp:

(WebCore::SharedBufferChunkReader::nextChunk):

  • platform/cf/SharedBufferCF.cpp:

(WebCore::SharedBuffer::createCFData const):

  • platform/generic/KeyedEncoderGeneric.cpp:

(WebCore::KeyedEncoderGeneric::encodeString):

  • platform/graphics/GraphicsContextGL.cpp:

(WebCore::GraphicsContextGL::packImageData):

  • platform/graphics/ImageBufferBackend.cpp:

(WebCore::ImageBufferBackend::getPixelBuffer const):
(WebCore::ImageBufferBackend::putPixelBuffer):

  • platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:

(WebCore::InbandTextTrackPrivateAVF::processNativeSamples):

  • platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp:

(WebCore::CDMSessionAVFoundationCF::generateKeyRequest):
(WebCore::CDMSessionAVFoundationCF::update):

  • platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp:

(WebCore::InbandTextTrackPrivateAVCF::readNativeSampleBuffer):

  • platform/graphics/displaylists/DisplayListItemBuffer.cpp:

(WebCore::DisplayList::ItemBuffer::createItemBuffer):

  • platform/graphics/displaylists/DisplayListIterator.cpp:

(WebCore::DisplayList::DisplayList::Iterator::updateCurrentItem):

  • platform/image-decoders/gif/GIFImageReader.h:

(GIFImageReader::data const):

  • platform/mac/SSLKeyGeneratorMac.mm:

(WebCore::signedPublicKeyAndChallengeString):

  • platform/mediastream/RealtimeMediaSourceCenter.cpp:

(WebCore::addStringToSHA1):

  • platform/network/FormDataBuilder.cpp:

(WebCore::FormDataBuilder::encodeStringAsFormData):

  • platform/network/SocketStreamHandle.cpp:

(WebCore::SocketStreamHandle::sendHandshake):

  • platform/network/cf/ResourceRequestCFNet.cpp:

(WebCore::ResourceRequest::doUpdatePlatformRequest):

  • platform/network/cf/ResourceRequestCFNet.h:

(WebCore::httpHeaderValueUsingSuitableEncoding):

  • platform/network/cf/SocketStreamHandleImplCFNet.cpp:

(WebCore::SocketStreamHandleImpl::platformSendInternal):

  • platform/network/curl/CurlCacheEntry.cpp:

(WebCore::CurlCacheEntry::generateBaseFilename):

  • platform/sql/SQLiteStatement.cpp:

(WebCore::SQLiteStatement::columnBlobView):

  • testing/MockCDMFactory.cpp:

(WebCore::MockCDM::sanitizeResponse const):

Source/WebDriver:

  • socket/HTTPParser.cpp:

(WebDriver::HTTPParser::readLine):

  • socket/SessionHostSocket.cpp:

(WebDriver::SessionHost::sendWebInspectorEvent):

Source/WebKit:

  • GPUProcess/media/RemoteMediaPlayerProxy.cpp:

(WebKit::RemoteMediaPlayerProxy::mediaPlayerInitializationDataEncountered):

  • GPUProcess/media/RemoteTextTrackProxy.cpp:

(WebKit::RemoteTextTrackProxy::addDataCue):

  • GPUProcess/webrtc/RemoteMediaRecorder.cpp:

(WebKit::RemoteMediaRecorder::fetchData):

  • NetworkProcess/cache/NetworkCacheDataCurl.cpp:

(WebKit::NetworkCache::Data::apply const):

  • NetworkProcess/cache/NetworkCacheKey.cpp:

(WebKit::NetworkCache::hashString):

  • NetworkProcess/soup/WebKitDirectoryInputStream.cpp:

(webkitDirectoryInputStreamRead):

  • Platform/IPC/ArgumentCoders.cpp:

(IPC::ArgumentCoder<CString>::encode):
(IPC::ArgumentCoder<String>::encode):

  • Shared/API/c/cf/WKStringCF.mm:

(WKStringCopyCFString):

  • Shared/API/c/cf/WKURLCF.mm:

(WKURLCopyCFURL):

  • Shared/ShareableResource.cpp:

(WebKit::ShareableResource::wrapInSharedBuffer):

  • Shared/SharedDisplayListHandle.h:

(WebKit::SharedDisplayListHandle::data const):

  • Shared/WebCompiledContentRuleList.cpp:

(WebKit::WebCompiledContentRuleList::conditionsApplyOnlyToDomain const):

  • UIProcess/API/APIWebAuthenticationAssertionResponse.cpp:

(API::WebAuthenticationAssertionResponse::userHandle const):

  • UIProcess/API/C/WKPage.cpp:

(dataFrom):

  • UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.mm:

(WebKit::RedirectSOAuthorizationSession::completeInternal):

  • UIProcess/Inspector/socket/RemoteInspectorClient.cpp:

(WebKit::RemoteInspectorClient::sendWebInspectorEvent):

  • WebProcess/Network/WebSocketChannel.cpp:

(WebKit::WebSocketChannel::createMessageQueue):
(WebKit::WebSocketChannel::didReceiveText):

  • WebProcess/Network/webrtc/RTCDataChannelRemoteManager.cpp:

(WebKit::RTCDataChannelRemoteManager::sendData):
(WebKit::RTCDataChannelRemoteManager::RemoteSourceConnection::didReceiveStringData):

  • WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:

(WebKit::NetscapePluginStream::sendJavaScriptStream):

Source/WTF:

  • wtf/CryptographicallyRandomNumber.cpp:
  • wtf/FastMalloc.h:

(WTF::FastAllocator::allocate):

  • wtf/SHA1.h:

(WTF::SHA1::addBytes):

  • wtf/StackCheck.h:

(WTF::StackCheck::Scope::Scope):
(WTF::StackCheck::StackCheck):

  • wtf/URLHelpers.cpp:

(WTF::URLHelpers::userVisibleURL):

  • wtf/URLParser.cpp:

(WTF::URLParser::formURLDecode):

  • wtf/cf/URLCF.cpp:

(WTF::URL::createCFURL const):

  • wtf/cocoa/URLCocoa.mm:

(WTF::URL::createCFURL const):

  • wtf/persistence/PersistentCoders.cpp:

(WTF::Persistence::Coder<CString>::encode):
(WTF::Persistence::Coder<String>::encode):

  • wtf/text/CString.h:
  • wtf/text/WTFString.cpp:

(WTF::String::latin1 const):

  • wtf/text/cf/StringImplCF.cpp:

(WTF::StringImpl::createCFString):

Location:
trunk/Source
Files:
77 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r278618 r278619  
     12021-06-08  Chris Dumez  <cdumez@apple.com>
     2
     3        Reduce use of reinterpret_cast<> in the codebase
     4        https://bugs.webkit.org/show_bug.cgi?id=226743
     5
     6        Reviewed by Darin Adler.
     7
     8        * wtf/CryptographicallyRandomNumber.cpp:
     9        * wtf/FastMalloc.h:
     10        (WTF::FastAllocator::allocate):
     11        * wtf/SHA1.h:
     12        (WTF::SHA1::addBytes):
     13        * wtf/StackCheck.h:
     14        (WTF::StackCheck::Scope::Scope):
     15        (WTF::StackCheck::StackCheck):
     16        * wtf/URLHelpers.cpp:
     17        (WTF::URLHelpers::userVisibleURL):
     18        * wtf/URLParser.cpp:
     19        (WTF::URLParser::formURLDecode):
     20        * wtf/cf/URLCF.cpp:
     21        (WTF::URL::createCFURL const):
     22        * wtf/cocoa/URLCocoa.mm:
     23        (WTF::URL::createCFURL const):
     24        * wtf/persistence/PersistentCoders.cpp:
     25        (WTF::Persistence::Coder<CString>::encode):
     26        (WTF::Persistence::Coder<String>::encode):
     27        * wtf/text/CString.h:
     28        * wtf/text/WTFString.cpp:
     29        (WTF::String::latin1 const):
     30        * wtf/text/cf/StringImplCF.cpp:
     31        (WTF::StringImpl::createCFString):
     32
    1332021-06-08  Devin Rousso  <drousso@apple.com>
    234
  • trunk/Source/WTF/wtf/CryptographicallyRandomNumber.cpp

    r277958 r278619  
    150150    Locker locker { m_lock };
    151151
    152     unsigned char* result = reinterpret_cast<unsigned char*>(buffer);
     152    auto result = static_cast<unsigned char*>(buffer);
    153153    stirIfNeeded();
    154154    while (length--) {
  • trunk/Source/WTF/wtf/FastMalloc.h

    r274871 r278619  
    204204    T* allocate(size_t count)
    205205    {
    206         return reinterpret_cast<T*>(fastMalloc(sizeof(T) * count));
     206        return static_cast<T*>(fastMalloc(sizeof(T) * count));
    207207    }
    208208
  • trunk/Source/WTF/wtf/SHA1.h

    r251263 r278619  
    5252    void addBytes(const CString& input)
    5353    {
    54         const char* string = input.data();
    55         addBytes(reinterpret_cast<const uint8_t*>(string), input.length());
     54        addBytes(input.dataAsUInt8Ptr(), input.length());
    5655    }
    5756    WTF_EXPORT_PRIVATE void addBytes(const uint8_t* input, size_t length);
  • trunk/Source/WTF/wtf/StackCheck.h

    r261325 r278619  
    5858            // 1. break the interval into smaller pieces (i.e. insert more checks), or
    5959            // 2. use a larger reservedZone size.
    60             uint8_t* currentStackCheckpoint = reinterpret_cast<uint8_t*>(currentStackPointer());
     60            uint8_t* currentStackCheckpoint = static_cast<uint8_t*>(currentStackPointer());
    6161            uint8_t* previousStackCheckpoint = m_checker.m_lastStackCheckpoint;
    6262            RELEASE_ASSERT(previousStackCheckpoint - currentStackCheckpoint > 0);
     
    8888#if VERIFY_STACK_CHECK_RESERVED_ZONE_SIZE
    8989        , m_ownerThread(&Thread::current())
    90         , m_lastStackCheckpoint(reinterpret_cast<uint8_t*>(currentStackPointer()))
     90        , m_lastStackCheckpoint(static_cast<uint8_t*>(currentStackPointer()))
    9191        , m_reservedZone(minReservedZone)
    9292#endif
  • trunk/Source/WTF/wtf/URLHelpers.cpp

    r278351 r278619  
    823823String userVisibleURL(const CString& url)
    824824{
    825     auto* before = reinterpret_cast<const unsigned char*>(url.data());
     825    auto* before = url.dataAsUInt8Ptr();
    826826    int length = url.length();
    827827
  • trunk/Source/WTF/wtf/URLParser.cpp

    r278351 r278619  
    27932793    if (utf8.isNull())
    27942794        return std::nullopt;
    2795     auto percentDecoded = percentDecode(reinterpret_cast<const LChar*>(utf8.data()), utf8.length());
     2795    auto percentDecoded = percentDecode(utf8.dataAsUInt8Ptr(), utf8.length());
    27962796    return String::fromUTF8ReplacingInvalidSequences(percentDecoded.data(), percentDecoded.size());
    27972797}
  • trunk/Source/WTF/wtf/cf/URLCF.cpp

    r264382 r278619  
    5353    RetainPtr<CFURLRef> cfURL;
    5454    if (LIKELY(m_string.is8Bit() && m_string.isAllASCII()))
    55         cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(m_string.characters8()), m_string.length(), kCFStringEncodingUTF8, nullptr, true));
     55        cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, m_string.characters8(), m_string.length(), kCFStringEncodingUTF8, nullptr, true));
    5656    else {
    5757        CString utf8 = m_string.utf8();
    58         cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(utf8.data()), utf8.length(), kCFStringEncodingUTF8, nullptr, true));
     58        cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, utf8.dataAsUInt8Ptr(), utf8.length(), kCFStringEncodingUTF8, nullptr, true));
    5959    }
    6060
  • trunk/Source/WTF/wtf/cocoa/URLCocoa.mm

    r278253 r278619  
    7171    RetainPtr<CFURLRef> cfURL;
    7272    if (LIKELY(m_string.is8Bit() && m_string.isAllASCII()))
    73         cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(m_string.characters8()), m_string.length(), kCFStringEncodingUTF8, nullptr, true));
     73        cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, m_string.characters8(), m_string.length(), kCFStringEncodingUTF8, nullptr, true));
    7474    else {
    7575        CString utf8 = m_string.utf8();
    76         cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(utf8.data()), utf8.length(), kCFStringEncodingUTF8, nullptr, true));
     76        cfURL = adoptCF(CFURLCreateAbsoluteURLWithBytes(nullptr, utf8.dataAsUInt8Ptr(), utf8.length(), kCFStringEncodingUTF8, nullptr, true));
    7777    }
    7878
  • trunk/Source/WTF/wtf/persistence/PersistentCoders.cpp

    r278253 r278619  
    5858    uint32_t length = string.length();
    5959    encoder << length;
    60     encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.data()), length);
     60    encoder.encodeFixedLengthData(string.dataAsUInt8Ptr(), length);
    6161}
    6262
     
    9999
    100100    if (is8Bit)
    101         encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.characters8()), length * sizeof(LChar));
     101        encoder.encodeFixedLengthData(string.characters8(), length);
    102102    else
    103103        encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.characters16()), length * sizeof(UChar));
  • trunk/Source/WTF/wtf/text/CString.h

    r264488 r278619  
    6262    WTF_EXPORT_PRIVATE CString(const char*);
    6363    WTF_EXPORT_PRIVATE CString(const char*, size_t length);
     64    CString(const uint8_t* data, size_t length) : CString(reinterpret_cast<const char*>(data), length) { }
    6465    CString(CStringBuffer* buffer) : m_buffer(buffer) { }
    6566    WTF_EXPORT_PRIVATE static CString newUninitialized(size_t length, char*& characterBuffer);
     
    7071        return m_buffer ? m_buffer->data() : nullptr;
    7172    }
     73
     74    const uint8_t* dataAsUInt8Ptr() const { return reinterpret_cast<const uint8_t*>(data()); }
     75
    7276    WTF_EXPORT_PRIVATE char* mutableData();
    7377    size_t length() const
  • trunk/Source/WTF/wtf/text/WTFString.cpp

    r278146 r278619  
    661661
    662662    if (is8Bit())
    663         return CString(reinterpret_cast<const char*>(this->characters8()), length);
     663        return CString(this->characters8(), length);
    664664
    665665    const UChar* characters = this->characters16();
  • trunk/Source/WTF/wtf/text/cf/StringImplCF.cpp

    r274324 r278619  
    120120    if (!m_length || !isMainThread()) {
    121121        if (is8Bit())
    122             return adoptCF(CFStringCreateWithBytes(nullptr, reinterpret_cast<const UInt8*>(characters8()), m_length, kCFStringEncodingISOLatin1, false));
     122            return adoptCF(CFStringCreateWithBytes(nullptr, characters8(), m_length, kCFStringEncodingISOLatin1, false));
    123123        return adoptCF(CFStringCreateWithCharacters(nullptr, reinterpret_cast<const UniChar*>(characters16()), m_length));
    124124    }
     
    131131    RetainPtr<CFStringRef> string;
    132132    if (is8Bit())
    133         string = adoptCF(CFStringCreateWithBytesNoCopy(allocator, reinterpret_cast<const UInt8*>(characters8()), m_length, kCFStringEncodingISOLatin1, false, kCFAllocatorNull));
     133        string = adoptCF(CFStringCreateWithBytesNoCopy(allocator, characters8(), m_length, kCFStringEncodingISOLatin1, false, kCFAllocatorNull));
    134134    else
    135135        string = adoptCF(CFStringCreateWithCharactersNoCopy(allocator, reinterpret_cast<const UniChar*>(characters16()), m_length, kCFAllocatorNull));
  • trunk/Source/WebCore/ChangeLog

    r278618 r278619  
     12021-06-08  Chris Dumez  <cdumez@apple.com>
     2
     3        Reduce use of reinterpret_cast<> in the codebase
     4        https://bugs.webkit.org/show_bug.cgi?id=226743
     5
     6        Reviewed by Darin Adler.
     7
     8        * Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp:
     9        (WebCore::CDMSessionClearKey::generateKeyRequest):
     10        * Modules/fetch/FetchBody.cpp:
     11        (WebCore::FetchBody::take):
     12        * Modules/fetch/FetchBodyConsumer.cpp:
     13        (WebCore::FetchBodyConsumer::resolve):
     14        (WebCore::FetchBodyConsumer::takeAsBlob):
     15        (WebCore::FetchBodyConsumer::takeAsText):
     16        * Modules/mediastream/RTCDataChannelRemoteHandler.cpp:
     17        (WebCore::RTCDataChannelRemoteHandler::readyToSend):
     18        (WebCore::RTCDataChannelRemoteHandler::sendStringData):
     19        (WebCore::RTCDataChannelRemoteHandler::sendRawData):
     20        * Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp:
     21        (WebCore::copyBusData):
     22        * Modules/webauthn/AuthenticatorResponseData.h:
     23        (WebCore::encodeArrayBuffer):
     24        (WebCore::decodeArrayBuffer):
     25        * Modules/websockets/WebSocketChannel.cpp:
     26        (WebCore::WebSocketChannel::startClosingHandshake):
     27        (WebCore::WebSocketChannel::processOutgoingFrameQueue):
     28        * Modules/websockets/WebSocketHandshake.cpp:
     29        (WebCore::WebSocketHandshake::getExpectedWebSocketAccept):
     30        (WebCore::headerHasValidHTTPVersion):
     31        * bindings/js/ScriptBufferSourceProvider.h:
     32        * bindings/js/SerializedScriptValue.cpp:
     33        (WebCore::CloneDeserializer::readString):
     34        * contentextensions/SerializedNFA.cpp:
     35        (WebCore::ContentExtensions::SerializedNFA::pointerAtOffsetInFile const):
     36        * dom/Node.cpp:
     37        (WebCore::hashPointer):
     38        * dom/TextEncoder.cpp:
     39        (WebCore::TextEncoder::encode const):
     40        * dom/TextEncoderStreamEncoder.cpp:
     41        (WebCore::TextEncoderStreamEncoder::flush):
     42        * editing/cocoa/WebContentReaderCocoa.mm:
     43        (WebCore::sanitizeMarkupWithArchive):
     44        * html/canvas/WebGLRenderingContextBase.cpp:
     45        (WebCore::WebGLRenderingContextBase::texImageArrayBufferViewHelper):
     46        * inspector/DOMPatchSupport.cpp:
     47        (WebCore::addStringToSHA1):
     48        * loader/TextResourceDecoder.cpp:
     49        (WebCore::TextResourceDecoder::textFromUTF8):
     50        * loader/cache/CachedScript.cpp:
     51        (WebCore::CachedScript::script):
     52        * page/cocoa/ResourceUsageOverlayCocoa.mm:
     53        (WebCore::showText):
     54        * platform/SharedBufferChunkReader.cpp:
     55        (WebCore::SharedBufferChunkReader::nextChunk):
     56        * platform/cf/SharedBufferCF.cpp:
     57        (WebCore::SharedBuffer::createCFData const):
     58        * platform/generic/KeyedEncoderGeneric.cpp:
     59        (WebCore::KeyedEncoderGeneric::encodeString):
     60        * platform/graphics/GraphicsContextGL.cpp:
     61        (WebCore::GraphicsContextGL::packImageData):
     62        * platform/graphics/ImageBufferBackend.cpp:
     63        (WebCore::ImageBufferBackend::getPixelBuffer const):
     64        (WebCore::ImageBufferBackend::putPixelBuffer):
     65        * platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp:
     66        (WebCore::InbandTextTrackPrivateAVF::processNativeSamples):
     67        * platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp:
     68        (WebCore::CDMSessionAVFoundationCF::generateKeyRequest):
     69        (WebCore::CDMSessionAVFoundationCF::update):
     70        * platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp:
     71        (WebCore::InbandTextTrackPrivateAVCF::readNativeSampleBuffer):
     72        * platform/graphics/displaylists/DisplayListItemBuffer.cpp:
     73        (WebCore::DisplayList::ItemBuffer::createItemBuffer):
     74        * platform/graphics/displaylists/DisplayListIterator.cpp:
     75        (WebCore::DisplayList::DisplayList::Iterator::updateCurrentItem):
     76        * platform/image-decoders/gif/GIFImageReader.h:
     77        (GIFImageReader::data const):
     78        * platform/mac/SSLKeyGeneratorMac.mm:
     79        (WebCore::signedPublicKeyAndChallengeString):
     80        * platform/mediastream/RealtimeMediaSourceCenter.cpp:
     81        (WebCore::addStringToSHA1):
     82        * platform/network/FormDataBuilder.cpp:
     83        (WebCore::FormDataBuilder::encodeStringAsFormData):
     84        * platform/network/SocketStreamHandle.cpp:
     85        (WebCore::SocketStreamHandle::sendHandshake):
     86        * platform/network/cf/ResourceRequestCFNet.cpp:
     87        (WebCore::ResourceRequest::doUpdatePlatformRequest):
     88        * platform/network/cf/ResourceRequestCFNet.h:
     89        (WebCore::httpHeaderValueUsingSuitableEncoding):
     90        * platform/network/cf/SocketStreamHandleImplCFNet.cpp:
     91        (WebCore::SocketStreamHandleImpl::platformSendInternal):
     92        * platform/network/curl/CurlCacheEntry.cpp:
     93        (WebCore::CurlCacheEntry::generateBaseFilename):
     94        * platform/sql/SQLiteStatement.cpp:
     95        (WebCore::SQLiteStatement::columnBlobView):
     96        * testing/MockCDMFactory.cpp:
     97        (WebCore::MockCDM::sanitizeResponse const):
     98
    1992021-06-08  Devin Rousso  <drousso@apple.com>
    2100
  • trunk/Source/WebCore/Modules/encryptedmedia/legacy/LegacyCDMSessionClearKey.cpp

    r277740 r278619  
    7171
    7272    bool sawError = false;
    73     String keyID = UTF8Encoding().decode(reinterpret_cast_ptr<char*>(m_initData->baseAddress()), m_initData->byteLength(), true, sawError);
     73    String keyID = UTF8Encoding().decode(static_cast<char*>(m_initData->baseAddress()), m_initData->byteLength(), true, sawError);
    7474    if (sawError) {
    7575        errorCode = WebKitMediaKeyError::MEDIA_KEYERR_CLIENT;
  • trunk/Source/WebCore/Modules/fetch/FetchBody.cpp

    r278516 r278619  
    305305
    306306    if (isArrayBuffer())
    307         return SharedBuffer::create(reinterpret_cast<const char*>(arrayBufferBody().data()), arrayBufferBody().byteLength());
     307        return SharedBuffer::create(static_cast<const char*>(arrayBufferBody().data()), arrayBufferBody().byteLength());
    308308    if (isArrayBufferView())
    309         return SharedBuffer::create(reinterpret_cast<const uint8_t*>(arrayBufferViewBody().baseAddress()), arrayBufferViewBody().byteLength());
     309        return SharedBuffer::create(static_cast<const uint8_t*>(arrayBufferViewBody().baseAddress()), arrayBufferViewBody().byteLength());
    310310
    311311    return nullptr;
  • trunk/Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp

    r278532 r278619  
    279279                data->append(chunk->data, chunk->size);
    280280            else
    281                 resolveWithTypeAndData(WTFMove(promise), type, contentType, reinterpret_cast<const unsigned char*>(data->data()), data->size());
     281                resolveWithTypeAndData(WTFMove(promise), type, contentType, data->data(), data->size());
    282282        });
    283283        m_sink->pipeFrom(*stream);
     
    356356
    357357    // FIXME: We should try to move m_buffer to Blob without doing extra copy.
    358     return blobFromData(context, reinterpret_cast<const unsigned char*>(m_buffer->data()), m_buffer->size(), m_contentType);
     358    return blobFromData(context, m_buffer->data(), m_buffer->size(), m_contentType);
    359359}
    360360
     
    365365        return String();
    366366
    367     auto text = TextResourceDecoder::textFromUTF8(reinterpret_cast<const unsigned char*>(m_buffer->data()), m_buffer->size());
     367    auto text = TextResourceDecoder::textFromUTF8(m_buffer->data(), m_buffer->size());
    368368    m_buffer = nullptr;
    369369    return text;
  • trunk/Source/WebCore/Modules/mediastream/RTCDataChannelRemoteHandler.cpp

    r278516 r278619  
    8181
    8282    for (auto& message : m_pendingMessages)
    83         m_connection->sendData(m_remoteIdentifier, message.isRaw, reinterpret_cast<const unsigned char*>(message.buffer->data()), message.buffer->size());
     83        m_connection->sendData(m_remoteIdentifier, message.isRaw, message.buffer->data(), message.buffer->size());
    8484    m_pendingMessages.clear();
    8585
     
    101101        return true;
    102102    }
    103     m_connection->sendData(m_remoteIdentifier, false, reinterpret_cast<const unsigned char*>(text.data()), text.length());
     103    m_connection->sendData(m_remoteIdentifier, false, text.dataAsUInt8Ptr(), text.length());
    104104    return true;
    105105}
     
    111111        return true;
    112112    }
    113     m_connection->sendData(m_remoteIdentifier, true, reinterpret_cast<const unsigned char*>(data), size);
     113    m_connection->sendData(m_remoteIdentifier, true, data, size);
    114114    return true;
    115115}
  • trunk/Source/WebCore/Modules/webaudio/MediaStreamAudioSourceGStreamer.cpp

    r275510 r278619  
    4444    for (size_t channelIndex = 0; channelIndex < bus.numberOfChannels(); ++channelIndex) {
    4545        const auto& channel = *bus.channel(channelIndex);
    46         auto offset = reinterpret_cast<size_t>(channelIndex * size);
    47         memcpy(reinterpret_cast<float*>(mappedBuffer.data() + offset), channel.data(), sizeof(float) * channel.length());
     46        auto offset = channelIndex * size;
     47        memcpy(mappedBuffer.data() + offset, channel.data(), sizeof(float) * channel.length());
    4848        offsets.uncheckedAppend(offset);
    4949    }
  • trunk/Source/WebCore/Modules/webauthn/AuthenticatorResponseData.h

    r278253 r278619  
    6060{
    6161    encoder << static_cast<uint64_t>(buffer.byteLength());
    62     encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(buffer.data()), buffer.byteLength(), 1);
     62    encoder.encodeFixedLengthData(static_cast<const uint8_t*>(buffer.data()), buffer.byteLength(), 1);
    6363}
    6464
     
    7676    if (!buffer)
    7777        return nullptr;
    78     if (!decoder.decodeFixedLengthData(reinterpret_cast<uint8_t*>(buffer->data()), length.value(), 1))
     78    if (!decoder.decodeFixedLengthData(static_cast<uint8_t*>(buffer->data()), length.value(), 1))
    7979        return nullptr;
    8080    return buffer;
  • trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp

    r278532 r278619  
    496496        buf.append(lowByte);
    497497        auto reasonUTF8 = reason.utf8();
    498         buf.append(reinterpret_cast<const uint8_t*>(reasonUTF8.data()), reasonUTF8.length());
     498        buf.append(reasonUTF8.dataAsUInt8Ptr(), reasonUTF8.length());
    499499    }
    500500    enqueueRawFrame(WebSocketFrame::OpCodeClose, buf.data(), buf.size());
     
    744744        switch (frame->frameType) {
    745745        case QueuedFrameTypeString: {
    746             sendFrame(frame->opCode, reinterpret_cast<const uint8_t*>(frame->stringData.data()), frame->stringData.length(), [this, protectedThis = makeRef(*this)] (bool success) {
     746            sendFrame(frame->opCode, frame->stringData.dataAsUInt8Ptr(), frame->stringData.length(), [this, protectedThis = makeRef(*this)] (bool success) {
    747747                if (!success)
    748748                    fail("Failed to send WebSocket frame.");
  • trunk/Source/WebCore/Modules/websockets/WebSocketHandshake.cpp

    r278532 r278619  
    103103String WebSocketHandshake::getExpectedWebSocketAccept(const String& secWebSocketKey)
    104104{
    105     static const char* const webSocketKeyGUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
     105    constexpr uint8_t webSocketKeyGUID[] = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
    106106    SHA1 sha1;
    107107    CString keyData = secWebSocketKey.ascii();
    108     sha1.addBytes(reinterpret_cast<const uint8_t*>(keyData.data()), keyData.length());
    109     sha1.addBytes(reinterpret_cast<const uint8_t*>(webSocketKeyGUID), strlen(webSocketKeyGUID));
     108    sha1.addBytes(keyData.dataAsUInt8Ptr(), keyData.length());
     109    sha1.addBytes(webSocketKeyGUID, std::size(webSocketKeyGUID) - 1);
    110110    SHA1::Digest hash;
    111111    sha1.computeHash(hash);
     
    329329static inline bool headerHasValidHTTPVersion(StringView httpStatusLine)
    330330{
    331     const char* httpVersionStaticPreambleLiteral = "HTTP/";
    332     StringView httpVersionStaticPreamble(reinterpret_cast<const LChar*>(httpVersionStaticPreambleLiteral), strlen(httpVersionStaticPreambleLiteral));
    333     if (!httpStatusLine.startsWith(httpVersionStaticPreamble))
     331    constexpr char preamble[] = "HTTP/";
     332    if (!httpStatusLine.startsWith(preamble))
    334333        return false;
    335334
    336335    // Check that there is a version number which should be at least three characters after "HTTP/"
    337     unsigned preambleLength = httpVersionStaticPreamble.length();
     336    unsigned preambleLength = strlen(preamble);
    338337    if (httpStatusLine.length() < preambleLength + 3)
    339338        return false;
  • trunk/Source/WebCore/bindings/js/ScriptBufferSourceProvider.h

    r278253 r278619  
    5353
    5454        if (!m_containsOnlyASCII) {
    55             m_containsOnlyASCII = charactersAreAllASCII(reinterpret_cast<const LChar*>(m_scriptBuffer.buffer()->data()), m_scriptBuffer.buffer()->size());
     55            m_containsOnlyASCII = charactersAreAllASCII(m_scriptBuffer.buffer()->data(), m_scriptBuffer.buffer()->size());
    5656            if (*m_containsOnlyASCII)
    57                 m_scriptHash = StringHasher::computeHashAndMaskTop8Bits(reinterpret_cast<const LChar*>(m_scriptBuffer.buffer()->data()), m_scriptBuffer.buffer()->size());
     57                m_scriptHash = StringHasher::computeHashAndMaskTop8Bits(m_scriptBuffer.buffer()->data(), m_scriptBuffer.buffer()->size());
    5858        }
    5959        if (*m_containsOnlyASCII)
    60             return { reinterpret_cast<const LChar*>(m_scriptBuffer.buffer()->data()), static_cast<unsigned>(m_scriptBuffer.buffer()->size()) };
     60            return { m_scriptBuffer.buffer()->data(), static_cast<unsigned>(m_scriptBuffer.buffer()->size()) };
    6161
    6262        if (!m_cachedScriptString) {
  • trunk/Source/WebCore/bindings/js/SerializedScriptValue.cpp

    r278338 r278619  
    23412341            if ((end - ptr) < static_cast<int>(length))
    23422342                return false;
    2343             str = String(reinterpret_cast<const LChar*>(ptr), length);
     2343            str = String { ptr, length };
    23442344            ptr += length;
    23452345            return true;
  • trunk/Source/WebCore/contentextensions/SerializedNFA.cpp

    r278532 r278619  
    108108const T* SerializedNFA::pointerAtOffsetInFile(size_t offset) const
    109109{
    110     return reinterpret_cast<const T*>(reinterpret_cast<const uint8_t*>(m_file.data()) + offset);
     110    return reinterpret_cast<const T*>(static_cast<const uint8_t*>(m_file.data()) + offset);
    111111}
    112112
  • trunk/Source/WebCore/dom/Node.cpp

    r278058 r278619  
    16011601}
    16021602
    1603 static SHA1::Digest hashPointer(void* pointer)
     1603static SHA1::Digest hashPointer(const void* pointer)
    16041604{
    16051605    SHA1 sha1;
  • trunk/Source/WebCore/dom/TextEncoder.cpp

    r266621 r278619  
    4141    // FIXME: We should not need to allocate a CString to encode into a Uint8Array.
    4242    CString utf8 = input.utf8();
    43     return Uint8Array::tryCreate(reinterpret_cast<const uint8_t*>(utf8.data()), utf8.length());
     43    return Uint8Array::tryCreate(utf8.dataAsUInt8Ptr(), utf8.length());
    4444}
    4545
  • trunk/Source/WebCore/dom/TextEncoderStreamEncoder.cpp

    r278516 r278619  
    7878        return nullptr;
    7979
    80     auto byteSequence = "\xEF\xBF\xBD";
    81     return Uint8Array::tryCreate(reinterpret_cast<const uint8_t*>(byteSequence), 3);
     80    constexpr uint8_t byteSequence[] = { 0xEF, 0xBF, 0xBD };
     81    return Uint8Array::tryCreate(byteSequence, std::size(byteSequence));
    8282}
    8383
  • trunk/Source/WebCore/editing/cocoa/WebContentReaderCocoa.mm

    r278253 r278619  
    487487        Vector<uint8_t> blobBuffer;
    488488        blobBuffer.reserveCapacity(utf8.length());
    489         blobBuffer.append(reinterpret_cast<const uint8_t*>(utf8.data()), utf8.length());
     489        blobBuffer.append(utf8.dataAsUInt8Ptr(), utf8.length());
    490490        auto blob = Blob::create(&destinationDocument, WTFMove(blobBuffer), type);
    491491
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp

    r278351 r278619  
    49634963    if (!validateTexFuncData(functionName, sourceType, width, height, depth, format, type, pixels.get(), nullDisposition, srcOffset))
    49644964        return;
    4965     uint8_t* data = reinterpret_cast<uint8_t*>(pixels ? pixels->baseAddress() : nullptr);
     4965    auto data = static_cast<uint8_t*>(pixels ? pixels->baseAddress() : nullptr);
    49664966    if (srcOffset) {
    49674967        ASSERT(pixels);
  • trunk/Source/WebCore/inspector/DOMPatchSupport.cpp

    r277740 r278619  
    398398{
    399399    CString cString = string.utf8();
    400     sha1.addBytes(reinterpret_cast<const uint8_t*>(cString.data()), cString.length());
     400    sha1.addBytes(cString.dataAsUInt8Ptr(), cString.length());
    401401}
    402402
  • trunk/Source/WebCore/loader/TextResourceDecoder.cpp

    r263022 r278619  
    334334    if (shouldPrependBOM(data, length))
    335335        decoder->decode("\xef\xbb\xbf", 3);
    336     return decoder->decodeAndFlush(reinterpret_cast<const char*>(data), length);
     336    return decoder->decodeAndFlush(data, length);
    337337}
    338338
  • trunk/Source/WebCore/loader/cache/CachedScript.cpp

    r261597 r278619  
    6363        && TextEncoding(encoding()).isByteBasedEncoding()
    6464        && m_data->size()
    65         && charactersAreAllASCII(reinterpret_cast<const LChar*>(m_data->data()), m_data->size())) {
     65        && charactersAreAllASCII(m_data->data(), m_data->size())) {
    6666
    6767        m_decodingState = DataAndDecodedStringHaveSameBytes;
     
    7171        m_decodedDataDeletionTimer.stop();
    7272
    73         m_scriptHash = StringHasher::computeHashAndMaskTop8Bits(reinterpret_cast<const LChar*>(m_data->data()), m_data->size());
     73        m_scriptHash = StringHasher::computeHashAndMaskTop8Bits(m_data->data(), m_data->size());
    7474    }
    7575
    7676    if (m_decodingState == DataAndDecodedStringHaveSameBytes)
    77         return { reinterpret_cast<const LChar*>(m_data->data()), static_cast<unsigned>(m_data->size()) };
     77        return { m_data->data(), static_cast<unsigned>(m_data->size()) };
    7878
    7979    if (!m_script) {
  • trunk/Source/WebCore/page/cocoa/ResourceUsageOverlayCocoa.mm

    r277967 r278619  
    270270    auto attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
    271271    CString cstr = text.ascii();
    272     auto string = adoptCF(CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(cstr.data()), cstr.length(), kCFStringEncodingASCII, false, kCFAllocatorNull));
     272    auto string = adoptCF(CFStringCreateWithBytesNoCopy(kCFAllocatorDefault, cstr.dataAsUInt8Ptr(), cstr.length(), kCFStringEncodingASCII, false, kCFAllocatorNull));
    273273    auto attributedString = adoptCF(CFAttributedStringCreate(kCFAllocatorDefault, string.get(), attributes.get()));
    274274    auto line = adoptCF(CTLineCreateWithAttributedString(attributedString.get()));
  • trunk/Source/WebCore/platform/cf/SharedBufferCF.cpp

    r217260 r278619  
    4848            return *data;
    4949    }
    50     return adoptCF(CFDataCreate(nullptr, reinterpret_cast<const UInt8*>(data()), size()));
     50    return adoptCF(CFDataCreate(nullptr, data(), size()));
    5151}
    5252#endif
  • trunk/Source/WebCore/platform/generic/KeyedEncoderGeneric.cpp

    r248846 r278619  
    4141    auto utf8 = key.utf8();
    4242    m_encoder << utf8.length();
    43     m_encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(utf8.data()), utf8.length());
     43    m_encoder.encodeFixedLengthData(utf8.dataAsUInt8Ptr(), utf8.length());
    4444}
    4545
  • trunk/Source/WebCore/platform/graphics/GraphicsContextGL.cpp

    r278351 r278619  
    758758    data.resize(packedSize);
    759759
    760     if (!packPixels(reinterpret_cast<const uint8_t*>(pixels), sourceFormat, sourceImageWidth, sourceImageHeight, sourceImageSubRectangle, depth, sourceUnpackAlignment, unpackImageHeight, format, type, alphaOp, data.data(), flipY))
     760    if (!packPixels(static_cast<const uint8_t*>(pixels), sourceFormat, sourceImageWidth, sourceImageHeight, sourceImageSubRectangle, depth, sourceUnpackAlignment, unpackImageHeight, format, type, alphaOp, data.data(), flipY))
    761761        return false;
    762762    if (ImageObserver* observer = image->imageObserver())
  • trunk/Source/WebCore/platform/graphics/ImageBufferBackend.cpp

    r278338 r278619  
    119119        { AlphaPremultiplication::Premultiplied, pixelFormat(), colorSpace() },
    120120        bytesPerRow(),
    121         reinterpret_cast<uint8_t*>(data) + sourceRectClipped.y() * source.bytesPerRow + sourceRectClipped.x() * 4
     121        static_cast<uint8_t*>(data) + sourceRectClipped.y() * source.bytesPerRow + sourceRectClipped.x() * 4
    122122    };
    123123   
     
    160160        { destinationAlphaFormat, pixelFormat(), colorSpace() },
    161161        bytesPerRow(),
    162         reinterpret_cast<uint8_t*>(data) + destinationRect.y() * destination.bytesPerRow + destinationRect.x() * 4
     162        static_cast<uint8_t*>(data) + destinationRect.y() * destination.bytesPerRow + destinationRect.x() * 4
    163163    };
    164164
  • trunk/Source/WebCore/platform/graphics/avfoundation/InbandTextTrackPrivateAVF.cpp

    r278253 r278619  
    531531            // A WebVTT header is terminated by "One or more WebVTT line terminators" so append two line feeds to make sure the parser
    532532            // reccognized this string as a full header.
    533             StringBuilder header;
    534             header.appendCharacters(reinterpret_cast<const unsigned char*>(CFDataGetBytePtr(webvttHeaderData)), length);
    535             header.append("\n\n");
    536 
    537             INFO_LOG(LOGIDENTIFIER, "VTT header ", &header);
    538             client()->parseWebVTTFileHeader(header.toString());
     533            auto header = makeString(StringView { CFDataGetBytePtr(webvttHeaderData), length }, "\n\n");
     534
     535            INFO_LOG(LOGIDENTIFIER, "VTT header ", header);
     536            client()->parseWebVTTFileHeader(WTFMove(header));
    539537            m_haveReportedVTTHeader = true;
    540538        } while (0);
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/CDMSessionAVFoundationCF.cpp

    r237009 r278619  
    7575
    7676    auto certificateData = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, certificate->byteLength()));
    77     CFDataAppendBytes(certificateData.get(), reinterpret_cast<const UInt8*>(certificate->baseAddress()), certificate->byteLength());
     77    CFDataAppendBytes(certificateData.get(), certificate->data(), certificate->byteLength());
    7878
    7979    auto assetStr = keyID.utf8();
    8080    auto assetID = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, assetStr.length()));
    81     CFDataAppendBytes(assetID.get(), reinterpret_cast<const UInt8*>(assetStr.data()), assetStr.length());
     81    CFDataAppendBytes(assetID.get(), assetStr.dataAsUIntPtr(), assetStr.length());
    8282
    8383    CFErrorRef cfError = nullptr;
     
    111111{
    112112    auto keyData = adoptCF(CFDataCreateMutable(kCFAllocatorDefault, key->byteLength()));
    113     CFDataAppendBytes(keyData.get(), reinterpret_cast<const UInt8*>(key->baseAddress()), key->byteLength());
     113    CFDataAppendBytes(keyData.get(), key->data(), key->byteLength());
    114114
    115115    AVCFAssetResourceLoadingRequestFinishLoadingWithResponse(m_request.get(), nullptr, keyData.get(), nullptr);
  • trunk/Source/WebCore/platform/graphics/avfoundation/cf/InbandTextTrackPrivateAVCF.cpp

    r256353 r278619  
    205205
    206206    m_sampleInputBuffer.grow(m_sampleInputBuffer.size() + bufferLength);
    207     CFDataGetBytes(sampleBuffer->buffer, CFRangeMake(0, bufferLength), reinterpret_cast<UInt8*>(m_sampleInputBuffer.data()) + m_sampleInputBuffer.size() - bufferLength);
     207    CFDataGetBytes(sampleBuffer->buffer, CFRangeMake(0, bufferLength), m_sampleInputBuffer.data() + m_sampleInputBuffer.size() - bufferLength);
    208208
    209209    buffer = ArrayBuffer::create(m_sampleInputBuffer.data(), m_sampleInputBuffer.size());
  • trunk/Source/WebCore/platform/graphics/displaylists/DisplayListItemBuffer.cpp

    r278516 r278619  
    703703
    704704    auto newBufferCapacity = std::max(capacity, defaultItemBufferCapacity);
    705     auto* buffer = reinterpret_cast<uint8_t*>(fastMalloc(newBufferCapacity));
     705    auto* buffer = static_cast<uint8_t*>(fastMalloc(newBufferCapacity));
    706706    m_allocatedBuffers.append(buffer);
    707707    return { ItemBufferIdentifier::generate(), buffer, newBufferCapacity };
  • trunk/Source/WebCore/platform/graphics/displaylists/DisplayListIterator.cpp

    r278185 r278619  
    8080
    8181    auto paddedSizeOfTypeAndItem = paddedSizeOfTypeAndItemInBytes(itemType);
    82     m_currentBufferForItem = paddedSizeOfTypeAndItem <= sizeOfFixedBufferForCurrentItem ? m_fixedBufferForCurrentItem : reinterpret_cast<uint8_t*>(fastMalloc(paddedSizeOfTypeAndItem));
     82    m_currentBufferForItem = paddedSizeOfTypeAndItem <= sizeOfFixedBufferForCurrentItem ? m_fixedBufferForCurrentItem : static_cast<uint8_t*>(fastMalloc(paddedSizeOfTypeAndItem));
    8383    if (isInlineItem(itemType)) {
    8484        if (UNLIKELY(static_cast<uint64_t>(m_currentEndOfBuffer - m_cursor) < paddedSizeOfTypeAndItem)) {
  • trunk/Source/WebCore/platform/image-decoders/gif/GIFImageReader.h

    r251836 r278619  
    286286    void setRemainingBytes(size_t);
    287287
    288     const unsigned char* data(size_t dataPosition) const
    289     {
    290         return reinterpret_cast<const unsigned char*>(m_data->data()) + dataPosition;
     288    const uint8_t* data(size_t dataPosition) const
     289    {
     290        return m_data->data() + dataPosition;
    291291    }
    292292
  • trunk/Source/WebCore/platform/mac/SSLKeyGeneratorMac.mm

    r277740 r278619  
    190190    // Length needs to account for the null terminator.
    191191    signedPublicKeyAndChallenge.publicKeyAndChallenge.challenge.Length = challenge.length() + 1;
    192     signedPublicKeyAndChallenge.publicKeyAndChallenge.challenge.Data = reinterpret_cast<uint8_t*>(const_cast<char*>(challenge.data()));
     192    signedPublicKeyAndChallenge.publicKeyAndChallenge.challenge.Data = const_cast<uint8_t*>(challenge.dataAsUInt8Ptr());
    193193
    194194    CSSM_DATA encodedPublicKeyAndChallenge { 0, nullptr };
  • trunk/Source/WebCore/platform/mediastream/RealtimeMediaSourceCenter.cpp

    r277361 r278619  
    146146
    147147    auto utf8 = string.utf8();
    148     sha1.addBytes(reinterpret_cast<const uint8_t*>(utf8.data()), utf8.length() + 1); // Include terminating null byte.
     148    sha1.addBytes(utf8.dataAsUInt8Ptr(), utf8.length() + 1); // Include terminating null byte.
    149149}
    150150
  • trunk/Source/WebCore/platform/network/FormDataBuilder.cpp

    r266187 r278619  
    212212void encodeStringAsFormData(Vector<char>& buffer, const CString& string)
    213213{
    214     appendFormURLEncoded(buffer, reinterpret_cast<const uint8_t*>(string.data()), string.length());
    215 }
    216 
    217 }
    218 
    219 }
     214    appendFormURLEncoded(buffer, string.dataAsUInt8Ptr(), string.length());
     215}
     216
     217}
     218
     219}
  • trunk/Source/WebCore/platform/network/SocketStreamHandle.cpp

    r278532 r278619  
    6262    if (m_state == Connecting || m_state == Closing)
    6363        return completionHandler(false, false);
    64     platformSendHandshake(reinterpret_cast<const uint8_t*>(handshake.data()), handshake.length(), WTFMove(headerFieldProxy), WTFMove(completionHandler));
     64    platformSendHandshake(handshake.dataAsUInt8Ptr(), handshake.length(), WTFMove(headerFieldProxy), WTFMove(completionHandler));
    6565}
    6666
  • trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.cpp

    r274252 r278619  
    229229    if (!partition.isNull() && !partition.isEmpty()) {
    230230        CString utf8String = partition.utf8();
    231         RetainPtr<CFStringRef> partitionValue = adoptCF(CFStringCreateWithBytes(0, reinterpret_cast<const UInt8*>(utf8String.data()), utf8String.length(), kCFStringEncodingUTF8, false));
     231        RetainPtr<CFStringRef> partitionValue = adoptCF(CFStringCreateWithBytes(0, utf8String.dataAsUInt8Ptr(), utf8String.length(), kCFStringEncodingUTF8, false));
    232232        _CFURLRequestSetProtocolProperty(cfRequest.get(), _kCFURLCachePartitionKey, partitionValue.get());
    233233    }
  • trunk/Source/WebCore/platform/network/cf/ResourceRequestCFNet.h

    r274180 r278619  
    132132        auto utf8Value = header.value.utf8();
    133133        // Constructing a string with the UTF-8 bytes but claiming that it’s Latin-1 is the way to get CFNetwork to put those UTF-8 bytes on the wire.
    134         return adoptCF(CFStringCreateWithBytes(nullptr, reinterpret_cast<const UInt8*>(utf8Value.data()), utf8Value.length(), kCFStringEncodingISOLatin1, false));
     134        return adoptCF(CFStringCreateWithBytes(nullptr, utf8Value.dataAsUInt8Ptr(), utf8Value.length(), kCFStringEncodingISOLatin1, false));
    135135    }
    136136    return header.value.createCFString();
  • trunk/Source/WebCore/platform/network/cf/SocketStreamHandleImplCFNet.cpp

    r278532 r278619  
    723723        return 0;
    724724
    725     CFIndex result = CFWriteStreamWrite(m_writeStream.get(), reinterpret_cast<const UInt8*>(data), length);
     725    CFIndex result = CFWriteStreamWrite(m_writeStream.get(), data, length);
    726726    if (result == -1)
    727727        return std::nullopt;
  • trunk/Source/WebCore/platform/network/curl/CurlCacheEntry.cpp

    r278532 r278619  
    212212{
    213213    SHA1 sha1;
    214     sha1.addBytes(reinterpret_cast<const uint8_t*>(url.data()), url.length());
     214    sha1.addBytes(url.dataAsUInt8Ptr(), url.length());
    215215
    216216    SHA1::Digest sum;
  • trunk/Source/WebCore/platform/sql/SQLiteStatement.cpp

    r277920 r278619  
    305305        return { };
    306306
    307     return { reinterpret_cast<const uint8_t*>(blob), static_cast<size_t>(blobSize) };
     307    return { static_cast<const uint8_t*>(blob), static_cast<size_t>(blobSize) };
    308308}
    309309
  • trunk/Source/WebCore/testing/MockCDMFactory.cpp

    r278253 r278619  
    214214RefPtr<SharedBuffer> MockCDM::sanitizeResponse(const SharedBuffer& response) const
    215215{
    216     if (!charactersAreAllASCII(reinterpret_cast<const LChar*>(response.data()), response.size()))
     216    if (!charactersAreAllASCII(response.data(), response.size()))
    217217        return nullptr;
    218218
  • trunk/Source/WebDriver/ChangeLog

    r278340 r278619  
     12021-06-08  Chris Dumez  <cdumez@apple.com>
     2
     3        Reduce use of reinterpret_cast<> in the codebase
     4        https://bugs.webkit.org/show_bug.cgi?id=226743
     5
     6        Reviewed by Darin Adler.
     7
     8        * socket/HTTPParser.cpp:
     9        (WebDriver::HTTPParser::readLine):
     10        * socket/SessionHostSocket.cpp:
     11        (WebDriver::SessionHost::sendWebInspectorEvent):
     12
    1132021-06-01  Darin Adler  <darin@apple.com>
    214
  • trunk/Source/WebDriver/socket/HTTPParser.cpp

    r278185 r278619  
    131131        return false;
    132132
    133     line = String::fromUTF8(reinterpret_cast<char*>(m_buffer.data()), position);
     133    line = String::fromUTF8(m_buffer.data(), position);
    134134    if (line.isNull())
    135135        LOG_ERROR("Client error: invalid encoding in HTTP header.");
  • trunk/Source/WebDriver/socket/SessionHostSocket.cpp

    r278253 r278619  
    5151
    5252    const CString message = event.utf8();
    53     send(m_clientID.value(), reinterpret_cast<const uint8_t*>(message.data()), message.length());
     53    send(m_clientID.value(), message.dataAsUInt8Ptr(), message.length());
    5454}
    5555
  • trunk/Source/WebKit/ChangeLog

    r278614 r278619  
     12021-06-08  Chris Dumez  <cdumez@apple.com>
     2
     3        Reduce use of reinterpret_cast<> in the codebase
     4        https://bugs.webkit.org/show_bug.cgi?id=226743
     5
     6        Reviewed by Darin Adler.
     7
     8        * GPUProcess/media/RemoteMediaPlayerProxy.cpp:
     9        (WebKit::RemoteMediaPlayerProxy::mediaPlayerInitializationDataEncountered):
     10        * GPUProcess/media/RemoteTextTrackProxy.cpp:
     11        (WebKit::RemoteTextTrackProxy::addDataCue):
     12        * GPUProcess/webrtc/RemoteMediaRecorder.cpp:
     13        (WebKit::RemoteMediaRecorder::fetchData):
     14        * NetworkProcess/cache/NetworkCacheDataCurl.cpp:
     15        (WebKit::NetworkCache::Data::apply const):
     16        * NetworkProcess/cache/NetworkCacheKey.cpp:
     17        (WebKit::NetworkCache::hashString):
     18        * NetworkProcess/soup/WebKitDirectoryInputStream.cpp:
     19        (webkitDirectoryInputStreamRead):
     20        * Platform/IPC/ArgumentCoders.cpp:
     21        (IPC::ArgumentCoder<CString>::encode):
     22        (IPC::ArgumentCoder<String>::encode):
     23        * Shared/API/c/cf/WKStringCF.mm:
     24        (WKStringCopyCFString):
     25        * Shared/API/c/cf/WKURLCF.mm:
     26        (WKURLCopyCFURL):
     27        * Shared/ShareableResource.cpp:
     28        (WebKit::ShareableResource::wrapInSharedBuffer):
     29        * Shared/SharedDisplayListHandle.h:
     30        (WebKit::SharedDisplayListHandle::data const):
     31        * Shared/WebCompiledContentRuleList.cpp:
     32        (WebKit::WebCompiledContentRuleList::conditionsApplyOnlyToDomain const):
     33        * UIProcess/API/APIWebAuthenticationAssertionResponse.cpp:
     34        (API::WebAuthenticationAssertionResponse::userHandle const):
     35        * UIProcess/API/C/WKPage.cpp:
     36        (dataFrom):
     37        * UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.mm:
     38        (WebKit::RedirectSOAuthorizationSession::completeInternal):
     39        * UIProcess/Inspector/socket/RemoteInspectorClient.cpp:
     40        (WebKit::RemoteInspectorClient::sendWebInspectorEvent):
     41        * WebProcess/Network/WebSocketChannel.cpp:
     42        (WebKit::WebSocketChannel::createMessageQueue):
     43        (WebKit::WebSocketChannel::didReceiveText):
     44        * WebProcess/Network/webrtc/RTCDataChannelRemoteManager.cpp:
     45        (WebKit::RTCDataChannelRemoteManager::sendData):
     46        (WebKit::RTCDataChannelRemoteManager::RemoteSourceConnection::didReceiveStringData):
     47        * WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
     48        (WebKit::NetscapePluginStream::sendJavaScriptStream):
     49
    1502021-06-08  Devin Rousso  <drousso@apple.com>
    251
  • trunk/Source/WebKit/GPUProcess/media/RemoteMediaPlayerProxy.cpp

    r278253 r278619  
    692692void RemoteMediaPlayerProxy::mediaPlayerInitializationDataEncountered(const String& initDataType, RefPtr<ArrayBuffer>&& initData)
    693693{
    694     m_webProcessConnection->send(Messages::MediaPlayerPrivateRemote::InitializationDataEncountered(initDataType, IPC::DataReference(reinterpret_cast<uint8_t*>(initData->data()), initData->byteLength())), m_id);
     694    m_webProcessConnection->send(Messages::MediaPlayerPrivateRemote::InitializationDataEncountered(initDataType, IPC::DataReference(static_cast<uint8_t*>(initData->data()), initData->byteLength())), m_id);
    695695}
    696696
  • trunk/Source/WebKit/GPUProcess/media/RemoteTextTrackProxy.cpp

    r278532 r278619  
    114114        return;
    115115
    116     m_connectionToWebProcess->connection().send(Messages::MediaPlayerPrivateRemote::AddDataCue(m_identifier, start, end, IPC::DataReference(reinterpret_cast<const uint8_t*>(data), length)), m_mediaPlayerIdentifier);
     116    m_connectionToWebProcess->connection().send(Messages::MediaPlayerPrivateRemote::AddDataCue(m_identifier, start, end, IPC::DataReference(static_cast<const uint8_t*>(data), length)), m_mediaPlayerIdentifier);
    117117}
    118118
  • trunk/Source/WebKit/GPUProcess/webrtc/RemoteMediaRecorder.cpp

    r277728 r278619  
    108108{
    109109    m_writer->fetchData([completionHandler = WTFMove(completionHandler)](auto&& data, auto timeCode) mutable {
    110         auto* pointer = reinterpret_cast<const uint8_t*>(data ? data->data() : nullptr);
     110        auto* pointer = data ? data->data() : nullptr;
    111111        completionHandler(IPC::DataReference { pointer, data ? data->size() : 0 }, timeCode);
    112112    });
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheDataCurl.cpp

    r257518 r278619  
    7474        return false;
    7575
    76     return applier(reinterpret_cast<const uint8_t*>(data()), size());
     76    return applier(data(), size());
    7777}
    7878
  • trunk/Source/WebKit/NetworkProcess/cache/NetworkCacheKey.cpp

    r278253 r278619  
    9595    auto cString = string.utf8();
    9696    // Include terminating null byte.
    97     sha1.addBytes(reinterpret_cast<const uint8_t*>(cString.data()), cString.length() + 1);
     97    sha1.addBytes(cString.dataAsUInt8Ptr(), cString.length() + 1);
    9898}
    9999
  • trunk/Source/WebKit/NetworkProcess/soup/WebKitDirectoryInputStream.cpp

    r272409 r278619  
    152152        auto* bufferData = g_bytes_get_data(stream->priv->buffer.get(), &bufferSize);
    153153        gsize bytesRead = std::min(bufferSize, count - totalBytesRead);
    154         memcpy(reinterpret_cast<char*>(buffer) + totalBytesRead, bufferData, bytesRead);
     154        memcpy(static_cast<char*>(buffer) + totalBytesRead, bufferData, bytesRead);
    155155        if (bytesRead == bufferSize)
    156156            stream->priv->buffer = nullptr;
  • trunk/Source/WebKit/Platform/IPC/ArgumentCoders.cpp

    r278253 r278619  
    8383    uint32_t length = string.length();
    8484    encoder << length;
    85     encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.data()), length, 1);
     85    encoder.encodeFixedLengthData(string.dataAsUInt8Ptr(), length, 1);
    8686}
    8787
     
    126126
    127127    if (is8Bit)
    128         encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.characters8()), length * sizeof(LChar), alignof(LChar));
     128        encoder.encodeFixedLengthData(string.characters8(), length * sizeof(LChar), alignof(LChar));
    129129    else
    130130        encoder.encodeFixedLengthData(reinterpret_cast<const uint8_t*>(string.characters16()), length * sizeof(UChar), alignof(UChar));
  • trunk/Source/WebKit/Shared/API/c/cf/WKStringCF.mm

    r242339 r278619  
    5858    // expects to be called on the thread running WebCore.
    5959    if (WebKit::toImpl(stringRef)->string().is8Bit())
    60         return CFStringCreateWithBytes(allocatorRef, reinterpret_cast<const UInt8*>(WebKit::toImpl(stringRef)->string().characters8()), WebKit::toImpl(stringRef)->string().length(), kCFStringEncodingISOLatin1, true);
     60        return CFStringCreateWithBytes(allocatorRef, WebKit::toImpl(stringRef)->string().characters8(), WebKit::toImpl(stringRef)->string().length(), kCFStringEncodingISOLatin1, true);
    6161    return CFStringCreateWithCharacters(allocatorRef, reinterpret_cast<const UniChar*>(WebKit::toImpl(stringRef)->string().characters16()), WebKit::toImpl(stringRef)->string().length());
    6262}
  • trunk/Source/WebKit/Shared/API/c/cf/WKURLCF.mm

    r270810 r278619  
    6868
    6969    CString buffer = string.utf8();
    70     return CFURLCreateAbsoluteURLWithBytes(nullptr, reinterpret_cast<const UInt8*>(buffer.data()), buffer.length(), kCFStringEncodingUTF8, nullptr, true);
     70    return CFURLCreateAbsoluteURLWithBytes(nullptr, buffer.dataAsUInt8Ptr(), buffer.length(), kCFStringEncodingUTF8, nullptr, true);
    7171}
  • trunk/Source/WebKit/Shared/ShareableResource.cpp

    r278532 r278619  
    8585#if USE(CF)
    8686    auto deallocator = createShareableResourceDeallocator(this);
    87     auto cfData = adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, reinterpret_cast<const UInt8*>(data()), static_cast<CFIndex>(size()), deallocator.get()));
     87    auto cfData = adoptCF(CFDataCreateWithBytesNoCopy(kCFAllocatorDefault, data(), static_cast<CFIndex>(size()), deallocator.get()));
    8888    return SharedBuffer::create(cfData.get());
    8989#elif USE(GLIB)
  • trunk/Source/WebKit/Shared/SharedDisplayListHandle.h

    r278161 r278619  
    4949
    5050    WebCore::DisplayList::ItemBufferIdentifier identifier() const { return m_identifier; }
    51     uint8_t* data() const { return reinterpret_cast<uint8_t*>(sharedMemory().data()); }
     51    uint8_t* data() const { return static_cast<uint8_t*>(sharedMemory().data()); }
    5252
    5353    uint64_t unreadBytes()
  • trunk/Source/WebKit/Shared/WebCompiledContentRuleList.cpp

    r244597 r278619  
    4747bool WebCompiledContentRuleList::conditionsApplyOnlyToDomain() const
    4848{
    49     return *reinterpret_cast<const uint32_t*>(reinterpret_cast<const uint8_t*>(m_data.data->data()) + m_data.conditionsApplyOnlyToDomainOffset);
     49    return *reinterpret_cast<const uint32_t*>(static_cast<const uint8_t*>(m_data.data->data()) + m_data.conditionsApplyOnlyToDomainOffset);
    5050}
    5151
  • trunk/Source/WebKit/UIProcess/API/APIWebAuthenticationAssertionResponse.cpp

    r254554 r278619  
    5151    if (auto* userHandle = m_response->userHandle()) {
    5252        userHandle->ref();
    53         data = API::Data::createWithoutCopying(reinterpret_cast<unsigned char*>(userHandle->data()), userHandle->byteLength(), [] (unsigned char*, const void* data) {
     53        data = API::Data::createWithoutCopying(static_cast<unsigned char*>(userHandle->data()), userHandle->byteLength(), [] (unsigned char*, const void* data) {
    5454            static_cast<ArrayBuffer*>(const_cast<void*>(data))->deref();
    5555        }, userHandle);
  • trunk/Source/WebKit/UIProcess/API/C/WKPage.cpp

    r278253 r278619  
    242242    if (string.isNull() || !string.is8Bit())
    243243        return { reinterpret_cast<const uint8_t*>(string.characters16()), string.length() * sizeof(UChar) };
    244     return { reinterpret_cast<const uint8_t*>(string.characters8()), string.length() * sizeof(LChar) };
     244    return { string.characters8(), string.length() * sizeof(LChar) };
    245245}
    246246
  • trunk/Source/WebKit/UIProcess/Cocoa/SOAuthorization/RedirectSOAuthorizationSession.mm

    r261968 r278619  
    7878            page->setShouldSuppressSOAuthorizationInNextNavigationPolicyDecision();
    7979            auto html = makeString("<script>location = '", response.httpHeaderFields().get(HTTPHeaderName::Location), "'</script>").utf8();
    80             auto data = IPC::DataReference(reinterpret_cast<const uint8_t*>(html.data()), html.length());
     80            auto data = IPC::DataReference(html.dataAsUInt8Ptr(), html.length());
    8181            page->loadData(data, "text/html"_s, "UTF-8"_s, navigationAction->request().url().string(), nullptr, navigationAction->shouldOpenExternalURLsPolicy());
    8282            return;
  • trunk/Source/WebKit/UIProcess/Inspector/socket/RemoteInspectorClient.cpp

    r278244 r278619  
    125125    ASSERT(m_connectionID);
    126126    auto message = event.utf8();
    127     send(m_connectionID.value(), reinterpret_cast<const uint8_t*>(message.data()), message.length());
     127    send(m_connectionID.value(), message.dataAsUInt8Ptr(), message.length());
    128128}
    129129
  • trunk/Source/WebKit/WebProcess/Network/WebSocketChannel.cpp

    r278532 r278619  
    5757{
    5858    return { document, [&channel](auto& utf8String) {
    59         channel.notifySendFrame(WebSocketFrame::OpCode::OpCodeText, reinterpret_cast<const uint8_t*>(utf8String.data()), utf8String.length());
    60         channel.sendMessage(Messages::NetworkSocketChannel::SendString { IPC::DataReference { reinterpret_cast<const uint8_t*>(utf8String.data()), utf8String.length() } }, utf8String.length());
     59        channel.notifySendFrame(WebSocketFrame::OpCode::OpCodeText, utf8String.dataAsUInt8Ptr(), utf8String.length());
     60        channel.sendMessage(Messages::NetworkSocketChannel::SendString { IPC::DataReference { utf8String.dataAsUInt8Ptr(), utf8String.length() } }, utf8String.length());
    6161    }, [&channel](const uint8_t* data, size_t byteLength) {
    6262        channel.notifySendFrame(WebSocketFrame::OpCode::OpCodeBinary, data, byteLength);
     
    296296
    297297    auto utf8Message = message.utf8();
    298     m_inspector.didReceiveWebSocketFrame(m_document.get(), createWebSocketFrameForWebInspector(reinterpret_cast<const uint8_t*>(utf8Message.data()), utf8Message.length(), WebSocketFrame::OpCode::OpCodeText));
     298    m_inspector.didReceiveWebSocketFrame(m_document.get(), createWebSocketFrameForWebInspector(utf8Message.dataAsUInt8Ptr(), utf8Message.length(), WebSocketFrame::OpCode::OpCodeText));
    299299
    300300    m_client->didReceiveMessage(message);
  • trunk/Source/WebKit/WebProcess/Network/webrtc/RTCDataChannelRemoteManager.cpp

    r278516 r278619  
    124124            source->sendRawData(data.data(), data.size());
    125125        else
    126             source->sendStringData(CString(reinterpret_cast<const char*>(data.data()), data.size()));
     126            source->sendStringData(CString(data.data(), data.size()));
    127127    }
    128128}
     
    228228{
    229229    auto text = string.utf8();
    230     m_connection->send(Messages::RTCDataChannelRemoteManagerProxy::ReceiveData { identifier, false, IPC::DataReference { reinterpret_cast<const unsigned char*>(text.data()), text.length() } }, 0);
     230    m_connection->send(Messages::RTCDataChannelRemoteManagerProxy::ReceiveData { identifier, false, IPC::DataReference { text.dataAsUInt8Ptr(), text.length() } }, 0);
    231231}
    232232
  • trunk/Source/WebKit/WebProcess/Plugins/Netscape/NetscapePluginStream.cpp

    r278516 r278619  
    118118        return;
    119119
    120     deliverData(reinterpret_cast<const uint8_t*>(resultCString.data()), resultCString.length());
     120    deliverData(resultCString.dataAsUInt8Ptr(), resultCString.length());
    121121    stop(NPRES_DONE);
    122122}
Note: See TracChangeset for help on using the changeset viewer.