Skip to content

Commit

Permalink
Merge pull request #20 from fiendish/master
Browse files Browse the repository at this point in the history
random finds from static code analysis
  • Loading branch information
nickgammon committed Mar 21, 2016
2 parents 8c0f2ef + f425baa commit b673264
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 23 deletions.
4 changes: 3 additions & 1 deletion Dmetaph.cpp
Expand Up @@ -109,8 +109,10 @@ bool MString::StringAt(int start, int length, ... )
do
{
test = va_arg(sstrings, char*);
if(*test AND (target == test))
if(*test AND (target == test)) {
va_end(sstrings);
return true;
}

}while(strcmp(test, ""));

Expand Down
6 changes: 1 addition & 5 deletions dialogs/world_prefs/aliasdlg.cpp
Expand Up @@ -171,11 +171,7 @@ void CAliasDlg::DoDataExchange(CDataExchange* pDX)
if (m_bRegexp)
{
if (!CheckRegularExpression (m_name, (m_bIgnoreCase ? 0 : PCRE_CASELESS)
| (m_pDoc->m_bUTF_8 ? PCRE_UTF8 : 0)
#if ALIASES_USE_UTF8
| (m_pDoc->m_bUTF_8 ? PCRE_UTF8 : 0)
#endif // ALIASES_USE_UTF8

| (m_pDoc->m_bUTF_8 ? PCRE_UTF8 : 0)
))
{ // failed check
DDX_Text(pDX, IDC_ALIAS_NAME, m_name);
Expand Down
13 changes: 7 additions & 6 deletions luacom/tCOMUtil.cpp
Expand Up @@ -367,9 +367,8 @@ ITypeLib* tCOMUtil::LoadTypeLibFromProgID(const char* ProgID,
return NULL;

bool version_found = false;
int version = -1;

if(major_version <= 0)
if(major_version == 0)
{
if(sscanf(ProgID, "%*s.%*s.%d", &major_version) == 1)
version_found = true;
Expand Down Expand Up @@ -471,6 +470,7 @@ ITypeLib* tCOMUtil::LoadTypeLibFromCLSID(CLSID clsid,

if(pcClsid)
free(pcClsid);
free(bLibID);

return NULL;
}
Expand All @@ -496,8 +496,7 @@ ITypeLib* tCOMUtil::LoadTypeLibFromCLSID(CLSID clsid,

if(major_version > 0 &&
(
(!version_info_found) ||
(version_info_found && found == 0)
(!version_info_found) || (found == 0)
)
)
{
Expand All @@ -513,8 +512,11 @@ ITypeLib* tCOMUtil::LoadTypeLibFromCLSID(CLSID clsid,
&version_major,
&version_minor);

if(!result)
if(!result) {
free(bLibID);
free(wcTypelib);
return NULL;
}
}

free(bLibID);
Expand Down Expand Up @@ -703,7 +705,6 @@ bool tCOMUtil::DelRegKey(const char *key,
const char *subkey)
{

bool ok = false;
LONG ec = 0;

const int bufsize = 10000;
Expand Down
6 changes: 3 additions & 3 deletions luacom/tLuaCOMConnPoints.cpp
Expand Up @@ -44,7 +44,7 @@ tLuaCOMEnumConnPoints::tLuaCOMEnumConnPoints(IUnknown* pHostObj)
cRefs = 0;

// Assign the Host Object pointer.
pHostObj = pHostObj;
this->pHostObj = pHostObj;

// Initialize the Connection Point enumerator variables.
iEnumIndex = 0;
Expand Down Expand Up @@ -453,7 +453,7 @@ tLuaCOMConnPoint::tLuaCOMConnPoint(lua_State *p_L,
// this connection point. Since this connection point object's lifetime
// is geared to that of the connectable object there is no need to
// AddRef the following copied pointer to the connectable object.
pHostObj = pHostObj;
this->pHostObj = pHostObj;

// Initialize the Connection Point variables.
dwNextCookie = COOKIE_START_VALUE;
Expand Down Expand Up @@ -973,7 +973,7 @@ tLuaCOMEnumConnections::tLuaCOMEnumConnections(
cRefs = 0;

// Assign the Host Object pointer.
pHostObj = pHostObj;
this->pHostObj = pHostObj;

// Initialize the Connection Point enumerator variables.
iEnumIndex = 0;
Expand Down
4 changes: 2 additions & 2 deletions luacom/tLuaVector.cpp
Expand Up @@ -50,7 +50,7 @@ unsigned long tLuaVector::get_Dimensions()
unsigned long tLuaVector::get_Nth_Dimension(unsigned long n)
{
// precond
CHECKPRECOND(length >= 0 && n >= 0 && (n == 1 || elem_type == VECTOR));
CHECKPRECOND(n == 1 || elem_type == VECTOR);

if(n == 1)
return length;
Expand Down Expand Up @@ -323,7 +323,7 @@ void tLuaVector::InitVectorFromTable(lua_State* L, stkIndex table)
// Itera em tabela ou userdata, criando LuaVectors recursivamente
while(1)
{
CHECKPRECOND((length <= 0 || elem_type != UNKNOWN) &&
CHECKPRECOND((elem_type != UNKNOWN) &&
(length != 0 || elem_type == UNKNOWN));

lua_pushvalue(L, table);
Expand Down
8 changes: 4 additions & 4 deletions mcdatetime.cpp
Expand Up @@ -70,13 +70,13 @@ CmcDateTime CmcDateTime::operator-(const CmcDateTimeSpan& dateSpan) const
} // end of CmcDateTime CmcDateTime::operator-


const CmcDateTime& CmcDateTime::operator+=(const CmcDateTimeSpan dateSpan)
const CmcDateTime& CmcDateTime::operator+=(const CmcDateTimeSpan& dateSpan)
{
*this = *this + dateSpan;
return *this;
} // end of CmcDateTime& CmcDateTime::operator+=

const CmcDateTime& CmcDateTime::operator-=(const CmcDateTimeSpan dateSpan)
const CmcDateTime& CmcDateTime::operator-=(const CmcDateTimeSpan& dateSpan)
{
*this = *this - dateSpan;
return *this;
Expand Down Expand Up @@ -392,10 +392,10 @@ CmcDateTimeSpan CmcDateTimeSpan::operator-(const CmcDateTimeSpan& dateSpan) cons
return dateSpanTemp;
}

const CmcDateTimeSpan& CmcDateTimeSpan::operator+=(const CmcDateTimeSpan dateSpan)
const CmcDateTimeSpan& CmcDateTimeSpan::operator+=(const CmcDateTimeSpan& dateSpan)
{ *this = *this + dateSpan; return *this; }

const CmcDateTimeSpan& CmcDateTimeSpan::operator-=(const CmcDateTimeSpan dateSpan)
const CmcDateTimeSpan& CmcDateTimeSpan::operator-=(const CmcDateTimeSpan& dateSpan)
{ *this = *this - dateSpan; return *this; }
CmcDateTimeSpan CmcDateTimeSpan::operator-() const
{ return -this->m_span; }
Expand Down
2 changes: 1 addition & 1 deletion regexp.h
Expand Up @@ -74,7 +74,7 @@ class t_regexp
};

// returns a named wildcard
string GetWildcard (const string sName) const
string GetWildcard (const string& sName) const
{
int iNumber;
if (IsStringNumber (sName))
Expand Down
2 changes: 1 addition & 1 deletion stdafx.h
Expand Up @@ -682,7 +682,7 @@ inline string trim (const string & s, const string & t = SPACES)

// string find-and-replace
inline string FindAndReplace
(const string& source, const string target, const string replacement)
(const string& source, const string& target, const string& replacement)
{
string str = source;
string::size_type pos = 0, // where we are now
Expand Down

0 comments on commit b673264

Please sign in to comment.