Skip to content

Commit fb64ae3

Browse files
committed
Fix some anomalies found with PVS-Studio (#140)
1 parent d9e24a5 commit fb64ae3

File tree

19 files changed

+24
-24
lines changed

19 files changed

+24
-24
lines changed

src/Layers/xrRenderPC_R1/FStaticRender_RenderTarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ CRenderTarget::CRenderTarget()
2626
param_color_map_influence = 0.0f;
2727
param_color_map_interpolate = 0.0f;
2828

29-
im_noise_time = 1 / 100;
29+
im_noise_time = 1 / 100.0f;
3030
im_noise_shift_w = 0;
3131
im_noise_shift_h = 0;
3232

src/Layers/xrRenderPC_R2/r2_rendertarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ CRenderTarget::CRenderTarget()
195195
param_noise_fps = 25.f;
196196
param_noise_scale = 1.f;
197197

198-
im_noise_time = 1 / 100;
198+
im_noise_time = 1 / 100.0f;
199199
im_noise_shift_w = 0;
200200
im_noise_shift_h = 0;
201201

src/Layers/xrRenderPC_R3/r3_rendertarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ CRenderTarget::CRenderTarget()
291291
param_noise_fps = 25.f;
292292
param_noise_scale = 1.f;
293293

294-
im_noise_time = 1 / 100;
294+
im_noise_time = 1 / 100.0f;
295295
im_noise_shift_w = 0;
296296
im_noise_shift_h = 0;
297297

src/Layers/xrRenderPC_R4/r4_rendertarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ CRenderTarget::CRenderTarget()
293293
param_noise_fps = 25.f;
294294
param_noise_scale = 1.f;
295295

296-
im_noise_time = 1 / 100;
296+
im_noise_time = 1 / 100.0f;
297297
im_noise_shift_w = 0;
298298
im_noise_shift_h = 0;
299299

src/utils/LWO/lwio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ int sgetI1(unsigned char** bp)
335335
if (i > 127)
336336
i -= 256;
337337
flen += 1;
338-
*bp++;
338+
(*bp)++;
339339
return i;
340340
}
341341

@@ -373,7 +373,7 @@ unsigned char sgetU1(unsigned char** bp)
373373
return 0;
374374
c = **bp;
375375
flen += 1;
376-
*bp++;
376+
(*bp)++;
377377
return c;
378378
}
379379

src/utils/LWO/lwob.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static int add_clip(char* s, lwClip** clist, int* nclips)
7979
clip->source.still.name = s;
8080
}
8181

82-
*nclips++;
82+
(*nclips)++;
8383
clip->index = *nclips;
8484

8585
lwListAdd(clist, clip);

src/utils/xrDXT/NVI_Image.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ void NVI_Image::ABGR8_To_ARGB8()
151151
{
152152
DWORD col;
153153
GetPixel_ARGB8(&col, i);
154-
DWORD a = (col >> 24) && 0x000000FF;
155-
DWORD b = (col >> 16) && 0x000000FF;
156-
DWORD g = (col >> 8) && 0x000000FF;
157-
DWORD r = (col >> 0) && 0x000000FF;
154+
DWORD a = (col >> 24) & 0x000000FF;
155+
DWORD b = (col >> 16) & 0x000000FF;
156+
DWORD g = (col >> 8) & 0x000000FF;
157+
DWORD r = (col >> 0) & 0x000000FF;
158158
col = (a << 24) | (r << 16) | (g << 8) | b;
159159
SetPixel_ARGB8(i, col);
160160
}

