Changeset 260704 in webkit


Ignore:
Timestamp:
Apr 25, 2020 8:46:47 AM (4 years ago)
Author:
ddkilzer@apple.com
Message:

IPC::Decoder::isInvalid() should be renamed to isValid()
<https://webkit.org/b/211000>

Reviewed by Darin Adler.

Negative logic is more difficult to reason about than positive
logic.

  • Platform/IPC/Connection.cpp:

(IPC::Connection::dispatchMessage):
(IPC::Connection::dispatchWorkQueueMessageReceiverMessage):
(IPC::Connection::dispatchThreadMessageReceiverMessage):
(IPC::Connection::dispatchSyncMessage):

  • Platform/IPC/Connection.h:

(IPC::Connection::sendWithAsyncReply):

  • Platform/IPC/Decoder.cpp:

(IPC::Decoder::create):

  • Platform/IPC/Decoder.h:

(IPC::Decoder::isValid const): Rename from isInvalid()
and invert logic.
(IPC::Decoder::isInvalid const): Rename to isValid().

  • Platform/IPC/MessageSender.h:
  • UIProcess/AuxiliaryProcessProxy.h:

(WebKit::AuxiliaryProcessProxy::sendWithAsyncReply):

  • Change Decoder::isInvalid() to Decoder::isValid() and reverse the Boolean logic.
Location:
trunk/Source/WebKit
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r260696 r260704  
     12020-04-25  David Kilzer  <ddkilzer@apple.com>
     2
     3        IPC::Decoder::isInvalid() should be renamed to isValid()
     4        <https://webkit.org/b/211000>
     5
     6        Reviewed by Darin Adler.
     7
     8        Negative logic is more difficult to reason about than positive
     9        logic.
     10
     11        * Platform/IPC/Connection.cpp:
     12        (IPC::Connection::dispatchMessage):
     13        (IPC::Connection::dispatchWorkQueueMessageReceiverMessage):
     14        (IPC::Connection::dispatchThreadMessageReceiverMessage):
     15        (IPC::Connection::dispatchSyncMessage):
     16        * Platform/IPC/Connection.h:
     17        (IPC::Connection::sendWithAsyncReply):
     18        * Platform/IPC/Decoder.cpp:
     19        (IPC::Decoder::create):
     20        * Platform/IPC/Decoder.h:
     21        (IPC::Decoder::isValid const): Rename from isInvalid()
     22        and invert logic.
     23        (IPC::Decoder::isInvalid const): Rename to isValid().
     24        * Platform/IPC/MessageSender.h:
     25        * UIProcess/AuxiliaryProcessProxy.h:
     26        (WebKit::AuxiliaryProcessProxy::sendWithAsyncReply):
     27        - Change Decoder::isInvalid() to Decoder::isValid() and reverse
     28          the Boolean logic.
     29
    1302020-04-25  Diego Pino Garcia  <dpino@igalia.com>
    231
  • trunk/Source/WebKit/Platform/IPC/Connection.cpp

    r257688 r260704  
    356356
    357357    // FIXME: If the message was invalid, we should send back a SyncMessageError.
    358     ASSERT(!decoder.isInvalid());
     358    ASSERT(decoder.isValid());
    359359
    360360    if (replyEncoder)
     
    400400
    401401    // FIXME: If the message was invalid, we should send back a SyncMessageError.
    402     ASSERT(!decoder.isInvalid());
     402    ASSERT(decoder.isValid());
    403403
    404404    if (replyEncoder)
     
    931931
    932932    // FIXME: If the message was invalid, we should send back a SyncMessageError.
    933     ASSERT(!decoder.isInvalid());
     933    ASSERT(decoder.isValid());
    934934
    935935    if (replyEncoder)
     
    10771077        dispatchMessage(*message);
    10781078
    1079     m_didReceiveInvalidMessage |= message->isInvalid();
     1079    m_didReceiveInvalidMessage |= !message->isValid();
    10801080    m_inDispatchMessageCount--;
    10811081
  • trunk/Source/WebKit/Platform/IPC/Connection.h

    r259047 r260704  
    484484    sendMessage(WTFMove(encoder), sendOptions);
    485485    addAsyncReplyHandler(*this, listenerID, [completionHandler = WTFMove(completionHandler)] (Decoder* decoder) mutable {
    486         if (decoder && !decoder->isInvalid())
     486        if (decoder && decoder->isValid())
    487487            T::callReply(*decoder, WTFMove(completionHandler));
    488488        else
  • trunk/Source/WebKit/Platform/IPC/Decoder.cpp

    r260666 r260704  
    4949{
    5050    auto decoder = makeUnique<Decoder>(buffer, bufferSize, bufferDeallocator, WTFMove(attachments));
    51     return decoder->isInvalid() ? nullptr : WTFMove(decoder);
     51    return decoder->isValid() ? WTFMove(decoder) : nullptr;
    5252}
    5353
  • trunk/Source/WebKit/Platform/IPC/Decoder.h

    r260666 r260704  
    7272    size_t length() const { return m_bufferEnd - m_buffer; }
    7373
    74     bool isInvalid() const
     74    bool isValid() const
    7575    {
    7676        // (m_bufferPos == m_bufferEnd) is a valid state for decoding if the last parameter
    7777        // is a variable length byte array and its size == 0.
    78         return m_bufferPos < m_buffer || m_bufferPos > m_bufferEnd;
     78        return m_bufferPos >= m_buffer && m_bufferPos <= m_bufferEnd;
    7979    }
    8080    void markInvalid() { m_bufferPos = nullptr; }
  • trunk/Source/WebKit/Platform/IPC/MessageSender.h

    r258069 r260704  
    9494        encoder->encode(message.arguments());
    9595        sendMessage(WTFMove(encoder), sendOptions, {{ [completionHandler = WTFMove(completionHandler)] (IPC::Decoder* decoder) mutable {
    96             if (decoder && !decoder->isInvalid())
     96            if (decoder && decoder->isValid())
    9797                T::callReply(*decoder, WTFMove(completionHandler));
    9898            else
  • trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h

    r254569 r260704  
    180180    encoder->encode(message.arguments());
    181181    sendMessage(WTFMove(encoder), sendOptions, {{ [completionHandler = WTFMove(completionHandler)] (IPC::Decoder* decoder) mutable {
    182         if (decoder && !decoder->isInvalid())
     182        if (decoder && decoder->isValid())
    183183            T::callReply(*decoder, WTFMove(completionHandler));
    184184        else
Note: See TracChangeset for help on using the changeset viewer.