Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
Fix some PVS-Studio warnings
  • Loading branch information
Xottab-DUTY committed Dec 24, 2017
1 parent 19aa7c8 commit 0dc29f0
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 46 deletions.
17 changes: 5 additions & 12 deletions src/xrCDB/xrCDB.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "xrCore/Threading/Lock.hpp" // XXX: Remove from header. Put in .cpp.
#include "Common/Noncopyable.hpp"

// forward declarations
class CFrustum;
Expand All @@ -10,7 +11,7 @@ class OPCODE_Model;
class AABBNoLeafNode;
};
template <class T> class _box3;
typedef _box3<float> Fbox;
using Fbox = _box3<float>;


#pragma pack(push, 8)
Expand Down Expand Up @@ -181,21 +182,13 @@ class XRCDB_API Collector
}
};

struct non_copyable
{
non_copyable() {}
private:
non_copyable(const non_copyable&) {}
non_copyable& operator=(const non_copyable&) {}
};

#pragma warning(push)
#pragma warning(disable : 4275)
const u32 clpMX = 24, clpMY = 16, clpMZ = 24;
class XRCDB_API CollectorPacked : public non_copyable
class XRCDB_API CollectorPacked : public Noncopyable
{
typedef xr_vector<u32> DWORDList;
typedef DWORDList::iterator DWORDIt;
using DWORDList = xr_vector<u32>;
using DWORDIt = DWORDList::iterator;

private:
xr_vector<Fvector> verts;
Expand Down
6 changes: 3 additions & 3 deletions src/xrCore/Animation/Envelope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,18 @@ the envelopes.
#pragma pack(push, 1)
struct st_Key
{
u8 shape;
enum
{
ktStepped = 1 << 0,
};
float value;
float time;
u8 shape;
float tension;
float continuity;
float bias;
float param[4];

st_Key() { ZeroMemory(this, sizeof(st_Key)); }
IC bool equal(const st_Key& tgt)
{
Expand Down Expand Up @@ -124,10 +125,9 @@ class CExporter;
class XRCORE_API CEnvelope
{
public:
KeyVec keys;
int behavior[2];
KeyVec keys;

public:
CEnvelope()
{
behavior[0] = 1;
Expand Down
7 changes: 1 addition & 6 deletions src/xrCore/Animation/Motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
//------------------------------------------------------------------------------------------
// CCustomMotion
//------------------------------------------------------------------------------------------
CCustomMotion::CCustomMotion()
{
iFrameStart = 0;
iFrameEnd = 0;
fFPS = 30.f;
}
CCustomMotion::CCustomMotion() : mtype(), iFrameStart(), iFrameEnd(), fFPS(30.) {}

CCustomMotion::CCustomMotion(CCustomMotion* source) { *this = *source; }
CCustomMotion::~CCustomMotion() {}
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/Crypto/xr_dsa_signer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

xr_dsa_signer::xr_dsa_signer(u8 const p_number[crypto::xr_dsa::public_key_length],
u8 const q_number[crypto::xr_dsa::private_key_length], u8 const g_number[crypto::xr_dsa::public_key_length])
: m_dsa(p_number, q_number, g_number)
: m_private_key(), m_dsa(p_number, q_number, g_number)
{
static_assert(crypto::xr_dsa::private_key_length == crypto::xr_sha256::digest_length,
"Private key size must be equal to digest value size.");
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/Crypto/xr_dsa_signer.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class XRCORE_API xr_dsa_signer
crypto::xr_dsa::private_key_t m_private_key;

private:
xr_dsa_signer() : m_dsa(NULL, NULL, NULL){};
xr_dsa_signer() : m_private_key(), m_dsa(nullptr, nullptr, nullptr){}

crypto::xr_dsa m_dsa;
crypto::xr_sha256 m_sha;
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/LocatorAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ XRCORE_API void _dump_open_files(int mode)
Log("----total count = ", g_open_files.size());
}

CLocatorAPI::CLocatorAPI() :
CLocatorAPI::CLocatorAPI() : bNoRecurse(true), m_auth_code(0),
#ifdef CONFIG_PROFILE_LOCKS
m_auth_lock(new Lock(MUTEX_PROFILE_ID(CLocatorAPI::m_auth_lock)))
#else
Expand Down
4 changes: 2 additions & 2 deletions src/xrCore/LzHuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <io.h>
#include <fcntl.h>
#include <sys\stat.h>
#include <sys/stat.h>

#define MODULE

Expand Down Expand Up @@ -77,7 +77,7 @@ class LZfs
*out_iterator++ = u8(c & 0xFF);
}

LZfs()
LZfs() : getbuf(0), getlen(0), putbuf(0), putlen(0)
{
in_start = in_end = in_iterator = 0;
out_start = out_end = out_iterator = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/xrCore/PostProcess/PostProcess.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define POSTPROCESS_PARAMS_COUNT 11
//.#define POSTPROCESS_FILE_VERSION 0x0001
#define POSTPROCESS_FILE_VERSION 0x0002
#define POSTPROCESS_FILE_EXTENSION ".ppe"
constexpr pcstr POSTPROCESS_FILE_EXTENSION = ".ppe";

typedef enum _pp_params {
pp_unknown = -1,
Expand Down Expand Up @@ -50,7 +50,7 @@ class XRCORE_API CPostProcessValue : public CPostProcessParam
float* m_pfParam;

public:
CPostProcessValue(float* pfparam) { m_pfParam = pfparam; }
CPostProcessValue(float* pfparam) : m_pfParam(pfparam) {}
virtual void update(float dt) { *m_pfParam = m_Value.Evaluate(dt); }
virtual void load(IReader& pReader);
virtual void save(IWriter& pWriter);
Expand All @@ -76,13 +76,13 @@ class XRCORE_API CPostProcessColor : public CPostProcessParam
{
protected:
float m_fBase;
SPPInfo::SColor* m_pColor;
CEnvelope m_Red;
CEnvelope m_Green;
CEnvelope m_Blue;
SPPInfo::SColor* m_pColor;

public:
CPostProcessColor(SPPInfo::SColor* pcolor) { m_pColor = pcolor; }
CPostProcessColor(SPPInfo::SColor* pcolor) : m_fBase(0.0), m_pColor(pcolor) {}
virtual void update(float dt)
{
m_pColor->r = m_Red.Evaluate(dt);
Expand Down
17 changes: 4 additions & 13 deletions src/xrEngine/EngineAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,10 @@ constexpr pcstr r4_name = "xrRender_R4";
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

void __cdecl dummy(void){};
CEngineAPI::CEngineAPI()
{
hGame = 0;
hRender = 0;
hTuner = 0;
pCreate = 0;
pDestroy = 0;
tune_pause = dummy;
tune_resume = dummy;
}
void __cdecl dummy(void) {}

CEngineAPI::CEngineAPI(): hGame(nullptr), hRender(nullptr), hTuner(nullptr), pCreate(nullptr), pDestroy(nullptr),
tune_enabled(false), tune_pause(dummy), tune_resume(dummy) {}

CEngineAPI::~CEngineAPI()
{
Expand Down Expand Up @@ -222,7 +215,6 @@ void CEngineAPI::CreateRendererList()
}

// try to initialize R3
Log("Loading DLL:", r3_name);
// Hide "d3d10.dll not found" message box for XP
SetErrorMode(SEM_FAILCRITICALERRORS);
hRender->open(r3_name);
Expand All @@ -237,7 +229,6 @@ void CEngineAPI::CreateRendererList()
}

// try to initialize R4
Log("Loading DLL:", r4_name);
// Hide "d3d10.dll not found" message box for XP
SetErrorMode(SEM_FAILCRITICALERRORS);
hRender->open(r4_name);
Expand Down
2 changes: 1 addition & 1 deletion src/xrEngine/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ SCRIPT_EXPORT(Device, (), {
def("device", &get_device), def("is_enough_address_space_available", &is_enough_address_space_available)];
});

CLoadScreenRenderer::CLoadScreenRenderer() : b_registered(false) {}
CLoadScreenRenderer::CLoadScreenRenderer() : b_registered(false), b_need_user_input(false) {}
void CLoadScreenRenderer::start(bool b_user_input)
{
Device.seqRender.Add(this, 0);
Expand Down
5 changes: 3 additions & 2 deletions src/xrEngine/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,10 +177,11 @@ class ENGINE_API CRenderDevice : public CRenderDeviceBase
Fmatrix mInvFullTransform;

CRenderDevice()
: m_dwWindowStyle(0)
: m_dwWindowStyle(0), fWidth_2(0), fHeight_2(0)
#ifdef INGAME_EDITOR
,
m_editor_module(nullptr), m_editor_initialize(nullptr), m_editor_finalize(nullptr), m_editor(nullptr), m_engine(nullptr)
m_editor_module(nullptr), m_editor_initialize(nullptr),
m_editor_finalize(nullptr), m_editor(nullptr), m_engine(nullptr)
#endif // #ifdef INGAME_EDITOR
{
m_hWnd = NULL;
Expand Down

0 comments on commit 0dc29f0

Please sign in to comment.