// Write block to history file
if (!CheckDiskSpace(::GetSerializeSize(*this, SER_DISK, CLIENT_VERSION)))
return error("AcceptBlock() : out of disk space");
- unsigned int nFile = UINT_MAX;
+ unsigned int nFile = std::numeric_limits<unsigned int>::max();
unsigned int nBlockPos = 0;
if (!WriteToDisk(nFile, nBlockPos))
return error("AcceptBlock() : WriteToDisk failed");
bool GetMyExternalIP(CNetAddr& ipRet)
{
struct sockaddr_in mapped;
- uint64_t rnd = UINT64_MAX;
+ uint64_t rnd = std::numeric_limits<uint64_t>::max();
const char *srv;
int rc = GetExternalIPbySTUN(rnd, &mapped, &srv);
if(rc >= 0) {
#ifndef BITCOIN_NET_H
#define BITCOIN_NET_H
+#include <limits>
#include <deque>
#ifndef Q_MOC_RUN
#include <boost/array.hpp>
nLastSendEmpty = GetTime();
nTimeConnected = GetTime();
nHeaderStart = -1;
- nMessageStart = UINT_MAX;
+ nMessageStart = std::numeric_limits<uint32_t>::max();
addr = addrIn;
addrName = addrNameIn == "" ? addr.ToStringIPPort() : addrNameIn;
nVersion = 0;
return;
vSend.resize(nHeaderStart);
nHeaderStart = -1;
- nMessageStart = UINT_MAX;
+ nMessageStart = std::numeric_limits<uint32_t>::max();
LEAVE_CRITICAL_SECTION(cs_vSend);
if (fDebug)
}
nHeaderStart = -1;
- nMessageStart = UINT_MAX;
+ nMessageStart = std::numeric_limits<uint32_t>::max();
LEAVE_CRITICAL_SECTION(cs_vSend);
}
memcpy(pchMessageStart, ::pchMessageStart, sizeof(pchMessageStart));
memset(pchCommand, 0, sizeof(pchCommand));
pchCommand[1] = 1;
- nMessageSize = UINT_MAX;
+ nMessageSize = std::numeric_limits<uint32_t>::max();
nChecksum = 0;
}
#include "serialize.h"
#include "netbase.h"
#include <string>
+#include <limits>
#include "uint256.h"
extern bool fTestNet;
* Of course all fields are in network format.
*/
-#define __STDC_LIMIT_MACROS
-
#include <stdio.h>
-#include <stdint.h>
+#include <inttypes.h>
+#include <limits>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
}
/* helper function to generate a random request id */
-static uint64_t randfiller = GetRand(UINT64_MAX);
+static uint64_t randfiller = GetRand(std::numeric_limits<uint64_t>::max());
static void stun_req_id(struct stun_header *req)
{
const uint64_t *S_block = (const uint64_t *)StunSrvList;
- req->id.id[0] = GetRandInt(INT32_MAX);
- req->id.id[1] = GetRandInt(INT32_MAX);
- req->id.id[2] = GetRandInt(INT32_MAX);
- req->id.id[3] = GetRandInt(INT32_MAX);
+ req->id.id[0] = GetRandInt(std::numeric_limits<int32_t>::max());
+ req->id.id[1] = GetRandInt(std::numeric_limits<int32_t>::max());
+ req->id.id[2] = GetRandInt(std::numeric_limits<int32_t>::max());
+ req->id.id[3] = GetRandInt(std::numeric_limits<int32_t>::max());
req->id.id[0] |= 0x55555555;
req->id.id[1] &= 0x55555555;
{
// Restart the file with some of the end
char pch[200000];
- fseek(file, -sizeof(pch), SEEK_END);
+ fseek(file, (long long)-sizeof(pch), SEEK_END);
int nBytes = fread(pch, 1, sizeof(pch), file);
fclose(file);