Title: [260704] trunk/Source/WebKit
Revision
260704
Author
[email protected]
Date
2020-04-25 08:46:47 -0700 (Sat, 25 Apr 2020)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (260703 => 260704)


--- trunk/Source/WebKit/ChangeLog	2020-04-25 15:22:05 UTC (rev 260703)
+++ trunk/Source/WebKit/ChangeLog	2020-04-25 15:46:47 UTC (rev 260704)
@@ -1,3 +1,32 @@
+2020-04-25  David Kilzer  <[email protected]>
+
+        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.
+
 2020-04-25  Diego Pino Garcia  <[email protected]>
 
         REGRESSION(210942): [GTK][WPE] EWS build bots fail in compile-webkit step

Modified: trunk/Source/WebKit/Platform/IPC/Connection.cpp (260703 => 260704)


--- trunk/Source/WebKit/Platform/IPC/Connection.cpp	2020-04-25 15:22:05 UTC (rev 260703)
+++ trunk/Source/WebKit/Platform/IPC/Connection.cpp	2020-04-25 15:46:47 UTC (rev 260704)
@@ -355,7 +355,7 @@
     workQueueMessageReceiver.didReceiveSyncMessage(*this, decoder, replyEncoder);
 
     // FIXME: If the message was invalid, we should send back a SyncMessageError.
-    ASSERT(!decoder.isInvalid());
+    ASSERT(decoder.isValid());
 
     if (replyEncoder)
         sendSyncReply(WTFMove(replyEncoder));
@@ -399,7 +399,7 @@
     threadMessageReceiver.didReceiveSyncMessage(*this, decoder, replyEncoder);
 
     // FIXME: If the message was invalid, we should send back a SyncMessageError.
-    ASSERT(!decoder.isInvalid());
+    ASSERT(decoder.isValid());
 
     if (replyEncoder)
         sendSyncReply(WTFMove(replyEncoder));
@@ -930,7 +930,7 @@
     }
 
     // FIXME: If the message was invalid, we should send back a SyncMessageError.
-    ASSERT(!decoder.isInvalid());
+    ASSERT(decoder.isValid());
 
     if (replyEncoder)
         sendSyncReply(WTFMove(replyEncoder));
@@ -1076,7 +1076,7 @@
     else
         dispatchMessage(*message);
 
-    m_didReceiveInvalidMessage |= message->isInvalid();
+    m_didReceiveInvalidMessage |= !message->isValid();
     m_inDispatchMessageCount--;
 
     // FIXME: For synchronous messages, we should not decrement the counter until we send a response.

Modified: trunk/Source/WebKit/Platform/IPC/Connection.h (260703 => 260704)


--- trunk/Source/WebKit/Platform/IPC/Connection.h	2020-04-25 15:22:05 UTC (rev 260703)
+++ trunk/Source/WebKit/Platform/IPC/Connection.h	2020-04-25 15:46:47 UTC (rev 260704)
@@ -483,7 +483,7 @@
     encoder->encode(message.arguments());
     sendMessage(WTFMove(encoder), sendOptions);
     addAsyncReplyHandler(*this, listenerID, [completionHandler = WTFMove(completionHandler)] (Decoder* decoder) mutable {
-        if (decoder && !decoder->isInvalid())
+        if (decoder && decoder->isValid())
             T::callReply(*decoder, WTFMove(completionHandler));
         else
             T::cancelReply(WTFMove(completionHandler));

Modified: trunk/Source/WebKit/Platform/IPC/Decoder.cpp (260703 => 260704)


--- trunk/Source/WebKit/Platform/IPC/Decoder.cpp	2020-04-25 15:22:05 UTC (rev 260703)
+++ trunk/Source/WebKit/Platform/IPC/Decoder.cpp	2020-04-25 15:46:47 UTC (rev 260704)
@@ -48,7 +48,7 @@
 std::unique_ptr<Decoder> Decoder::create(const uint8_t* buffer, size_t bufferSize, void (*bufferDeallocator)(const uint8_t*, size_t), Vector<Attachment>&& attachments)
 {
     auto decoder = makeUnique<Decoder>(buffer, bufferSize, bufferDeallocator, WTFMove(attachments));
-    return decoder->isInvalid() ? nullptr : WTFMove(decoder);
+    return decoder->isValid() ? WTFMove(decoder) : nullptr;
 }
 
 Decoder::Decoder(const uint8_t* buffer, size_t bufferSize, void (*bufferDeallocator)(const uint8_t*, size_t), Vector<Attachment>&& attachments)

Modified: trunk/Source/WebKit/Platform/IPC/Decoder.h (260703 => 260704)


--- trunk/Source/WebKit/Platform/IPC/Decoder.h	2020-04-25 15:22:05 UTC (rev 260703)
+++ trunk/Source/WebKit/Platform/IPC/Decoder.h	2020-04-25 15:46:47 UTC (rev 260704)
@@ -71,11 +71,11 @@
 
     size_t length() const { return m_bufferEnd - m_buffer; }
 
-    bool isInvalid() const
+    bool isValid() const
     {
         // (m_bufferPos == m_bufferEnd) is a valid state for decoding if the last parameter
         // is a variable length byte array and its size == 0.
-        return m_bufferPos < m_buffer || m_bufferPos > m_bufferEnd;
+        return m_bufferPos >= m_buffer && m_bufferPos <= m_bufferEnd;
     }
     void markInvalid() { m_bufferPos = nullptr; }
 

Modified: trunk/Source/WebKit/Platform/IPC/MessageSender.h (260703 => 260704)


--- trunk/Source/WebKit/Platform/IPC/MessageSender.h	2020-04-25 15:22:05 UTC (rev 260703)
+++ trunk/Source/WebKit/Platform/IPC/MessageSender.h	2020-04-25 15:46:47 UTC (rev 260704)
@@ -93,7 +93,7 @@
         encoder->encode(listenerID);
         encoder->encode(message.arguments());
         sendMessage(WTFMove(encoder), sendOptions, {{ [completionHandler = WTFMove(completionHandler)] (IPC::Decoder* decoder) mutable {
-            if (decoder && !decoder->isInvalid())
+            if (decoder && decoder->isValid())
                 T::callReply(*decoder, WTFMove(completionHandler));
             else
                 T::cancelReply(WTFMove(completionHandler));

Modified: trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h (260703 => 260704)


--- trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h	2020-04-25 15:22:05 UTC (rev 260703)
+++ trunk/Source/WebKit/UIProcess/AuxiliaryProcessProxy.h	2020-04-25 15:46:47 UTC (rev 260704)
@@ -179,7 +179,7 @@
     encoder->encode(listenerID);
     encoder->encode(message.arguments());
     sendMessage(WTFMove(encoder), sendOptions, {{ [completionHandler = WTFMove(completionHandler)] (IPC::Decoder* decoder) mutable {
-        if (decoder && !decoder->isInvalid())
+        if (decoder && decoder->isValid())
             T::callReply(*decoder, WTFMove(completionHandler));
         else
             T::cancelReply(WTFMove(completionHandler));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to