Skip to content

Commit

Permalink
Fix some anomalies found with PVS-Studio (#140)
Browse files Browse the repository at this point in the history
  • Loading branch information
Xottab-DUTY committed Mar 11, 2017
1 parent d9e24a5 commit fb64ae3
Show file tree
Hide file tree
Showing 19 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R1/FStaticRender_RenderTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ CRenderTarget::CRenderTarget()
param_color_map_influence = 0.0f;
param_color_map_interpolate = 0.0f;

im_noise_time = 1 / 100;
im_noise_time = 1 / 100.0f;
im_noise_shift_w = 0;
im_noise_shift_h = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R2/r2_rendertarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ CRenderTarget::CRenderTarget()
param_noise_fps = 25.f;
param_noise_scale = 1.f;

im_noise_time = 1 / 100;
im_noise_time = 1 / 100.0f;
im_noise_shift_w = 0;
im_noise_shift_h = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R3/r3_rendertarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ CRenderTarget::CRenderTarget()
param_noise_fps = 25.f;
param_noise_scale = 1.f;

im_noise_time = 1 / 100;
im_noise_time = 1 / 100.0f;
im_noise_shift_w = 0;
im_noise_shift_h = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/Layers/xrRenderPC_R4/r4_rendertarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ CRenderTarget::CRenderTarget()
param_noise_fps = 25.f;
param_noise_scale = 1.f;

im_noise_time = 1 / 100;
im_noise_time = 1 / 100.0f;
im_noise_shift_w = 0;
im_noise_shift_h = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/utils/LWO/lwio.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ int sgetI1(unsigned char** bp)
if (i > 127)
i -= 256;
flen += 1;
*bp++;
(*bp)++;
return i;
}

Expand Down Expand Up @@ -373,7 +373,7 @@ unsigned char sgetU1(unsigned char** bp)
return 0;
c = **bp;
flen += 1;
*bp++;
(*bp)++;
return c;
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/LWO/lwob.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static int add_clip(char* s, lwClip** clist, int* nclips)
clip->source.still.name = s;
}

*nclips++;
(*nclips)++;
clip->index = *nclips;

