No changes, just silence some MSVC 11 static analyzer warnings.
This is an aborted attempt to make wxWidgets code compile without warnings when using MSVC 11 /analyze option, as it was supposed to have become much better. Unfortunately it still produces way too many false positives to be really useful, in particular NULL pointer detection is completely broken as even the code such as (from object.cpp): wxClassInfo *info = sm_first; while (info) { if ( info->m_next == this ) ... } provokes tons of warnings about "info" being NULL inside the loop which is clearly impossible. So this commit just fixes a few obvious warnings, mostly about variable shadowing but also a couple about possibly passing NULL to memcpy(). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72496 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -230,7 +230,8 @@ protected:
|
|||||||
static CharType *StrCopy(const CharType *src, size_t len)
|
static CharType *StrCopy(const CharType *src, size_t len)
|
||||||
{
|
{
|
||||||
CharType *dst = (CharType*)malloc(sizeof(CharType) * (len + 1));
|
CharType *dst = (CharType*)malloc(sizeof(CharType) * (len + 1));
|
||||||
memcpy(dst, src, sizeof(CharType) * (len + 1));
|
if ( dst )
|
||||||
|
memcpy(dst, src, sizeof(CharType) * (len + 1));
|
||||||
return dst;
|
return dst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -969,8 +969,8 @@ int wxCmdLineParser::Parse(bool showUsage)
|
|||||||
case wxCMD_LINE_VAL_DATE:
|
case wxCMD_LINE_VAL_DATE:
|
||||||
{
|
{
|
||||||
wxDateTime dt;
|
wxDateTime dt;
|
||||||
wxString::const_iterator end;
|
wxString::const_iterator endDate;
|
||||||
if ( !dt.ParseDate(value, &end) || end != value.end() )
|
if ( !dt.ParseDate(value, &endDate) || endDate != value.end() )
|
||||||
{
|
{
|
||||||
errorMsg << wxString::Format(_("Option '%s': '%s' cannot be converted to a date."),
|
errorMsg << wxString::Format(_("Option '%s': '%s' cannot be converted to a date."),
|
||||||
name.c_str(), value.c_str())
|
name.c_str(), value.c_str())
|
||||||
|
@@ -514,7 +514,7 @@ wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
|
|||||||
// (indirectly) set the year correctly
|
// (indirectly) set the year correctly
|
||||||
while ( (nLostWeekDays % 7) != 0 )
|
while ( (nLostWeekDays % 7) != 0 )
|
||||||
{
|
{
|
||||||
nLostWeekDays += year++ % 4 ? 1 : 2;
|
nLostWeekDays += (year++ % 4) ? 1 : 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// finally move the year below 2000 so that the 2-digit
|
// finally move the year below 2000 so that the 2-digit
|
||||||
@@ -1725,12 +1725,12 @@ wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end)
|
|||||||
if ( len > lenRest )
|
if ( len > lenRest )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
const wxString::const_iterator pEnd = p + len;
|
const wxString::const_iterator pEndStr = p + len;
|
||||||
if ( wxString(p, pEnd).CmpNoCase(dateStr) == 0 )
|
if ( wxString(p, pEndStr).CmpNoCase(dateStr) == 0 )
|
||||||
{
|
{
|
||||||
// nothing can follow this, so stop here
|
// nothing can follow this, so stop here
|
||||||
|
|
||||||
p = pEnd;
|
p = pEndStr;
|
||||||
|
|
||||||
int dayDiffFromToday = literalDates[n].dayDiffFromToday;
|
int dayDiffFromToday = literalDates[n].dayDiffFromToday;
|
||||||
*this = Today();
|
*this = Today();
|
||||||
@@ -1739,7 +1739,7 @@ wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end)
|
|||||||
*this += wxDateSpan::Days(dayDiffFromToday);
|
*this += wxDateSpan::Days(dayDiffFromToday);
|
||||||
}
|
}
|
||||||
|
|
||||||
*end = pEnd;
|
*end = pEndStr;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -1574,8 +1574,12 @@ wxString wxGetOSDirectory()
|
|||||||
#ifdef __WXWINCE__
|
#ifdef __WXWINCE__
|
||||||
return wxString(wxT("\\Windows"));
|
return wxString(wxT("\\Windows"));
|
||||||
#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
|
#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
|
||||||
wxChar buf[256];
|
wxChar buf[MAX_PATH];
|
||||||
GetWindowsDirectory(buf, 256);
|
if ( !GetWindowsDirectory(buf, MAX_PATH) )
|
||||||
|
{
|
||||||
|
wxLogLastError(wxS("GetWindowsDirectory"));
|
||||||
|
}
|
||||||
|
|
||||||
return wxString(buf);
|
return wxString(buf);
|
||||||
#elif defined(__WXMAC__) && wxOSX_USE_CARBON
|
#elif defined(__WXMAC__) && wxOSX_USE_CARBON
|
||||||
return wxMacFindFolderNoSeparator(kOnSystemDisk, 'macs', false);
|
return wxMacFindFolderNoSeparator(kOnSystemDisk, 'macs', false);
|
||||||
|
@@ -834,7 +834,8 @@ wxChar32* wxStrdup(const wxChar32* s)
|
|||||||
{
|
{
|
||||||
size_t size = (wxStrlen(s) + 1) * sizeof(wxChar32);
|
size_t size = (wxStrlen(s) + 1) * sizeof(wxChar32);
|
||||||
wxChar32 *ret = (wxChar32*) malloc(size);
|
wxChar32 *ret = (wxChar32*) malloc(size);
|
||||||
memcpy(ret, s, size);
|
if ( ret )
|
||||||
|
memcpy(ret, s, size);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -636,22 +636,23 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
|
|||||||
extWithDot = wxT('.');
|
extWithDot = wxT('.');
|
||||||
extWithDot += ext;
|
extWithDot += ext;
|
||||||
|
|
||||||
wxRegKey key(wxRegKey::HKCR, extWithDot);
|
wxRegKey key2(wxRegKey::HKCR, extWithDot);
|
||||||
if ( !key.Exists() ) key.Create();
|
if ( !key2.Exists() )
|
||||||
key.SetValue(wxEmptyString, filetype);
|
key2.Create();
|
||||||
|
key2.SetValue(wxEmptyString, filetype);
|
||||||
|
|
||||||
// now set any mimetypes we may have, but ignore it if none
|
// now set any mimetypes we may have, but ignore it if none
|
||||||
const wxString& mimetype = ftInfo.GetMimeType();
|
const wxString& mimetype2 = ftInfo.GetMimeType();
|
||||||
if ( !mimetype.empty() )
|
if ( !mimetype2.empty() )
|
||||||
{
|
{
|
||||||
// set the MIME type
|
// set the MIME type
|
||||||
ok = key.SetValue(wxT("Content Type"), mimetype);
|
ok = key2.SetValue(wxT("Content Type"), mimetype2);
|
||||||
|
|
||||||
if ( ok )
|
if ( ok )
|
||||||
{
|
{
|
||||||
// create the MIME key
|
// create the MIME key
|
||||||
wxString strKey = MIME_DATABASE_KEY;
|
wxString strKey = MIME_DATABASE_KEY;
|
||||||
strKey << mimetype;
|
strKey << mimetype2;
|
||||||
wxRegKey keyMIME(wxRegKey::HKCR, strKey);
|
wxRegKey keyMIME(wxRegKey::HKCR, strKey);
|
||||||
ok = keyMIME.Create();
|
ok = keyMIME.Create();
|
||||||
|
|
||||||
|
@@ -636,7 +636,8 @@ bool wxDoSetEnv(const wxString& var, const wxChar *value)
|
|||||||
envstr += '=';
|
envstr += '=';
|
||||||
if ( value )
|
if ( value )
|
||||||
envstr += value;
|
envstr += value;
|
||||||
_tputenv(envstr.t_str());
|
if ( !_tputenv(envstr.t_str()) )
|
||||||
|
return false;
|
||||||
#else // other compiler
|
#else // other compiler
|
||||||
if ( !::SetEnvironmentVariable(var.t_str(), value) )
|
if ( !::SetEnvironmentVariable(var.t_str(), value) )
|
||||||
{
|
{
|
||||||
|
@@ -996,7 +996,7 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler,
|
|||||||
// just launched process
|
// just launched process
|
||||||
if ( !ddeServer.empty() )
|
if ( !ddeServer.empty() )
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ddeOK;
|
||||||
|
|
||||||
// give the process the time to init itself
|
// give the process the time to init itself
|
||||||
//
|
//
|
||||||
@@ -1015,15 +1015,15 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler,
|
|||||||
case WAIT_TIMEOUT:
|
case WAIT_TIMEOUT:
|
||||||
wxLogDebug(wxT("Timeout too small in WaitForInputIdle"));
|
wxLogDebug(wxT("Timeout too small in WaitForInputIdle"));
|
||||||
|
|
||||||
ok = false;
|
ddeOK = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0:
|
case 0:
|
||||||
// ok, process ready to accept DDE requests
|
// ok, process ready to accept DDE requests
|
||||||
ok = wxExecuteDDE(ddeServer, ddeTopic, ddeCommand);
|
ddeOK = wxExecuteDDE(ddeServer, ddeTopic, ddeCommand);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !ok )
|
if ( !ddeOK )
|
||||||
{
|
{
|
||||||
wxLogDebug(wxT("Failed to send DDE request to the process \"%s\"."),
|
wxLogDebug(wxT("Failed to send DDE request to the process \"%s\"."),
|
||||||
cmd.c_str());
|
cmd.c_str());
|
||||||
|
@@ -506,12 +506,13 @@ bool wxFSVolumeBase::Create(const wxString& name)
|
|||||||
if (!rc)
|
if (!rc)
|
||||||
{
|
{
|
||||||
wxLogError(_("Cannot read typename from '%s'!"), m_volName.c_str());
|
wxLogError(_("Cannot read typename from '%s'!"), m_volName.c_str());
|
||||||
return m_isOk;
|
return false;
|
||||||
}
|
}
|
||||||
m_dispName = fi.szDisplayName;
|
m_dispName = fi.szDisplayName;
|
||||||
|
|
||||||
// all tests passed.
|
// all tests passed.
|
||||||
return m_isOk = true;
|
m_isOk = true;
|
||||||
|
return true;
|
||||||
} // Create
|
} // Create
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
Reference in New Issue
Block a user