More Cppcheck fixes

Former-commit-id: 62ab1caa04543da1a169812bb92a450d44f3aec1
This commit is contained in:
Lynix 2015-06-07 00:21:53 +02:00
parent d1258c2a6d
commit f8682d227b
7 changed files with 41 additions and 28 deletions

View File

@ -160,31 +160,37 @@ inline NzColor NzColor::FromHSV(float hue, float saturation, float value)
r = value; r = value;
g = v3; g = v3;
b = v1; b = v1;
break;
case 1: case 1:
r = v2; r = v2;
g = value; g = value;
b = v1; b = v1;
break;
case 2: case 2:
r = v1; r = v1;
g = value; g = value;
b = v3; b = v3;
break;
case 3: case 3:
r = v1; r = v1;
g = v2; g = v2;
b = value; b = value;
break;
case 4: case 4:
r = v3; r = v3;
g = v1; g = v1;
b = value; b = value;
break;
default: default:
r = value; r = value;
g = v1; g = v1;
b = v2; b = v2;
break;
} }
// RGB results from 0 to 255 // RGB results from 0 to 255
@ -289,12 +295,11 @@ inline void NzColor::ToHSL(const NzColor& color, nzUInt8* hue, nzUInt8* saturati
float deltaB = ((max - b)/6.f + deltaMax/2.f)/deltaMax; float deltaB = ((max - b)/6.f + deltaMax/2.f)/deltaMax;
float h; float h;
if (NzNumberEquals(r, max)) if (NzNumberEquals(r, max))
h = deltaB - deltaG; h = deltaB - deltaG;
else if (NzNumberEquals(g, max)) else if (NzNumberEquals(g, max))
h = (1.f/3.f) + deltaR - deltaB; h = (1.f/3.f) + deltaR - deltaB;
else if (NzNumberEquals(b, max)) else
h = (2.f/3.f) + deltaG - deltaR; h = (2.f/3.f) + deltaG - deltaR;
if (h < 0.f) if (h < 0.f)

View File

@ -123,14 +123,14 @@ inline T* NzMemoryPool::New(Args&&... args)
inline NzMemoryPool& NzMemoryPool::operator=(NzMemoryPool&& pool) noexcept inline NzMemoryPool& NzMemoryPool::operator=(NzMemoryPool&& pool) noexcept
{ {
m_blockSize = m_blockSize; m_blockSize = pool.m_blockSize;
m_canGrow = m_canGrow; m_canGrow = pool.m_canGrow;
m_freeCount = m_freeCount.load(std::memory_order_relaxed); m_freeCount = pool.m_freeCount.load(std::memory_order_relaxed);
m_freeList = std::move(m_freeList); m_freeList = std::move(pool.m_freeList);
m_pool = std::move(m_pool); m_pool = std::move(pool.m_pool);
m_previous = m_previous; m_previous = pool.m_previous;
m_next = std::move(m_next); m_next = std::move(pool.m_next);
m_size = m_size; m_size = pool.m_size;
// Si nous avons été créés par un autre pool, nous devons le faire pointer vers nous de nouveau // Si nous avons été créés par un autre pool, nous devons le faire pointer vers nous de nouveau
if (m_previous) if (m_previous)

View File

@ -588,7 +588,7 @@ void SHA256_Init(SHA_CTX* context)
void SHA256_Internal_Transform(SHA_CTX* context, const nzUInt32* data) void SHA256_Internal_Transform(SHA_CTX* context, const nzUInt32* data)
{ {
nzUInt32 a, b, c, d, e, f, g, h, s0, s1; nzUInt32 a, b, c, d, e, f, g, h;
nzUInt32 T1, *W256; nzUInt32 T1, *W256;
int j; int j;
@ -622,6 +622,8 @@ void SHA256_Internal_Transform(SHA_CTX* context, const nzUInt32* data)
/* Now for the remaining rounds to 64: */ /* Now for the remaining rounds to 64: */
do do
{ {
nzUInt32 s0, s1;
ROUND256(a,b,c,d,e,f,g,h); ROUND256(a,b,c,d,e,f,g,h);
ROUND256(h,a,b,c,d,e,f,g); ROUND256(h,a,b,c,d,e,f,g);
ROUND256(g,h,a,b,c,d,e,f); ROUND256(g,h,a,b,c,d,e,f);

View File

@ -104,6 +104,9 @@ nzUInt8 NzHashDigest::operator[](unsigned int pos) const
NzHashDigest& NzHashDigest::operator=(const NzHashDigest& rhs) NzHashDigest& NzHashDigest::operator=(const NzHashDigest& rhs)
{ {
if (this == &rhs)
return *this;
m_hashName = rhs.m_hashName; m_hashName = rhs.m_hashName;
m_digestLength = rhs.m_digestLength; m_digestLength = rhs.m_digestLength;

View File

@ -1097,7 +1097,7 @@ unsigned int NzString::FindLastWord(const char* string, int start, nzUInt32 flag
{ {
if (it.base() != m_sharedString->string) if (it.base() != m_sharedString->string)
{ {
it--; --it;
if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator)) if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator))
continue; continue;
} }
@ -1139,7 +1139,7 @@ unsigned int NzString::FindLastWord(const char* string, int start, nzUInt32 flag
{ {
if (it.base() != m_sharedString->string) if (it.base() != m_sharedString->string)
{ {
it--; --it;
if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator)) if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator))
continue; continue;
} }
@ -1280,7 +1280,7 @@ unsigned int NzString::FindLastWord(const NzString& string, int start, nzUInt32
{ {
if (it.base() != m_sharedString->string) if (it.base() != m_sharedString->string)
{ {
it--; --it;
if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator)) if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator))
continue; continue;
} }
@ -1322,7 +1322,7 @@ unsigned int NzString::FindLastWord(const NzString& string, int start, nzUInt32
{ {
if (it.base() != m_sharedString->string) if (it.base() != m_sharedString->string)
{ {
it--; --it;
if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator)) if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator))
continue; continue;
} }
@ -1456,7 +1456,7 @@ unsigned int NzString::FindWord(const char* string, int start, nzUInt32 flags) c
{ {
if (it.base() != m_sharedString->string) if (it.base() != m_sharedString->string)
{ {
it--; --it;
if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator)) if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator))
continue; continue;
} }
@ -1478,8 +1478,8 @@ unsigned int NzString::FindWord(const char* string, int start, nzUInt32 flags) c
if (NzUnicode::GetLowercase(*tIt) != NzUnicode::GetLowercase(*p)) if (NzUnicode::GetLowercase(*tIt) != NzUnicode::GetLowercase(*p))
break; break;
p++; ++p;
tIt++; ++tIt;
} }
} }
} }
@ -1496,7 +1496,7 @@ unsigned int NzString::FindWord(const char* string, int start, nzUInt32 flags) c
{ {
if (it.base() != m_sharedString->string) if (it.base() != m_sharedString->string)
{ {
it--; --it;
if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator)) if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator))
continue; continue;
} }
@ -1518,8 +1518,8 @@ unsigned int NzString::FindWord(const char* string, int start, nzUInt32 flags) c
if (*tIt != *p) if (*tIt != *p)
break; break;
p++; ++p;
tIt++; ++tIt;
} }
} }
} }
@ -1628,7 +1628,7 @@ unsigned int NzString::FindWord(const NzString& string, int start, nzUInt32 flag
{ {
if (it.base() != m_sharedString->string) if (it.base() != m_sharedString->string)
{ {
it--; --it;
if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator)) if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator))
continue; continue;
} }
@ -1650,8 +1650,8 @@ unsigned int NzString::FindWord(const NzString& string, int start, nzUInt32 flag
if (NzUnicode::GetLowercase(*tIt) != NzUnicode::GetLowercase(*p)) if (NzUnicode::GetLowercase(*tIt) != NzUnicode::GetLowercase(*p))
break; break;
p++; ++p;
tIt++; ++tIt;
} }
} }
} }
@ -1668,7 +1668,7 @@ unsigned int NzString::FindWord(const NzString& string, int start, nzUInt32 flag
{ {
if (it.base() != m_sharedString->string) if (it.base() != m_sharedString->string)
{ {
it--; --it;
if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator)) if (!(NzUnicode::GetCategory(*it++) & NzUnicode::Category_Separator))
continue; continue;
} }
@ -1690,8 +1690,8 @@ unsigned int NzString::FindWord(const NzString& string, int start, nzUInt32 flag
if (*tIt != *p) if (*tIt != *p)
break; break;
p++; ++p;
tIt++; ++tIt;
} }
} }
} }

View File

@ -638,7 +638,7 @@ NzBoxf NzComputeAABB(NzSparsePtr<const NzVector3f> positionPtr, unsigned int ver
if (vertexCount > 0) if (vertexCount > 0)
{ {
aabb.Set(positionPtr->x, positionPtr->y, positionPtr->z, 0.f, 0.f, 0.f); aabb.Set(positionPtr->x, positionPtr->y, positionPtr->z, 0.f, 0.f, 0.f);
positionPtr++; --positionPtr;
for (unsigned int i = 1; i < vertexCount; ++i) for (unsigned int i = 1; i < vertexCount; ++i)
aabb.ExtendTo(*positionPtr++); aabb.ExtendTo(*positionPtr++);

View File

@ -333,6 +333,9 @@ bool NzSkeleton::IsValid() const
NzSkeleton& NzSkeleton::operator=(const NzSkeleton& skeleton) NzSkeleton& NzSkeleton::operator=(const NzSkeleton& skeleton)
{ {
if (this == &skeleton)
return *this;
Destroy(); Destroy();
if (skeleton.m_impl) if (skeleton.m_impl)