1
0
forked from 0ad/0ad

Fix some static analysis warnings

This was SVN commit r13101.
This commit is contained in:
Ykkrosh 2013-01-21 20:33:25 +00:00
parent c037e3f78e
commit 75a23856cf
11 changed files with 22 additions and 12 deletions

View File

@ -97,7 +97,7 @@ bool CClientArea::SetClientArea(const CStr& Value)
if (!line.m_ParseOK)
return false;
int arg_count[4]; // argument counts for the four values
int arg_count[4] = {0,0,0,0}; // argument counts for the four values
int arg_start[4] = {0,0,0,0}; // location of first argument, [0] is always 0
// Divide into the four piles (delimiter is an argument named "delim")

View File

@ -578,6 +578,7 @@ void CConsole::SetBuffer(const wchar_t* szMessage)
FlushBuffer();
wcsncpy(m_szBuffer, szMessage, CONSOLE_BUFFER_SIZE);
m_szBuffer[CONSOLE_BUFFER_SIZE-1] = 0;
m_iBufferLength = (int)wcslen(m_szBuffer);
m_iBufferPos = std::min(oldBufferPos, m_iBufferLength);
}

View File

@ -41,8 +41,7 @@ bool CColor::ParseString(const CStr8& Value, float DefaultAlpha)
// TODO Gee: Parsing failed
return false;
}
float values[4];
values[3] = DefaultAlpha;
float values[4] = { 0, 0, 0, DefaultAlpha };
for (int i=0; i<(int)line.GetArgCount(); ++i)
{
if (!line.GetArgFloat(i, values[i]))

View File

@ -439,6 +439,9 @@ namespace
f << "\n\n" << table->GetTitle() << "\n";
if (cols == 0) // avoid divide-by-zero
return;
for (size_t r = 0; r < data.size()/cols; ++r)
{
for (size_t c = 0; c < cols; ++c)

View File

@ -659,14 +659,14 @@ private:
if (counter.type == INTEL_PERFQUERIES_TYPE_UNSIGNED_INT)
{
ENSURE(counter.size == 4);
GLuint value;
GLuint value = 0;
memcpy(&value, buf + counter.offset, counter.size);
m_Storage.RecordAttributePrintf("%s: %u", counter.name.c_str(), value);
}
else if (counter.type == INTEL_PERFQUERIES_TYPE_UNSIGNED_INT64)
{
ENSURE(counter.size == 8);
GLuint64 value;
GLuint64 value = 0;
memcpy(&value, buf + counter.offset, counter.size);
m_Storage.RecordAttributePrintf("%s: %.0f", counter.name.c_str(), (double)value);
@ -676,14 +676,14 @@ private:
else if (counter.type == INTEL_PERFQUERIES_TYPE_FLOAT)
{
ENSURE(counter.size == 4);
GLfloat value;
GLfloat value = 0;
memcpy(&value, buf + counter.offset, counter.size);
m_Storage.RecordAttributePrintf("%s: %f", counter.name.c_str(), value);
}
else if (counter.type == INTEL_PERFQUERIES_TYPE_BOOL)
{
ENSURE(counter.size == 4);
GLuint value;
GLuint value = 0;
memcpy(&value, buf + counter.offset, counter.size);
ENSURE(value == 0 || value == 1);
m_Storage.RecordAttributePrintf("%s: %u", counter.name.c_str(), value);

View File

@ -249,4 +249,6 @@ void CReplayPlayer::Replay()
delete &g_Profiler;
delete &g_ProfileViewer;
g_Game = NULL;
}

View File

@ -1476,7 +1476,7 @@ void CRenderer::RenderSubmissions()
if (waterScissor.GetVolume() > 0 && m_WaterManager->WillRenderFancyWater())
{
PROFILE3_GPU("water scissor");
SScreenRect dirty;
SScreenRect dirty = { 0, 0, 0, 0 };
if (m_Options.m_WaterRefraction && m_Options.m_WaterReflection)
{
SScreenRect reflectionScissor = RenderReflections(context, waterScissor);

View File

@ -35,7 +35,6 @@
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/random/linear_congruential.hpp>
#include <boost/random/uniform_real.hpp>
#include <boost/flyweight.hpp>
#include <boost/flyweight/key_value.hpp>
#include <boost/flyweight/no_locking.hpp>

View File

@ -83,13 +83,14 @@ JSIdArray* AutoJSIdArray::get() const
size_t AutoJSIdArray::length() const
{
ENSURE(m_IdArray);
if (!m_IdArray)
return 0;
return m_IdArray->length;
}
jsid AutoJSIdArray::operator[](size_t i) const
{
ENSURE(m_IdArray);
ENSURE(i < (size_t)m_IdArray->length);
if (!(m_IdArray && i < (size_t)m_IdArray->length))
return JSID_VOID;
return m_IdArray->vector[i];
}

View File

@ -1449,6 +1449,10 @@ public:
}
}
}
if (overallVisibleVertices == 0) // avoid divide-by-zero
return 0;
return exploredVertices * 100 / overallVisibleVertices;
}
};

View File

@ -327,6 +327,7 @@ bool BeginAtlas(const CmdLineArgs& args, const DllLoader& dll)
// Clean up
AtlasView::DestroyViews();
ScriptingHost::FinalShutdown();
AtlasMessage::g_MessagePasser = NULL;
return true;
}