Get rid of C style macros
authorCryptoManiac <balthazar@yandex.ru>
Thu, 14 Apr 2016 00:16:49 +0000 (03:16 +0300)
committerCryptoManiac <balthazar@yandex.ru>
Thu, 14 Apr 2016 00:16:49 +0000 (03:16 +0300)
src/ntp.cpp
src/rpcwallet.cpp
src/util.cpp

index c5ee734..58fcc7d 100644 (file)
@@ -438,7 +438,7 @@ int64_t NtpGetTime(const std::string &strHostName)
 std::string strTrustedUpstream = "localhost";
 
 // Current offset
-int64_t nNtpOffset = INT64_MAX;
+int64_t nNtpOffset = numeric_limits<int64_t>::max();
 
 int64_t GetNtpOffset() {
     return nNtpOffset;
@@ -477,7 +477,7 @@ void ThreadNtpSamples(void* parg) {
             }
             else {
                 // Something went wrong, disable trusted offset sampling.
-                nNtpOffset = INT64_MAX;
+                nNtpOffset = numeric_limits<int64_t>::max();
                 strTrustedUpstream = "localhost";
 
                 int nSleepMinutes = 1 + GetRandInt(9); // Sleep for 1-10 minutes.
@@ -506,7 +506,7 @@ void ThreadNtpSamples(void* parg) {
             }
             else {
                 // Not enough offsets yet, try to collect additional samples later.
-                nNtpOffset = INT64_MAX;
+                nNtpOffset = numeric_limits<int64_t>::max();
                 int nSleepMinutes = 1 + GetRandInt(4); // Sleep for 1-5 minutes.
                 for (int i = 0; i < nSleepMinutes * 60 && !fShutdown; i++) 
                     Sleep(1000);
@@ -514,7 +514,7 @@ void ThreadNtpSamples(void* parg) {
             }
         }
 
-        if (GetNodesOffset() == INT_MAX && abs(nNtpOffset) > 40 * 60)
+        if (GetNodesOffset() == numeric_limits<int64_t>::max() && abs(nNtpOffset) > 40 * 60)
         {
             // If there is not enough node offsets data and NTP time offset is greater than 40 minutes then give a warning.
             std::string strMessage = _("Warning: Please check that your computer's date and time are correct! If your clock is wrong NovaCoin will not work properly.");
index e892bfb..7371fa2 100644 (file)
@@ -88,8 +88,8 @@ Value getinfo(const Array& params, bool fHelp)
     auto nNtpOffset = GetNtpOffset(),
             nP2POffset = GetNodesOffset();
 
-    timestamping.push_back(Pair("ntpoffset", nNtpOffset != INT64_MAX ? nNtpOffset : Value::null));
-    timestamping.push_back(Pair("p2poffset", nP2POffset != INT64_MAX ? nP2POffset : Value::null));
+    timestamping.push_back(Pair("ntpoffset", nNtpOffset != numeric_limits<int64_t>::max() ? nNtpOffset : Value::null));
+    timestamping.push_back(Pair("p2poffset", nP2POffset != numeric_limits<int64_t>::max() ? nP2POffset : Value::null));
 
     obj.push_back(Pair("timestamping", timestamping));
 
index c0513ef..982c1e5 100644 (file)
@@ -1280,7 +1280,7 @@ int64_t GetTime()
 extern int64_t nNtpOffset;
 
 // Median of time samples given by other nodes.
-static int64_t nNodesOffset = INT64_MAX;
+static int64_t nNodesOffset = numeric_limits<int64_t>::max();
 
 // Select time offset:
 int64_t GetTimeOffset()
@@ -1329,7 +1329,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nTime)
         }
         else
         {
-            nNodesOffset = INT64_MAX;
+            nNodesOffset = numeric_limits<int64_t>::max();
 
             static bool fDone;
             if (!fDone)
@@ -1356,7 +1356,7 @@ void AddTimeData(const CNetAddr& ip, int64_t nTime)
                 printf("%+" PRId64 "  ", n);
             printf("|  ");
         }
-        if (nNodesOffset != INT64_MAX)
+        if (nNodesOffset != numeric_limits<int64_t>::max())
             printf("nNodesOffset = %+" PRId64 "  (%+" PRId64 " minutes)\n", nNodesOffset, nNodesOffset/60);
     }
 }