Merge pull request #270 from svost/useless-cast
author0xDEADFACE <masmfan@gmail.com>
Wed, 3 Feb 2016 07:46:18 +0000 (07:46 +0000)
committer0xDEADFACE <masmfan@gmail.com>
Wed, 3 Feb 2016 07:46:18 +0000 (07:46 +0000)
Get rid of some useless-cast

1  2 
src/main.cpp
src/net.cpp

diff --combined src/main.cpp
@@@ -7,6 -7,7 +7,6 @@@
  #include "checkpoints.h"
  #include "db.h"
  #include "txdb.h"
 -#include "net.h"
  #include "init.h"
  #include "ui_interface.h"
  #include "checkqueue.h"
@@@ -3671,7 -3672,7 +3671,7 @@@ bool static ProcessMessage(CNode* pfrom
  
          if (!GetBoolArg("-allowreceivebyip"))
          {
-             pfrom->PushMessage("reply", hashReply, (int)2, string(""));
+             pfrom->PushMessage("reply", hashReply, 2, string(""));
              return true;
          }
  
          // Send back approval of order and pubkey to use
          CScript scriptPubKey;
          scriptPubKey << mapReuseKey[pfrom->addr] << OP_CHECKSIG;
-         pfrom->PushMessage("reply", hashReply, (int)0, scriptPubKey);
+         pfrom->PushMessage("reply", hashReply, 0, scriptPubKey);
      }
  
  
diff --combined src/net.cpp
@@@ -201,7 -201,7 +201,7 @@@ void static AdvertizeLocal(
          if (pnode->fSuccessfullyConnected)
          {
              CAddress addrLocal = GetLocalAddress(&pnode->addr);
-             if (addrLocal.IsRoutable() && (CService)addrLocal != (CService)pnode->addrLocal)
+             if (addrLocal.IsRoutable() && (CService)addrLocal != pnode->addrLocal)
              {
                  pnode->PushAddress(addrLocal);
                  pnode->addrLocal = addrLocal;
@@@ -447,7 -447,8 +447,7 @@@ void CNode::CloseSocketDisconnect(
      if (hSocket != INVALID_SOCKET)
      {
          printf("disconnecting node %s\n", addrName.c_str());
 -        closesocket(hSocket);
 -        hSocket = INVALID_SOCKET;
 +        CloseSocket(hSocket);
          vRecv.clear();
      }
  
@@@ -776,13 -777,13 +776,13 @@@ void ThreadSocketHandler2(void* parg
                  {
                      LOCK(cs_setservAddNodeAddresses);
                      if (!setservAddNodeAddresses.count(addr))
 -                        closesocket(hSocket);
 +                        CloseSocket(hSocket);
                  }
              }
              else if (CNode::IsBanned(addr))
              {
                  printf("connection from %s dropped (banned)\n", addr.ToString().c_str());
 -                closesocket(hSocket);
 +                CloseSocket(hSocket);
              }
              else
              {
@@@ -1606,7 -1607,7 +1606,7 @@@ bool BindListenPort(const CService &add
          else
              strError = strprintf(_("Unable to bind to %s on this computer (bind returned error %d, %s)"), addrBind.ToString().c_str(), nErr, strerror(nErr));
          printf("%s\n", strError.c_str());
 -        closesocket(hListenSocket);
 +        CloseSocket(hListenSocket);
          return false;
      }
      printf("Bound to %s\n", addrBind.ToString().c_str());
      {
          strError = strprintf("Error: Listening for incoming connections failed (listen returned error %d)", WSAGetLastError());
          printf("%s\n", strError.c_str());
 -        closesocket(hListenSocket);
 +        CloseSocket(hListenSocket);
          return false;
      }
  
@@@ -1802,11 -1803,11 +1802,11 @@@ public
          // Close sockets
          BOOST_FOREACH(CNode* pnode, vNodes)
              if (pnode->hSocket != INVALID_SOCKET)
 -                closesocket(pnode->hSocket);
 +                CloseSocket(pnode->hSocket);
          BOOST_FOREACH(SOCKET hListenSocket, vhListenSocket)
              if (hListenSocket != INVALID_SOCKET)
 -                if (closesocket(hListenSocket) == SOCKET_ERROR)
 -                    printf("closesocket(hListenSocket) failed with error %d\n", WSAGetLastError());
 +                if (!CloseSocket(hListenSocket))
 +                    printf("CloseSocket(hListenSocket) failed with error %d\n", WSAGetLastError());
  
          // clean up some globals (to help leak detection)
          BOOST_FOREACH(CNode *pnode, vNodes)