Include limits instead of climits

Consistently use `std::numeric_limits` instead of `INT_MIN` and `INT_MAX`.
This commit is contained in:
Robert Müller 2024-01-10 21:43:44 +01:00
parent 42319546a6
commit 5e510cdbf4
4 changed files with 7 additions and 8 deletions

View file

@ -63,7 +63,7 @@
#endif
#include <chrono>
#include <climits>
#include <limits>
#include <new>
#include <stack>
#include <thread>
@ -3798,7 +3798,7 @@ int CClient::HandleChecksum(int Conn, CUuid Uuid, CUnpacker *pUnpacker)
{
return 1;
}
if(Start < 0 || Length < 0 || Start > INT_MAX - Length)
if(Start < 0 || Length < 0 || Start > std::numeric_limits<int>::max() - Length)
{
return 2;
}

View file

@ -6,7 +6,6 @@
#include "serverbrowser_ping_cache.h"
#include <algorithm>
#include <climits>
#include <unordered_set>
#include <vector>

View file

@ -1,7 +1,7 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
/* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <climits>
#include <limits>
#include <engine/graphics.h>
#include <engine/shared/config.h>
@ -132,7 +132,7 @@ void CSpectator::ConSpectateClosest(IConsole::IResult *pResult, void *pUserData)
CurPosition.y = CurCharacter.m_Y;
}
int ClosestDistance = INT_MAX;
int ClosestDistance = std::numeric_limits<int>::max();
for(int i = 0; i < MAX_CLIENTS; i++)
{
if(i == SpectatorID || !Snap.m_apPlayerInfos[i] || Snap.m_apPlayerInfos[i]->m_Team == TEAM_SPECTATORS || (SpectatorID == SPEC_FREEVIEW && i == Snap.m_LocalClientID))

View file

@ -6,7 +6,7 @@
#include <base/system.h>
#include <engine/shared/jsonwriter.h>
#include <climits>
#include <limits>
class JsonFileWriter
{
@ -201,12 +201,12 @@ TYPED_TEST(JsonWriters, MinusOne)
TYPED_TEST(JsonWriters, Large)
{
this->Impl.m_pJson->WriteIntValue(INT_MAX);
this->Impl.m_pJson->WriteIntValue(std::numeric_limits<int>::max());
this->Impl.Expect("2147483647\n");
}
TYPED_TEST(JsonWriters, Small)
{
this->Impl.m_pJson->WriteIntValue(INT_MIN);
this->Impl.m_pJson->WriteIntValue(std::numeric_limits<int>::min());
this->Impl.Expect("-2147483648\n");
}