lwListAdd(clist, clip);
Expand Down
8 changes: 4 additions & 4 deletions src/utils/xrDXT/NVI_Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ void NVI_Image::ABGR8_To_ARGB8()
{
DWORD col;
GetPixel_ARGB8(&col, i);
DWORD a = (col >> 24) && 0x000000FF;
DWORD b = (col >> 16) && 0x000000FF;
DWORD g = (col >> 8) && 0x000000FF;
DWORD r = (col >> 0) && 0x000000FF;
DWORD a = (col >> 24) & 0x000000FF;
DWORD b = (col >> 16) & 0x000000FF;
DWORD g = (col >> 8) & 0x000000FF;
DWORD r = (col >> 0) & 0x000000FF;
col = (a << 24) | (r << 16) | (g << 8) | b;
SetPixel_ARGB8(i, col);
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/xrDXT/dds/tPixel.h
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ class RGBAMipMappedCubeMap
const RGBAMipMappedImage& operator[](size_t i) const { return cubeFaces[i]; }
size_t numMIPMaps() const { return cubeFaces[0].numMIPMaps(); }
size_t height() const { return cubeFaces[0].height(); }
size_t width() const { return cubeFaces[0].height(); }
size_t width() const { return cubeFaces[0].width(); }
void clear()
{
for (size_t f = 0; f < 6; f++)
Expand Down Expand Up @@ -1140,7 +1140,7 @@ class fpMipMappedCubeMap
const fpMipMappedImage& operator[](size_t i) const { return cubeFaces[i]; }
size_t numMIPMaps() const { return cubeFaces[0].numMIPMaps(); }
size_t height() const { return cubeFaces[0].height(); }
size_t width() const { return cubeFaces[0].height(); }
size_t width() const { return cubeFaces[0].width(); }
void clear()
{
for (size_t f = 0; f < 6; f++)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/xrQSlim/src/MxQMetric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ MxMatrix& MxQuadric::homogeneous(MxMatrix& H) const
unsigned int i, j;

for (i = 0; i < A.dim(); i++)
for (j = 0; j < A.dim(); i++)
for (j = 0; j < A.dim(); j++)
H(i, j) = A(i, j);

for (i = 0; i < b.dim(); i++)
Expand Down
1 change: 1 addition & 0 deletions src/xrCore/_matrix33.h
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ struct _matrix33
R.x = s1 * (m[0][0] * V1.x + m[1][0] * V1.y + m[2][0] * V1.z);
R.y = s1 * (m[0][1] * V1.x + m[1][1] * V1.y + m[2][1] * V1.z);
R.z = s1 * (m[0][2] * V1.x + m[1][2] * V1.y + m[2][2] * V1.z);
return *this;
}
IC SelfRef MxV(Tvector& R, const Tvector& V1) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrCore/xrDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ size_t xrDebug::BuildStackTrace(char* buffer, size_t capacity, size_t lineCapaci

size_t xrDebug::BuildStackTrace(EXCEPTION_POINTERS* exPtrs, char* buffer, size_t capacity, size_t lineCapacity)
{
memset(buffer, capacity * lineCapacity, 0);
memset(buffer, 0, capacity*lineCapacity);
auto flags = GSTSO_MODULE | GSTSO_SYMBOL | GSTSO_SRCLINE;
auto traceDump = GetFirstStackTraceString(flags, exPtrs);
int frameCount = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/Actor_Network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ BOOL CActor::net_Spawn(CSE_Abstract* DC)
inventory().SetPrevActiveSlot(NO_ACTIVE_SLOT);

//-------------------------------------
m_States.empty();
m_States.clear(); // Xottab_DUTY: check if replace is correct
//-------------------------------------
if (!g_Alive())
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/BoneProtections.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void SBoneProtections::reload(const shared_str& bone_sect, IKinematics* kinemati

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

if (!xr_strcmp(i->first.c_str(), "default"))
{
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/HudItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ BOOL CHudItem::GetHUDmode()
if (object().H_Parent())
{
CActor* A = smart_cast<CActor*>(object().H_Parent());
return (A && A->HUDview() && HudItemData() && HudItemData());
return (A && A->HUDview() && HudItemData());
}
else
return FALSE;
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/ai/monsters/basemonster/base_monster_startup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,10 +449,10 @@ void CBaseMonster::settings_read(CInifile const* ini, LPCSTR section, SMonsterSe
if (ini->line_exist(ppi_section, "color_base"))
sscanf(ini->r_string(ppi_section, "color_base"), "%f,%f,%f", &data.m_attack_effector.ppi.color_base.r,
&data.m_attack_effector.ppi.color_base.g, &data.m_attack_effector.ppi.color_base.b);
if (ini->line_exist(ppi_section, "color_base"))
if (ini->line_exist(ppi_section, "color_gray"))
sscanf(ini->r_string(ppi_section, "color_gray"), "%f,%f,%f", &data.m_attack_effector.ppi.color_gray.r,
&data.m_attack_effector.ppi.color_gray.g, &data.m_attack_effector.ppi.color_gray.b);
if (ini->line_exist(ppi_section, "color_base"))
if (ini->line_exist(ppi_section, "color_add"))
sscanf(ini->r_string(ppi_section, "color_add"), "%f,%f,%f", &data.m_attack_effector.ppi.color_add.r,
&data.m_attack_effector.ppi.color_add.g, &data.m_attack_effector.ppi.color_add.b);

Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ai/monsters/rats/ai_rat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ void CAI_Rat::UpdateCL()
CMonsterSquad* squad = monster_squad().get_squad(this);

if (squad &&
((squad->GetLeader() != this && !squad->GetLeader()->g_Alive()) || squad->get_index(this) == u32(-1)))
((squad->GetLeader() != this && !squad->GetLeader()->g_Alive()) || squad->get_index(this) == u8(-1)))
squad->SetLeader(this);

if (squad && squad->SquadActive() && squad->GetLeader() == this && m_squad_count != squad->squad_alife_count())
Expand Down
1 change: 0 additions & 1 deletion src/xrGame/relation_registry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ RELATION_REGISTRY::RELATION_MAP_SPOTS::RELATION_MAP_SPOTS()
spot_names[ALife::eRelationTypeNeutral] = "neutral_location";
spot_names[ALife::eRelationTypeEnemy] = "enemy_location";
spot_names[ALife::eRelationTypeWorstEnemy] = "enemy_location";
spot_names[ALife::eRelationTypeWorstEnemy] = "enemy_location";
spot_names[ALife::eRelationTypeLast] = "neutral_location";
}
//////////////////////////////////////////////////////////////////////////
Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/space_restriction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ CSpaceRestriction::CBaseRestrictionPtr CSpaceRestriction::merge(
RESTRICTIONS::const_iterator I = temp_restrictions.begin();
RESTRICTIONS::const_iterator E = temp_restrictions.end();
for (; I != E; ++I)
temp = strconcat(sizeof(S), S, *temp, ",", *(*I)->name());
temp = strconcat(acc_length, S, *temp, ",", *(*I)->name());

xr_free(S);

Expand Down
2 changes: 1 addition & 1 deletion src/xrGame/ui/UIMpTradeWnd_misc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ CUIDragDropListEx* CUIMpTradeWnd::GetMatchedListForItem(const shared_str& sect_n
return m_list[e_player_bag];
}

if (list_idx == e_pistol || list_idx == e_rifle || list_idx == e_outfit || list_idx == e_outfit)
if (list_idx == e_pistol || list_idx == e_rifle || list_idx == e_outfit)
{
if (m_list[list_idx]->ItemsCount())
return m_list[e_player_bag];
Expand Down

0 comments on commit fb64ae3

Please sign in to comment.