mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
asan+ubsan clean
This commit is contained in:
parent
05efc25f32
commit
68bcd21eff
|
@ -120,8 +120,14 @@ port=17822
|
|||
|
||||
cp ../ubsan.supp .
|
||||
|
||||
if [[ $OSTYPE == 'darwin'* ]]; then
|
||||
DETECT_LEAKS=0
|
||||
else
|
||||
DETECT_LEAKS=1
|
||||
fi
|
||||
|
||||
export UBSAN_OPTIONS=suppressions=./ubsan.supp:log_path=./SAN:print_stacktrace=1:halt_on_errors=0
|
||||
export ASAN_OPTIONS=log_path=./SAN:print_stacktrace=1:check_initialization_order=1:detect_leaks=1:halt_on_errors=0
|
||||
export ASAN_OPTIONS=log_path=./SAN:print_stacktrace=1:check_initialization_order=1:detect_leaks=$DETECT_LEAKS:halt_on_errors=0
|
||||
|
||||
function print_san() {
|
||||
if test -n "$(find . -maxdepth 1 -name 'SAN.*' -print -quit)"
|
||||
|
@ -181,14 +187,15 @@ wait
|
|||
sleep 1
|
||||
|
||||
ranks="$(sqlite3 ddnet-server.sqlite < <(echo "select * from record_race;"))"
|
||||
num_ranks="$(echo "$ranks" | wc -l | xargs)"
|
||||
if [ "$ranks" == "" ]
|
||||
then
|
||||
touch fail_ranks.txt
|
||||
echo "[-] Error: no ranks found in database"
|
||||
elif [ "$(echo "$ranks" | wc -l)" != "1" ]
|
||||
elif [ "$num_ranks" != "1" ]
|
||||
then
|
||||
touch fail_ranks.txt
|
||||
echo "[-] Error: expected 1 rank got $(echo "$ranks" | wc -l)"
|
||||
echo "[-] Error: expected 1 rank got $num_ranks"
|
||||
elif ! echo "$ranks" | grep -q client1
|
||||
then
|
||||
touch fail_ranks.txt
|
||||
|
@ -213,4 +220,3 @@ else
|
|||
fi
|
||||
|
||||
print_san || exit 1
|
||||
|
||||
|
|
|
@ -124,14 +124,17 @@ inline float angle(const vector2_base<float> &a)
|
|||
template<typename T>
|
||||
inline vector2_base<T> normalize_pre_length(const vector2_base<T> &v, T len)
|
||||
{
|
||||
if(len == 0)
|
||||
return vector2_base<T>();
|
||||
return vector2_base<T>(v.x / len, v.y / len);
|
||||
float l = (float)(1.0f / sqrtf(v.x * v.x + v.y * v.y));
|
||||
return vector2_base<float>(v.x * l, v.y * l);
|
||||
}
|
||||
|
||||
inline vector2_base<float> normalize(const vector2_base<float> &v)
|
||||
{
|
||||
float l = (float)(1.0f / sqrtf(v.x * v.x + v.y * v.y));
|
||||
float divisor = sqrtf(v.x * v.x + v.y * v.y);
|
||||
if(divisor == 0.0f)
|
||||
return vector2_base<float>(0.0f, 0.0f);
|
||||
float l = (float)(1.0f / divisor);
|
||||
return vector2_base<float>(v.x * l, v.y * l);
|
||||
}
|
||||
|
||||
|
@ -273,7 +276,10 @@ inline float length(const vector3_base<float> &a)
|
|||
|
||||
inline vector3_base<float> normalize(const vector3_base<float> &v)
|
||||
{
|
||||
float l = (float)(1.0f / sqrtf(v.x * v.x + v.y * v.y + v.z * v.z));
|
||||
float divisor = sqrtf(v.x * v.x + v.y * v.y + v.z * v.z);
|
||||
if(divisor == 0.0f)
|
||||
return vector3_base<float>(0.0f, 0.0f, 0.0f);
|
||||
float l = (float)(1.0f / divisor);
|
||||
return vector3_base<float>(v.x * l, v.y * l, v.z * l);
|
||||
}
|
||||
|
||||
|
|
|
@ -144,12 +144,14 @@ void CGameWorld::RemoveEntity(CEntity *pEnt)
|
|||
|
||||
if(pEnt->m_ObjType == ENTTYPE_CHARACTER)
|
||||
{
|
||||
CCharacter *pChar = (CCharacter *)pEnt;
|
||||
int ID = pChar->GetCID();
|
||||
if(ID >= 0 && ID < MAX_CLIENTS)
|
||||
if(CCharacter *pChar = dynamic_cast<CCharacter *>(pEnt))
|
||||
{
|
||||
m_apCharacters[ID] = 0;
|
||||
m_Core.m_apCharacters[ID] = 0;
|
||||
int ID = pChar->GetCID();
|
||||
if(ID >= 0 && ID < MAX_CLIENTS)
|
||||
{
|
||||
m_apCharacters[ID] = 0;
|
||||
m_Core.m_apCharacters[ID] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue