Skip to content

Commit 0dc29f0

Browse files
committed
Code cleanup
Fix some PVS-Studio warnings
1 parent 19aa7c8 commit 0dc29f0

File tree

11 files changed

+26
-46
lines changed

11 files changed

+26
-46
lines changed

src/xrCDB/xrCDB.h

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#pragma once
22

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

56
// forward declarations
67
class CFrustum;
@@ -10,7 +11,7 @@ class OPCODE_Model;
1011
class AABBNoLeafNode;
1112
};
1213
template <class T> class _box3;
13-
typedef _box3<float> Fbox;
14+
using Fbox = _box3<float>;
1415

1516

1617
#pragma pack(push, 8)
@@ -181,21 +182,13 @@ class XRCDB_API Collector
181182
}
182183
};
183184

184-
struct non_copyable
185-
{
186-
non_copyable() {}
187-
private:
188-
non_copyable(const non_copyable&) {}
189-
non_copyable& operator=(const non_copyable&) {}
190-
};
191-
192185
#pragma warning(push)
193186
#pragma warning(disable : 4275)
194187
const u32 clpMX = 24, clpMY = 16, clpMZ = 24;
195-
class XRCDB_API CollectorPacked : public non_copyable
188+
class XRCDB_API CollectorPacked : public Noncopyable
196189
{
197-
typedef xr_vector<u32> DWORDList;
198-
typedef DWORDList::iterator DWORDIt;
190+
using DWORDList = xr_vector<u32>;
191+
using DWORDIt = DWORDList::iterator;
199192

200193
private:
201194
xr_vector<Fvector> verts;

src/xrCore/Animation/Envelope.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,18 @@ the envelopes.
3636
#pragma pack(push, 1)
3737
struct st_Key
3838
{
39+
u8 shape;
3940
enum
4041
{
4142
ktStepped = 1 << 0,
4243
};
4344
float value;
4445
float time;
45-
u8 shape;
4646
float tension;
4747
float continuity;
4848
float bias;
4949
float param[4];
50+
5051
st_Key() { ZeroMemory(this, sizeof(st_Key)); }
5152
IC bool equal(const st_Key& tgt)
5253
{
@@ -124,10 +125,9 @@ class CExporter;
124125
class XRCORE_API CEnvelope
125126
{
126127
public:
127-
KeyVec keys;
128128
int behavior[2];
129+
KeyVec keys;
129130

130-
public:
131131
CEnvelope()
132132
{
133133
behavior[0] = 1;

src/xrCore/Animation/Motion.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@
1212
//------------------------------------------------------------------------------------------
1313
// CCustomMotion
1414
//------------------------------------------------------------------------------------------
15-
CCustomMotion::CCustomMotion()
16-
{
17-
iFrameStart = 0;
18-
iFrameEnd = 0;
19-
fFPS = 30.f;
20-
}
15+
CCustomMotion::CCustomMotion() : mtype(), iFrameStart(), iFrameEnd(), fFPS(30.) {}
2116

2217
CCustomMotion::CCustomMotion(CCustomMotion* source) { *this = *source; }
2318
CCustomMotion::~CCustomMotion() {}

src/xrCore/Crypto/xr_dsa_signer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
xr_dsa_signer::xr_dsa_signer(u8 const p_number[crypto::xr_dsa::public_key_length],
66
u8 const q_number[crypto::xr_dsa::private_key_length], u8 const g_number[crypto::xr_dsa::public_key_length])
7-
: m_dsa(p_number, q_number, g_number)
7+
: m_private_key(), m_dsa(p_number, q_number, g_number)
88
{
99
static_assert(crypto::xr_dsa::private_key_length == crypto::xr_sha256::digest_length,
1010
"Private key size must be equal to digest value size.");

src/xrCore/Crypto/xr_dsa_signer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class XRCORE_API xr_dsa_signer
2323
crypto::xr_dsa::private_key_t m_private_key;
2424

2525
private:
26-
xr_dsa_signer() : m_dsa(NULL, NULL, NULL){};
26+
xr_dsa_signer() : m_private_key(), m_dsa(nullptr, nullptr, nullptr){}
2727

2828
crypto::xr_dsa m_dsa;
2929
crypto::xr_sha256 m_sha;

src/xrCore/LocatorAPI.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ XRCORE_API void _dump_open_files(int mode)
149149
Log("----total count = ", g_open_files.size());
150150
}
151151

152-
CLocatorAPI::CLocatorAPI() :
152+
CLocatorAPI::CLocatorAPI() : bNoRecurse(true), m_auth_code(0),
153153
#ifdef CONFIG_PROFILE_LOCKS
154154
m_auth_lock(new Lock(MUTEX_PROFILE_ID(CLocatorAPI::m_auth_lock)))
155155
#else

src/xrCore/LzHuf.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
#include <io.h>
88
#include <fcntl.h>
9-
#include <sys\stat.h>
9+
#include <sys/stat.h>
1010

1111
#define MODULE
1212

@@ -77,7 +77,7 @@ class LZfs
7777
*out_iterator++ = u8(c & 0xFF);
7878
}
7979

80-
LZfs()
80+
LZfs() : getbuf(0), getlen(0), putbuf(0), putlen(0)
8181
{
8282
in_start = in_end = in_iterator = 0;
8383
out_start = out_end = out_iterator = 0;

src/xrCore/PostProcess/PostProcess.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#define POSTPROCESS_PARAMS_COUNT 11
77
//.#define POSTPROCESS_FILE_VERSION 0x0001
88
#define POSTPROCESS_FILE_VERSION 0x0002
9-
#define POSTPROCESS_FILE_EXTENSION ".ppe"
9+
constexpr pcstr POSTPROCESS_FILE_EXTENSION = ".ppe";
1010

1111
typedef enum _pp_params {
1212
pp_unknown = -1,
@@ -50,7 +50,7 @@ class XRCORE_API CPostProcessValue : public CPostProcessParam
5050
float* m_pfParam;
5151

5252
public:
53-
CPostProcessValue(float* pfparam) { m_pfParam = pfparam; }
53+
CPostProcessValue(float* pfparam) : m_pfParam(pfparam) {}
5454
virtual void update(float dt) { *m_pfParam = m_Value.Evaluate(dt); }
5555
virtual void load(IReader& pReader);
5656
virtual void save(IWriter& pWriter);
@@ -76,13 +76,13 @@ class XRCORE_API CPostProcessColor : public CPostProcessParam
7676
{
7777
protected:
7878
float m_fBase;
79+
SPPInfo::SColor* m_pColor;
7980
CEnvelope m_Red;
8081
CEnvelope m_Green;
8182
CEnvelope m_Blue;
82-
SPPInfo::SColor* m_pColor;
8383

8484
public:
85-
CPostProcessColor(SPPInfo::SColor* pcolor) { m_pColor = pcolor; }
85+
CPostProcessColor(SPPInfo::SColor* pcolor) : m_fBase(0.0), m_pColor(pcolor) {}
8686
virtual void update(float dt)
8787
{
8888
m_pColor->r = m_Red.Evaluate(dt);

src/xrEngine/EngineAPI.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,10 @@ constexpr pcstr r4_name = "xrRender_R4";
2020
// Construction/Destruction
2121
//////////////////////////////////////////////////////////////////////
2222

23-
void __cdecl dummy(void){};
24-
CEngineAPI::CEngineAPI()
25-
{
26-
hGame = 0;
27-
hRender = 0;
28-
hTuner = 0;
29-
pCreate = 0;
30-
pDestroy = 0;
31-
tune_pause = dummy;
32-
tune_resume = dummy;
33-
}
23+
void __cdecl dummy(void) {}
24+
25+
CEngineAPI::CEngineAPI(): hGame(nullptr), hRender(nullptr), hTuner(nullptr), pCreate(nullptr), pDestroy(nullptr),
26+
tune_enabled(false), tune_pause(dummy), tune_resume(dummy) {}
3427

3528
CEngineAPI::~CEngineAPI()
3629
{
@@ -222,7 +215,6 @@ void CEngineAPI::CreateRendererList()
222215
}
223216

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

239231
// try to initialize R4
240-
Log("Loading DLL:", r4_name);
241232
// Hide "d3d10.dll not found" message box for XP
242233
SetErrorMode(SEM_FAILCRITICALERRORS);
243234
hRender->open(r4_name);

src/xrEngine/device.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ SCRIPT_EXPORT(Device, (), {
497497
def("device", &get_device), def("is_enough_address_space_available", &is_enough_address_space_available)];
498498
});
499499

500-
CLoadScreenRenderer::CLoadScreenRenderer() : b_registered(false) {}
500+
CLoadScreenRenderer::CLoadScreenRenderer() : b_registered(false), b_need_user_input(false) {}
501501
void CLoadScreenRenderer::start(bool b_user_input)
502502
{
503503
Device.seqRender.Add(this, 0);

0 commit comments

Comments
 (0)