[Lldb-commits] [PATCH] D116768: Fix setting of success in Socket::Close()

Shafik Yaghmour via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Thu Jan 6 14:34:56 PST 2022


shafik created this revision.
shafik added reviewers: labath, jingham, JDevlieghere.
shafik requested review of this revision.

Both `close` and `closesocket` should return `0` on success so using `!!` looks incorrect. I replaced this will a more readable `== 0` check.


https://reviews.llvm.org/D116768

Files:
  lldb/source/Host/common/Socket.cpp


Index: lldb/source/Host/common/Socket.cpp
===================================================================
--- lldb/source/Host/common/Socket.cpp
+++ lldb/source/Host/common/Socket.cpp
@@ -281,9 +281,9 @@
             static_cast<void *>(this), static_cast<uint64_t>(m_socket));
 
 #if defined(_WIN32)
-  bool success = !!closesocket(m_socket);
+  bool success = closesocket(m_socket) == 0;
 #else
-  bool success = !!::close(m_socket);
+  bool success = ::close(m_socket) == 0;
 #endif
   // A reference to a FD was passed in, set it to an invalid value
   m_socket = kInvalidSocketValue;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116768.397993.patch
Type: text/x-patch
Size: 593 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220106/ba77edaa/attachment.bin>


More information about the lldb-commits mailing list