src/utils/xrDXT/dds/tPixel.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,7 @@ class RGBAMipMappedCubeMap
952952
const RGBAMipMappedImage& operator[](size_t i) const { return cubeFaces[i]; }
953953
size_t numMIPMaps() const { return cubeFaces[0].numMIPMaps(); }
954954
size_t height() const { return cubeFaces[0].height(); }
955-
size_t width() const { return cubeFaces[0].height(); }
955+
size_t width() const { return cubeFaces[0].width(); }
956956
void clear()
957957
{
958958
for (size_t f = 0; f < 6; f++)
@@ -1140,7 +1140,7 @@ class fpMipMappedCubeMap
11401140
const fpMipMappedImage& operator[](size_t i) const { return cubeFaces[i]; }
11411141
size_t numMIPMaps() const { return cubeFaces[0].numMIPMaps(); }
11421142
size_t height() const { return cubeFaces[0].height(); }
1143-
size_t width() const { return cubeFaces[0].height(); }
1143+
size_t width() const { return cubeFaces[0].width(); }
11441144
void clear()
11451145
{
11461146
for (size_t f = 0; f < 6; f++)

src/utils/xrQSlim/src/MxQMetric.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ MxMatrix& MxQuadric::homogeneous(MxMatrix& H) const
8181
unsigned int i, j;
8282

8383
for (i = 0; i < A.dim(); i++)
84-
for (j = 0; j < A.dim(); i++)
84+
for (j = 0; j < A.dim(); j++)
8585
H(i, j) = A(i, j);
8686

8787
for (i = 0; i < b.dim(); i++)

src/xrCore/_matrix33.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ struct _matrix33
377377
R.x = s1 * (m[0][0] * V1.x + m[1][0] * V1.y + m[2][0] * V1.z);
378378
R.y = s1 * (m[0][1] * V1.x + m[1][1] * V1.y + m[2][1] * V1.z);
379379
R.z = s1 * (m[0][2] * V1.x + m[1][2] * V1.y + m[2][2] * V1.z);
380+
return *this;
380381
}
381382
IC SelfRef MxV(Tvector& R, const Tvector& V1) const
382383
{

src/xrCore/xrDebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ size_t xrDebug::BuildStackTrace(char* buffer, size_t capacity, size_t lineCapaci
9797

9898
size_t xrDebug::BuildStackTrace(EXCEPTION_POINTERS* exPtrs, char* buffer, size_t capacity, size_t lineCapacity)
9999
{
100-
memset(buffer, capacity * lineCapacity, 0);
100+
memset(buffer, 0, capacity*lineCapacity);
101101
auto flags = GSTSO_MODULE | GSTSO_SYMBOL | GSTSO_SRCLINE;
102102
auto traceDump = GetFirstStackTraceString(flags, exPtrs);
103103
int frameCount = 0;

src/xrGame/Actor_Network.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ BOOL CActor::net_Spawn(CSE_Abstract* DC)
685685
inventory().SetPrevActiveSlot(NO_ACTIVE_SLOT);
686686

687687
//-------------------------------------
688-
m_States.empty();
688+
m_States.clear(); // Xottab_DUTY: check if replace is correct
689689
//-------------------------------------
690690
if (!g_Alive())
691691
{

src/xrGame/BoneProtections.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void SBoneProtections::reload(const shared_str& bone_sect, IKinematics* kinemati
5151

5252
BP.koeff = (float)atof(_GetItem(i->second.c_str(), 0, buffer));
5353
BP.armor = (float)atof(_GetItem(i->second.c_str(), 1, buffer));
54-
BP.BonePassBullet = (BOOL)(atoi(_GetItem(i->second.c_str(), 2, buffer)) > 0.5f);
54+
BP.BonePassBullet = (BOOL)(atof(_GetItem(i->second.c_str(), 2, buffer)) > 0.5f);
5555

5656
if (!xr_strcmp(i->first.c_str(), "default"))
5757
{

src/xrGame/HudItem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ BOOL CHudItem::GetHUDmode()
299299
if (object().H_Parent())
300300
{
301301
CActor* A = smart_cast<CActor*>(object().H_Parent());
302-
return (A && A->HUDview() && HudItemData() && HudItemData());
302+
return (A && A->HUDview() && HudItemData());
303303
}
304304
else
305305
return FALSE;

src/xrGame/ai/monsters/basemonster/base_monster_startup.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,10 +449,10 @@ void CBaseMonster::settings_read(CInifile const* ini, LPCSTR section, SMonsterSe
449449
if (ini->line_exist(ppi_section, "color_base"))
450450
sscanf(ini->r_string(ppi_section, "color_base"), "%f,%f,%f", &data.m_attack_effector.ppi.color_base.r,
451451
&data.m_attack_effector.ppi.color_base.g, &data.m_attack_effector.ppi.color_base.b);
452-
if (ini->line_exist(ppi_section, "color_base"))
452+
if (ini->line_exist(ppi_section, "color_gray"))
453453
sscanf(ini->r_string(ppi_section, "color_gray"), "%f,%f,%f", &data.m_attack_effector.ppi.color_gray.r,
454454
&data.m_attack_effector.ppi.color_gray.g, &data.m_attack_effector.ppi.color_gray.b);
455-
if (ini->line_exist(ppi_section, "color_base"))
455+
if (ini->line_exist(ppi_section, "color_add"))
456456
sscanf(ini->r_string(ppi_section, "color_add"), "%f,%f,%f", &data.m_attack_effector.ppi.color_add.r,
457457
&data.m_attack_effector.ppi.color_add.g, &data.m_attack_effector.ppi.color_add.b);
458458

src/xrGame/ai/monsters/rats/ai_rat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ void CAI_Rat::UpdateCL()
487487
CMonsterSquad* squad = monster_squad().get_squad(this);
488488

489489
if (squad &&
490-
((squad->GetLeader() != this && !squad->GetLeader()->g_Alive()) || squad->get_index(this) == u32(-1)))
490+
((squad->GetLeader() != this && !squad->GetLeader()->g_Alive()) || squad->get_index(this) == u8(-1)))
491491
squad->SetLeader(this);
492492

493493
if (squad && squad->SquadActive() && squad->GetLeader() == this && m_squad_count != squad->squad_alife_count())

src/xrGame/relation_registry.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ RELATION_REGISTRY::RELATION_MAP_SPOTS::RELATION_MAP_SPOTS()
4747
spot_names[ALife::eRelationTypeNeutral] = "neutral_location";
4848
spot_names[ALife::eRelationTypeEnemy] = "enemy_location";
4949
spot_names[ALife::eRelationTypeWorstEnemy] = "enemy_location";
50-
spot_names[ALife::eRelationTypeWorstEnemy] = "enemy_location";
5150
spot_names[ALife::eRelationTypeLast] = "neutral_location";
5251
}
5352
//////////////////////////////////////////////////////////////////////////

src/xrGame/space_restriction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ CSpaceRestriction::CBaseRestrictionPtr CSpaceRestriction::merge(
152152
RESTRICTIONS::const_iterator I = temp_restrictions.begin();
153153
RESTRICTIONS::const_iterator E = temp_restrictions.end();
154154
for (; I != E; ++I)
155-
temp = strconcat(sizeof(S), S, *temp, ",", *(*I)->name());
155+
temp = strconcat(acc_length, S, *temp, ",", *(*I)->name());
156156

157157
xr_free(S);
158158

src/xrGame/ui/UIMpTradeWnd_misc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ CUIDragDropListEx* CUIMpTradeWnd::GetMatchedListForItem(const shared_str& sect_n
373373
return m_list[e_player_bag];
374374
}
375375

376-
if (list_idx == e_pistol || list_idx == e_rifle || list_idx == e_outfit || list_idx == e_outfit)
376+
if (list_idx == e_pistol || list_idx == e_rifle || list_idx == e_outfit)
377377
{
378378
if (m_list[list_idx]->ItemsCount())
379379
return m_list[e_player_bag];

0 commit comments

Comments
 (0)