[Lldb-commits] [lldb] r372486 - [LLDB] Cast -1 (as invalid socket) to the socket type before comparing

Martin Storsjo via lldb-commits lldb-commits at lists.llvm.org
Sat Sep 21 12:10:15 PDT 2019


Author: mstorsjo
Date: Sat Sep 21 12:10:15 2019
New Revision: 372486

URL: http://llvm.org/viewvc/llvm-project?rev=372486&view=rev
Log:
[LLDB] Cast -1 (as invalid socket) to the socket type before comparing

This silences warnings about comparison of integers between unsigned
long long (which is what the Windows SOCKET type is) and signed int
when building in MinGW mode.

Differential Revision: https://reviews.llvm.org/D67863

Modified:
    lldb/trunk/source/Host/common/Socket.cpp
    lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp

Modified: lldb/trunk/source/Host/common/Socket.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Host/common/Socket.cpp?rev=372486&r1=372485&r2=372486&view=diff
==============================================================================
--- lldb/trunk/source/Host/common/Socket.cpp (original)
+++ lldb/trunk/source/Host/common/Socket.cpp Sat Sep 21 12:10:15 2019
@@ -476,11 +476,11 @@ NativeSocket Socket::AcceptSocket(Native
   if (!child_processes_inherit) {
     flags |= SOCK_CLOEXEC;
   }
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept4,
-      sockfd, addr, addrlen, flags);
+  NativeSocket fd = llvm::sys::RetryAfterSignal(
+      static_cast<NativeSocket>(-1), ::accept4, sockfd, addr, addrlen, flags);
 #else
-  NativeSocket fd = llvm::sys::RetryAfterSignal(-1, ::accept,
-      sockfd, addr, addrlen);
+  NativeSocket fd = llvm::sys::RetryAfterSignal(
+      static_cast<NativeSocket>(-1), ::accept, sockfd, addr, addrlen);
 #endif
   if (fd == kInvalidSocketValue)
     SetLastError(error);

Modified: lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp?rev=372486&r1=372485&r2=372486&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp (original)
+++ lldb/trunk/tools/lldb-vscode/lldb-vscode.cpp Sat Sep 21 12:10:15 2019
@@ -93,8 +93,9 @@ SOCKET AcceptConnection(int portno) {
     } else {
       listen(sockfd, 5);
       socklen_t clilen = sizeof(cli_addr);
-      newsockfd = llvm::sys::RetryAfterSignal(-1, accept,
-          sockfd, (struct sockaddr *)&cli_addr, &clilen);
+      newsockfd =
+          llvm::sys::RetryAfterSignal(static_cast<SOCKET>(-1), accept, sockfd,
+                                      (struct sockaddr *)&cli_addr, &clilen);
       if (newsockfd < 0)
         if (g_vsc.log)
           *g_vsc.log << "error: accept (" << strerror(errno) << ")"




More information about the lldb-commits mailing list