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,6 +230,7 @@ protected:
|
||||
static CharType *StrCopy(const CharType *src, size_t len)
|
||||
{
|
||||
CharType *dst = (CharType*)malloc(sizeof(CharType) * (len + 1));
|
||||
if ( dst )
|
||||
memcpy(dst, src, sizeof(CharType) * (len + 1));
|
||||
return dst;
|
||||
}
|
||||
|
@@ -969,8 +969,8 @@ int wxCmdLineParser::Parse(bool showUsage)
|
||||
case wxCMD_LINE_VAL_DATE:
|
||||
{
|
||||
wxDateTime dt;
|
||||
wxString::const_iterator end;
|
||||
if ( !dt.ParseDate(value, &end) || end != value.end() )
|
||||
wxString::const_iterator endDate;
|
||||
if ( !dt.ParseDate(value, &endDate) || endDate != value.end() )
|
||||
{
|
||||
errorMsg << wxString::Format(_("Option '%s': '%s' cannot be converted to a date."),
|
||||
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
|
||||
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
|
||||
@@ -1725,12 +1725,12 @@ wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end)
|
||||
if ( len > lenRest )
|
||||
continue;
|
||||
|
||||
const wxString::const_iterator pEnd = p + len;
|
||||
if ( wxString(p, pEnd).CmpNoCase(dateStr) == 0 )
|
||||
const wxString::const_iterator pEndStr = p + len;
|
||||
if ( wxString(p, pEndStr).CmpNoCase(dateStr) == 0 )
|
||||
{
|
||||
// nothing can follow this, so stop here
|
||||
|
||||
p = pEnd;
|
||||
p = pEndStr;
|
||||
|
||||
int dayDiffFromToday = literalDates[n].dayDiffFromToday;
|
||||
*this = Today();
|
||||
@@ -1739,7 +1739,7 @@ wxDateTime::ParseDate(const wxString& date, wxString::const_iterator *end)
|
||||
*this += wxDateSpan::Days(dayDiffFromToday);
|
||||
}
|
||||
|
||||
*end = pEnd;
|
||||
*end = pEndStr;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@@ -1574,8 +1574,12 @@ wxString wxGetOSDirectory()
|
||||
#ifdef __WXWINCE__
|
||||
return wxString(wxT("\\Windows"));
|
||||
#elif defined(__WINDOWS__) && !defined(__WXMICROWIN__)
|
||||
wxChar buf[256];
|
||||
GetWindowsDirectory(buf, 256);
|
||||
wxChar buf[MAX_PATH];
|
||||
if ( !GetWindowsDirectory(buf, MAX_PATH) )
|
||||
{
|
||||
wxLogLastError(wxS("GetWindowsDirectory"));
|
||||
}
|
||||
|
||||
return wxString(buf);
|
||||
#elif defined(__WXMAC__) && wxOSX_USE_CARBON
|
||||
return wxMacFindFolderNoSeparator(kOnSystemDisk, 'macs', false);
|
||||
|
@@ -834,6 +834,7 @@ wxChar32* wxStrdup(const wxChar32* s)
|
||||
{
|
||||
size_t size = (wxStrlen(s) + 1) * sizeof(wxChar32);
|
||||
wxChar32 *ret = (wxChar32*) malloc(size);
|
||||
if ( ret )
|
||||
memcpy(ret, s, size);
|
||||
return ret;
|
||||
}
|
||||
|
@@ -636,22 +636,23 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
|
||||
extWithDot = wxT('.');
|
||||
extWithDot += ext;
|
||||
|
||||
wxRegKey key(wxRegKey::HKCR, extWithDot);
|
||||
if ( !key.Exists() ) key.Create();
|
||||
key.SetValue(wxEmptyString, filetype);
|
||||
wxRegKey key2(wxRegKey::HKCR, extWithDot);
|
||||
if ( !key2.Exists() )
|
||||
key2.Create();
|
||||
key2.SetValue(wxEmptyString, filetype);
|
||||
|
||||
// now set any mimetypes we may have, but ignore it if none
|
||||
const wxString& mimetype = ftInfo.GetMimeType();
|
||||
if ( !mimetype.empty() )
|
||||
const wxString& mimetype2 = ftInfo.GetMimeType();
|
||||
if ( !mimetype2.empty() )
|
||||
{
|
||||
// set the MIME type
|
||||
ok = key.SetValue(wxT("Content Type"), mimetype);
|
||||
ok = key2.SetValue(wxT("Content Type"), mimetype2);
|
||||
|
||||
if ( ok )
|
||||
{
|
||||
// create the MIME key
|
||||
wxString strKey = MIME_DATABASE_KEY;
|
||||
strKey << mimetype;
|
||||
strKey << mimetype2;
|
||||
wxRegKey keyMIME(wxRegKey::HKCR, strKey);
|
||||
ok = keyMIME.Create();
|
||||
|
||||
|
@@ -636,7 +636,8 @@ bool wxDoSetEnv(const wxString& var, const wxChar *value)
|
||||
envstr += '=';
|
||||
if ( value )
|
||||
envstr += value;
|
||||
_tputenv(envstr.t_str());
|
||||
if ( !_tputenv(envstr.t_str()) )
|
||||
return false;
|
||||
#else // other compiler
|
||||
if ( !::SetEnvironmentVariable(var.t_str(), value) )
|
||||
{
|
||||
|
@@ -996,7 +996,7 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler,
|
||||
// just launched process
|
||||
if ( !ddeServer.empty() )
|
||||
{
|
||||
bool ok;
|
||||
bool ddeOK;
|
||||
|
||||
// give the process the time to init itself
|
||||
//
|
||||
@@ -1015,15 +1015,15 @@ long wxExecute(const wxString& cmd, int flags, wxProcess *handler,
|
||||
case WAIT_TIMEOUT:
|
||||
wxLogDebug(wxT("Timeout too small in WaitForInputIdle"));
|
||||
|
||||
ok = false;
|
||||
ddeOK = false;
|
||||
break;
|
||||
|
||||
case 0:
|
||||
// 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\"."),
|
||||
cmd.c_str());
|
||||
|
@@ -506,12 +506,13 @@ bool wxFSVolumeBase::Create(const wxString& name)
|
||||
if (!rc)
|
||||
{
|
||||
wxLogError(_("Cannot read typename from '%s'!"), m_volName.c_str());
|
||||
return m_isOk;
|
||||
return false;
|
||||
}
|
||||
m_dispName = fi.szDisplayName;
|
||||
|
||||
// all tests passed.
|
||||
return m_isOk = true;
|
||||
m_isOk = true;
|
||||
return true;
|
||||
} // Create
|
||||
|
||||
//=============================================================================
|
||||
|
Reference in New Issue
Block a user