From 32c5ada995bf249b72018e9d54bc12706c913c8f Mon Sep 17 00:00:00 2001 From: Phillip Khandeliants Date: Thu, 27 Apr 2017 10:33:31 +0300 Subject: [PATCH 1/5] Fixed V591: Non-void function should return a value If there is needed to prevent the copying of the object, then there is no need to provide the definition of the copy constructor and the assignment operator, because the member functions and friendly functions can still call them. If the code is compiled by a compiler with support for the C++11 standard, you can delete them using the keyword 'delete' --- Engine/source/core/util/tSignal.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/source/core/util/tSignal.h b/Engine/source/core/util/tSignal.h index 206533458..4960ba8dd 100644 --- a/Engine/source/core/util/tSignal.h +++ b/Engine/source/core/util/tSignal.h @@ -161,8 +161,8 @@ protected: SignalSig *mSignal; private: - SignalSlot( const SignalSlot&) {} - SignalSlot& operator=( const SignalSlot&) {} + SignalSlot( const SignalSlot&); + SignalSlot& operator=( const SignalSlot&); }; template class SignalBaseT : public SignalBase From ffb943f3bb9641325070613e223b838044163e63 Mon Sep 17 00:00:00 2001 From: Phillip Khandeliants Date: Thu, 27 Apr 2017 11:29:03 +0300 Subject: [PATCH 2/5] Fixed V547: Expression is always false 'ov_read' function returns a signed long, that is stored in an unsigned integer 'bytesRead'. Comparsion 'bytesRead < 0' doesn't make sense, since an unsigned number >= 0. --- Engine/source/sfx/media/sfxVorbisStream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/sfx/media/sfxVorbisStream.cpp b/Engine/source/sfx/media/sfxVorbisStream.cpp index 1c9af326f..3a2f12ba6 100644 --- a/Engine/source/sfx/media/sfxVorbisStream.cpp +++ b/Engine/source/sfx/media/sfxVorbisStream.cpp @@ -198,7 +198,7 @@ S32 SFXVorbisStream::read( U8 *buffer, // requests longer than this. const U32 MAXREAD = 4096; - U32 bytesRead = 0; + S64 bytesRead = 0; U32 offset = 0; U32 bytesToRead = 0; From c0f3c4e2f50bb9b4baf91e9240ab878669b6ce84 Mon Sep 17 00:00:00 2001 From: Phillip Khandeliants Date: Thu, 27 Apr 2017 12:03:44 +0300 Subject: [PATCH 3/5] Fixed V547: Bad C-string comparsion This comparison of a string to an empty is meaningless, since in fact two pointers will be compared and the expression will always be false. --- Engine/source/console/consoleFunctions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/console/consoleFunctions.cpp b/Engine/source/console/consoleFunctions.cpp index bdf1d5cfe..fe55d4b29 100644 --- a/Engine/source/console/consoleFunctions.cpp +++ b/Engine/source/console/consoleFunctions.cpp @@ -2148,7 +2148,7 @@ DefineEngineFunction( displaySplashWindow, bool, (const char* path), (""), "@return True if the splash window could be successfully initialized.\n\n" "@ingroup Platform" ) { - if (path == "") + if (path == NULL || *path == '\0') { path = Con::getVariable("$Core::splashWindowImage"); } From 172391e1d3e48fc3e78d46b68d58e3d571010458 Mon Sep 17 00:00:00 2001 From: Phillip Khandeliants Date: Thu, 27 Apr 2017 12:13:05 +0300 Subject: [PATCH 4/5] Fixed V610: Undefined behavior In an arithmetic expression, all the variables whose values can be represented with type 'int' will be promoted to this type. Therefore, the result of the '~mask' expression is a negative number. By the C++ standard, shifting a negative number to the left leads to an undefined behavior. --- Engine/source/core/strings/unicode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/source/core/strings/unicode.cpp b/Engine/source/core/strings/unicode.cpp index 109327fe1..fd2341b7b 100644 --- a/Engine/source/core/strings/unicode.cpp +++ b/Engine/source/core/strings/unicode.cpp @@ -469,7 +469,7 @@ U32 oneUTF32toUTF8(const UTF32 codepoint, UTF8 *threeByteCodeunitBuf) //----------------- U8 mask = sgByteMask8LUT[0]; // 0011 1111 - U8 marker = ( ~mask << 1); // 1000 0000 + U8 marker = ( ~static_cast(mask) << 1u); // 1000 0000 // Process the low order bytes, shifting the codepoint down 6 each pass. for( S32 i = bytecount-1; i > 0; i--) From b741d9c1c25c0aa4d060b0585ae8e1ef433d494c Mon Sep 17 00:00:00 2001 From: Phillip Khandeliants Date: Thu, 27 Apr 2017 12:25:01 +0300 Subject: [PATCH 5/5] Fixed V570: Variable is assigned to itself The uninitialized variable 'box' is assigned to itself. Judging from the fact that this is a copy constructor, I think that it is necessary to store in the 'box' the value of 'cv.box' --- Engine/source/forest/forestCollision.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Engine/source/forest/forestCollision.h b/Engine/source/forest/forestCollision.h index f750fc85b..716ec8991 100644 --- a/Engine/source/forest/forestCollision.h +++ b/Engine/source/forest/forestCollision.h @@ -58,7 +58,7 @@ public: mData = cv.mData; mScale = cv.mScale; hullId = cv.hullId; - box = box; + box = cv.box; } void calculateTransform( const MatrixF &worldXfrm ); @@ -85,4 +85,4 @@ protected: }; -#endif // _FORESTCOLLISION_H_ \ No newline at end of file +#endif // _FORESTCOLLISION_H_