'Dummy' warning fixes (might be used uninitialized).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32826 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2005-03-14 20:00:42 +00:00
parent 6ca3a32256
commit ba9bbf1388
5 changed files with 119 additions and 124 deletions

View File

@@ -364,7 +364,7 @@ static long GetTruncatedJDN(wxDateTime::wxDateTime_t day,
static wxString CallStrftime(const wxChar *format, const tm* tm) static wxString CallStrftime(const wxChar *format, const tm* tm)
{ {
wxChar buf[4096]; wxChar buf[4096];
if ( !wxStrftime(buf, WXSIZEOF(buf), format, tm) ) if ( !wxStrftime(buf, WXSIZEOF(buf), format, tm) )
{ {
// buffer is too small? // buffer is too small?
wxFAIL_MSG(_T("strftime() failed")); wxFAIL_MSG(_T("strftime() failed"));
@@ -829,47 +829,47 @@ wxString wxDateTime::GetMonthName(wxDateTime::Month month,
return CallStrftime(flags == Name_Abbr ? _T("%b") : _T("%B"), &tm); return CallStrftime(flags == Name_Abbr ? _T("%b") : _T("%B"), &tm);
#else #else
wxString ret; wxString ret;
switch(month) switch(month)
{ {
case Jan: case Jan:
ret = (flags == Name_Abbr ? wxT("Jan"): wxT("January")); ret = (flags == Name_Abbr ? wxT("Jan"): wxT("January"));
break; break;
case Feb: case Feb:
ret = (flags == Name_Abbr ? wxT("Feb"): wxT("Febuary")); ret = (flags == Name_Abbr ? wxT("Feb"): wxT("Febuary"));
break; break;
case Mar: case Mar:
ret = (flags == Name_Abbr ? wxT("Mar"): wxT("March")); ret = (flags == Name_Abbr ? wxT("Mar"): wxT("March"));
break; break;
case Apr: case Apr:
ret = (flags == Name_Abbr ? wxT("Apr"): wxT("April")); ret = (flags == Name_Abbr ? wxT("Apr"): wxT("April"));
break; break;
case May: case May:
ret = (flags == Name_Abbr ? wxT("May"): wxT("May")); ret = (flags == Name_Abbr ? wxT("May"): wxT("May"));
break; break;
case Jun: case Jun:
ret = (flags == Name_Abbr ? wxT("Jun"): wxT("June")); ret = (flags == Name_Abbr ? wxT("Jun"): wxT("June"));
break; break;
case Jul: case Jul:
ret = (flags == Name_Abbr ? wxT("Jul"): wxT("July")); ret = (flags == Name_Abbr ? wxT("Jul"): wxT("July"));
break; break;
case Aug: case Aug:
ret = (flags == Name_Abbr ? wxT("Aug"): wxT("August")); ret = (flags == Name_Abbr ? wxT("Aug"): wxT("August"));
break; break;
case Sep: case Sep:
ret = (flags == Name_Abbr ? wxT("Sep"): wxT("September")); ret = (flags == Name_Abbr ? wxT("Sep"): wxT("September"));
break; break;
case Oct: case Oct:
ret = (flags == Name_Abbr ? wxT("Oct"): wxT("October")); ret = (flags == Name_Abbr ? wxT("Oct"): wxT("October"));
break; break;
case Nov: case Nov:
ret = (flags == Name_Abbr ? wxT("Nov"): wxT("November")); ret = (flags == Name_Abbr ? wxT("Nov"): wxT("November"));
break; break;
case Dec: case Dec:
ret = (flags == Name_Abbr ? wxT("Dec"): wxT("December")); ret = (flags == Name_Abbr ? wxT("Dec"): wxT("December"));
break; break;
} }
return ret; return ret;
#endif #endif
} }
@@ -897,32 +897,32 @@ wxString wxDateTime::GetWeekDayName(wxDateTime::WeekDay wday,
// ... and call strftime() // ... and call strftime()
return CallStrftime(flags == Name_Abbr ? _T("%a") : _T("%A"), &tm); return CallStrftime(flags == Name_Abbr ? _T("%a") : _T("%A"), &tm);
#else #else
wxString ret; wxString ret;
switch(wday) switch(wday)
{ {
case Sun: case Sun:
ret = (flags == Name_Abbr ? wxT("Sun") : wxT("Sunday")); ret = (flags == Name_Abbr ? wxT("Sun") : wxT("Sunday"));
break; break;
case Mon: case Mon:
ret = (flags == Name_Abbr ? wxT("Mon") : wxT("Monday")); ret = (flags == Name_Abbr ? wxT("Mon") : wxT("Monday"));
break; break;
case Tue: case Tue:
ret = (flags == Name_Abbr ? wxT("Tue") : wxT("Tuesday")); ret = (flags == Name_Abbr ? wxT("Tue") : wxT("Tuesday"));
break; break;
case Wed: case Wed:
ret = (flags == Name_Abbr ? wxT("Wed") : wxT("Wednesday")); ret = (flags == Name_Abbr ? wxT("Wed") : wxT("Wednesday"));
break; break;
case Thu: case Thu:
ret = (flags == Name_Abbr ? wxT("Thu") : wxT("Thursday")); ret = (flags == Name_Abbr ? wxT("Thu") : wxT("Thursday"));
break; break;
case Fri: case Fri:
ret = (flags == Name_Abbr ? wxT("Fri") : wxT("Friday")); ret = (flags == Name_Abbr ? wxT("Fri") : wxT("Friday"));
break; break;
case Sat: case Sat:
ret = (flags == Name_Abbr ? wxT("Sat") : wxT("Saturday")); ret = (flags == Name_Abbr ? wxT("Sat") : wxT("Saturday"));
break; break;
} }
return ret; return ret;
#endif #endif
} }
@@ -2201,7 +2201,7 @@ wxString wxDateTime::Format(const wxChar *format, const TimeZone& tz) const
} }
} }
#ifndef __WXWINCE__ #ifndef __WXWINCE__
//Windows CE doesn't support strftime or wcsftime, so we use the generic implementation //Windows CE doesn't support strftime or wcsftime, so we use the generic implementation
if ( tm ) if ( tm )
{ {
return CallStrftime(format, tm); return CallStrftime(format, tm);
@@ -2416,9 +2416,9 @@ wxString wxDateTime::Format(const wxChar *format, const TimeZone& tz) const
res += str; res += str;
} }
#else #else
//Use "%m/%d/%y %H:%M:%S" format instead //Use "%m/%d/%y %H:%M:%S" format instead
res += wxString::Format(wxT("%02d/%02d/%04d %02d:%02d:%02d"), res += wxString::Format(wxT("%02d/%02d/%04d %02d:%02d:%02d"),
tm.mon+1,tm.mday, tm.year, tm.hour, tm.min, tm.sec); tm.mon+1,tm.mday, tm.year, tm.hour, tm.min, tm.sec);
#endif #endif
break; break;
@@ -2459,7 +2459,7 @@ wxString wxDateTime::Format(const wxChar *format, const TimeZone& tz) const
#ifndef __WXWINCE__ #ifndef __WXWINCE__
res += CallStrftime(_T("%p"), &tmTimeOnly); res += CallStrftime(_T("%p"), &tmTimeOnly);
#else #else
res += (tmTimeOnly.tm_hour > 12) ? wxT("pm") : wxT("am"); res += (tmTimeOnly.tm_hour > 12) ? wxT("pm") : wxT("am");
#endif #endif
break; break;
@@ -2486,7 +2486,7 @@ wxString wxDateTime::Format(const wxChar *format, const TimeZone& tz) const
#ifndef __WXWINCE__ #ifndef __WXWINCE__
res += CallStrftime(_T("%X"), &tmTimeOnly); res += CallStrftime(_T("%X"), &tmTimeOnly);
#else #else
res += wxString::Format(wxT("%02d:%02d:%02d"),tm.hour, tm.min, tm.sec); res += wxString::Format(wxT("%02d:%02d:%02d"),tm.hour, tm.min, tm.sec);
#endif #endif
break; break;
@@ -2739,7 +2739,7 @@ const wxChar *wxDateTime::ParseRfc822Date(const wxChar* date)
} }
// and now the interesting part: the timezone // and now the interesting part: the timezone
int offset; int offset wxDUMMY_INITIALIZE(0);
if ( *p == _T('-') || *p == _T('+') ) if ( *p == _T('-') || *p == _T('+') )
{ {
// the explicit offset given: it has the form of hhmm // the explicit offset given: it has the form of hhmm

View File

@@ -1796,46 +1796,43 @@ wxString wxString::FormatV(const wxChar *pszFormat, va_list argptr)
int wxString::Printf(const wxChar *pszFormat, ...) int wxString::Printf(const wxChar *pszFormat, ...)
{ {
va_list argptr; va_list argptr;
va_start(argptr, pszFormat); va_start(argptr, pszFormat);
int iLen = PrintfV(pszFormat, argptr); int iLen = PrintfV(pszFormat, argptr);
va_end(argptr); va_end(argptr);
return iLen; return iLen;
} }
int wxString::PrintfV(const wxChar* pszFormat, va_list argptr) int wxString::PrintfV(const wxChar* pszFormat, va_list argptr)
{ {
int size = 1024; int size = 1024;
int len;
for ( ;; ) for ( ;; )
{ {
wxStringBuffer tmp(*this, size + 1);
wxChar* buf = tmp;
if ( !buf )
{ {
wxStringBuffer tmp(*this, size + 1); // out of memory
wxChar* buf = tmp; return -1;
if ( !buf )
{
// out of memory
return -1;
}
// wxVsnprintf() may modify the original arg pointer, so pass it
// only a copy
va_list argptrcopy;
wxVaCopy(argptrcopy, argptr);
len = wxVsnprintf(buf, size, pszFormat, argptrcopy);
va_end(argptrcopy);
// some implementations of vsnprintf() don't NUL terminate
// the string if there is not enough space for it so
// always do it manually
buf[size] = _T('\0');
} }
// wxVsnprintf() may modify the original arg pointer, so pass it
// only a copy
va_list argptrcopy;
wxVaCopy(argptrcopy, argptr);
int len = wxVsnprintf(buf, size, pszFormat, argptrcopy);
va_end(argptrcopy);
// some implementations of vsnprintf() don't NUL terminate
// the string if there is not enough space for it so
// always do it manually
buf[size] = _T('\0');
// vsnprintf() may return either -1 (traditional Unix behaviour) or the // vsnprintf() may return either -1 (traditional Unix behaviour) or the
// total number of characters which would have been written if the // total number of characters which would have been written if the
// buffer were large enough // buffer were large enough

View File

@@ -668,7 +668,6 @@ wxImage wxXPMDecoder::ReadData(const char **xpm_data)
wxChar key[64]; wxChar key[64];
const char *clr_def; const char *clr_def;
bool hasMask; bool hasMask;
wxXPMColourMapData clr_data;
wxXPMColourMap clr_tbl; wxXPMColourMap clr_tbl;
wxXPMColourMap::iterator it; wxXPMColourMap::iterator it;
wxString maskKey; wxString maskKey;
@@ -702,6 +701,8 @@ wxImage wxXPMDecoder::ReadData(const char **xpm_data)
*/ */
for (i = 0; i < colors_cnt; i++) for (i = 0; i < colors_cnt; i++)
{ {
wxXPMColourMapData clr_data = {255,0,255};
for (i_key = 0; i_key < chars_per_pixel; i_key++) for (i_key = 0; i_key < chars_per_pixel; i_key++)
key[i_key] = (wxChar)xpm_data[1 + i][i_key]; key[i_key] = (wxChar)xpm_data[1 + i][i_key];
clr_def = ParseColor(xpm_data[1 + i] + chars_per_pixel); clr_def = ParseColor(xpm_data[1 + i] + chars_per_pixel);
@@ -710,17 +711,15 @@ wxImage wxXPMDecoder::ReadData(const char **xpm_data)
{ {
wxLogError(_("XPM: malformed colour definition '%s'!"), wxLogError(_("XPM: malformed colour definition '%s'!"),
xpm_data[1+i]); xpm_data[1+i]);
clr_data.R = 255, clr_data.G = 0, clr_data.B = 255;
} }
else else
{ {
bool isNone; bool isNone = false;
if ( !GetRGBFromName(clr_def, &isNone, if ( !GetRGBFromName(clr_def, &isNone,
&clr_data.R, &clr_data.G, &clr_data.B) ) &clr_data.R, &clr_data.G, &clr_data.B) )
{ {
wxLogError(_("XPM: malformed colour definition '%s'!"), wxLogError(_("XPM: malformed colour definition '%s'!"),
xpm_data[1+i]); xpm_data[1+i]);
clr_data.R = 255, clr_data.G = 0, clr_data.B = 255;
} }
else else
{ {
@@ -729,7 +728,6 @@ wxImage wxXPMDecoder::ReadData(const char **xpm_data)
img.SetMask(true); img.SetMask(true);
img.SetMaskColour(255, 0, 255); img.SetMaskColour(255, 0, 255);
hasMask = true; hasMask = true;
clr_data.R = 255, clr_data.G = 0, clr_data.B = 255;
maskKey = key; maskKey = key;
} }
} }

View File

@@ -593,7 +593,7 @@ wxZipEntry::wxZipEntry(
const wxString& name /*=wxEmptyString*/, const wxString& name /*=wxEmptyString*/,
const wxDateTime& dt /*=wxDateTime::Now()*/, const wxDateTime& dt /*=wxDateTime::Now()*/,
wxFileOffset size /*=wxInvalidOffset*/) wxFileOffset size /*=wxInvalidOffset*/)
: :
m_SystemMadeBy(wxZIP_SYSTEM_MSDOS), m_SystemMadeBy(wxZIP_SYSTEM_MSDOS),
m_VersionMadeBy(wxMAJOR_VERSION * 10 + wxMINOR_VERSION), m_VersionMadeBy(wxMAJOR_VERSION * 10 + wxMINOR_VERSION),
m_VersionNeeded(VERSION_NEEDED_TO_EXTRACT), m_VersionNeeded(VERSION_NEEDED_TO_EXTRACT),
@@ -907,7 +907,7 @@ size_t wxZipEntry::WriteLocal(wxOutputStream& stream, wxMBConv& conv) const
ds << m_VersionNeeded << m_Flags << m_Method; ds << m_VersionNeeded << m_Flags << m_Method;
ds.Write32(GetDateTime().GetAsDOS()); ds.Write32(GetDateTime().GetAsDOS());
ds.Write32(m_Crc); ds.Write32(m_Crc);
ds.Write32(m_CompressedSize != wxInvalidOffset ? (wxUint32)m_CompressedSize : 0); ds.Write32(m_CompressedSize != wxInvalidOffset ? (wxUint32)m_CompressedSize : 0);
ds.Write32(m_Size != wxInvalidOffset ? (wxUint32)m_Size : 0); ds.Write32(m_Size != wxInvalidOffset ? (wxUint32)m_Size : 0);
@@ -942,7 +942,7 @@ size_t wxZipEntry::ReadCentral(wxInputStream& stream, wxMBConv& conv)
ds >> nameLen >> extraLen >> commentLen ds >> nameLen >> extraLen >> commentLen
>> m_DiskStart >> m_InternalAttributes >> m_ExternalAttributes; >> m_DiskStart >> m_InternalAttributes >> m_ExternalAttributes;
SetOffset(ds.Read32()); SetOffset(ds.Read32());
SetName(ReadString(stream, nameLen, conv), wxPATH_UNIX); SetName(ReadString(stream, nameLen, conv), wxPATH_UNIX);
if (extraLen || GetExtraLen()) { if (extraLen || GetExtraLen()) {
@@ -990,7 +990,7 @@ size_t wxZipEntry::WriteCentral(wxOutputStream& stream, wxMBConv& conv) const
ds << commentLen << m_DiskStart << m_InternalAttributes ds << commentLen << m_DiskStart << m_InternalAttributes
<< m_ExternalAttributes << (wxUint32)GetOffset(); << m_ExternalAttributes << (wxUint32)GetOffset();
stream.Write(name, nameLen); stream.Write(name, nameLen);
if (extraLen) if (extraLen)
stream.Write(GetExtra(), extraLen); stream.Write(GetExtra(), extraLen);
@@ -1007,7 +1007,7 @@ size_t wxZipEntry::WriteCentral(wxOutputStream& stream, wxMBConv& conv) const
size_t wxZipEntry::ReadDescriptor(wxInputStream& stream) size_t wxZipEntry::ReadDescriptor(wxInputStream& stream)
{ {
wxDataInputStream ds(stream); wxDataInputStream ds(stream);
m_Crc = ds.Read32(); m_Crc = ds.Read32();
m_CompressedSize = ds.Read32(); m_CompressedSize = ds.Read32();
m_Size = ds.Read32(); m_Size = ds.Read32();
@@ -1019,7 +1019,7 @@ size_t wxZipEntry::ReadDescriptor(wxInputStream& stream)
stream.Read(buf, sizeof(buf)); stream.Read(buf, sizeof(buf));
wxUint32 u1 = CrackUint32(buf); wxUint32 u1 = CrackUint32(buf);
wxUint32 u2 = CrackUint32(buf + 4); wxUint32 u2 = CrackUint32(buf + 4);
// look for the signature of the following record to decide which // look for the signature of the following record to decide which
if ((u1 == LOCAL_MAGIC || u1 == CENTRAL_MAGIC) && if ((u1 == LOCAL_MAGIC || u1 == CENTRAL_MAGIC) &&
(u2 != LOCAL_MAGIC && u2 != CENTRAL_MAGIC)) (u2 != LOCAL_MAGIC && u2 != CENTRAL_MAGIC))
@@ -1241,7 +1241,7 @@ wxZipInputStream::~wxZipInputStream()
delete m_ffile; delete m_ffile;
m_weaklinks->Release(this); m_weaklinks->Release(this);
if (m_streamlink) if (m_streamlink)
m_streamlink->Release(this); m_streamlink->Release(this);
} }
@@ -1325,7 +1325,7 @@ bool wxZipInputStream::LoadEndRecord()
m_Comment = endrec.GetComment(); m_Comment = endrec.GetComment();
// Now find the central-directory. we have the file offset of // Now find the central-directory. we have the file offset of
// the CD, so look there first. // the CD, so look there first.
if (m_parent_i_stream->SeekI(endrec.GetOffset()) != wxInvalidOffset && if (m_parent_i_stream->SeekI(endrec.GetOffset()) != wxInvalidOffset &&
ReadSignature() == CENTRAL_MAGIC) { ReadSignature() == CENTRAL_MAGIC) {
m_signature = CENTRAL_MAGIC; m_signature = CENTRAL_MAGIC;
@@ -1333,7 +1333,7 @@ bool wxZipInputStream::LoadEndRecord()
m_offsetAdjustment = 0; m_offsetAdjustment = 0;
return true; return true;
} }
// If it's not there, then it could be that the zip has been appended // If it's not there, then it could be that the zip has been appended
// to a self extractor, so take the CD size (also in endrec), subtract // to a self extractor, so take the CD size (also in endrec), subtract
// it from the file offset of the end-central-directory and look there. // it from the file offset of the end-central-directory and look there.
@@ -1359,7 +1359,7 @@ bool wxZipInputStream::FindEndRecord()
return false; return false;
// usually it's 22 bytes in size and the last thing in the file // usually it's 22 bytes in size and the last thing in the file
{ {
wxLogNull nolog; wxLogNull nolog;
if (m_parent_i_stream->SeekI(-END_SIZE, wxFromEnd) == wxInvalidOffset) if (m_parent_i_stream->SeekI(-END_SIZE, wxFromEnd) == wxInvalidOffset)
return false; return false;
@@ -1386,7 +1386,7 @@ bool wxZipInputStream::FindEndRecord()
size_t len = (size_t)(pos - wxMax(pos - (BUFSIZE - 3), minpos)); size_t len = (size_t)(pos - wxMax(pos - (BUFSIZE - 3), minpos));
memcpy(buf.data() + len, buf, 3); memcpy(buf.data() + len, buf, 3);
pos -= len; pos -= len;
if (m_parent_i_stream->SeekI(pos, wxFromStart) == wxInvalidOffset || if (m_parent_i_stream->SeekI(pos, wxFromStart) == wxInvalidOffset ||
m_parent_i_stream->Read(buf.data(), len).LastRead() != len) m_parent_i_stream->Read(buf.data(), len).LastRead() != len)
return false; return false;
@@ -1470,7 +1470,7 @@ wxStreamError wxZipInputStream::ReadLocal(bool readEndRec /*=false*/)
while (m_signature == CENTRAL_MAGIC) { while (m_signature == CENTRAL_MAGIC) {
if (m_weaklinks->IsEmpty() && m_streamlink == NULL) if (m_weaklinks->IsEmpty() && m_streamlink == NULL)
return wxSTREAM_EOF; return wxSTREAM_EOF;
m_position += m_entry.ReadCentral(*m_parent_i_stream, GetConv()); m_position += m_entry.ReadCentral(*m_parent_i_stream, GetConv());
m_signature = 0; m_signature = 0;
if (m_parent_i_stream->GetLastError() == wxSTREAM_READ_ERROR) if (m_parent_i_stream->GetLastError() == wxSTREAM_READ_ERROR)
@@ -1506,7 +1506,7 @@ wxStreamError wxZipInputStream::ReadLocal(bool readEndRec /*=false*/)
} }
return wxSTREAM_EOF; return wxSTREAM_EOF;
} }
if (m_signature != LOCAL_MAGIC) { if (m_signature != LOCAL_MAGIC) {
wxLogError(_("error reading zip local header")); wxLogError(_("error reading zip local header"));
return wxSTREAM_READ_ERROR; return wxSTREAM_READ_ERROR;
@@ -1557,9 +1557,9 @@ bool wxZipInputStream::DoOpen(wxZipEntry *entry, bool raw)
// can only open the current entry on a non-seekable stream // can only open the current entry on a non-seekable stream
wxCHECK(m_parentSeekable, false); wxCHECK(m_parentSeekable, false);
} }
m_lasterror = wxSTREAM_READ_ERROR; m_lasterror = wxSTREAM_READ_ERROR;
if (entry) if (entry)
m_entry = *entry; m_entry = *entry;
@@ -1765,7 +1765,7 @@ wxFileOffset wxZipInputStream::OnSysSeek(wxFileOffset seek, wxSeekMode mode)
default : nextpos = pos; break; /* just to fool compiler, never happens */ default : nextpos = pos; break; /* just to fool compiler, never happens */
} }
size_t toskip; size_t toskip wxDUMMY_INITIALIZE(0);
if ( nextpos >= pos ) if ( nextpos >= pos )
{ {
toskip = (size_t)(nextpos - pos); toskip = (size_t)(nextpos - pos);
@@ -1825,7 +1825,7 @@ wxZipOutputStream::wxZipOutputStream(wxOutputStream& stream,
m_offsetAdjustment(wxInvalidOffset) m_offsetAdjustment(wxInvalidOffset)
{ {
} }
wxZipOutputStream::~wxZipOutputStream() wxZipOutputStream::~wxZipOutputStream()
{ {
Close(); Close();

View File

@@ -1157,7 +1157,7 @@ static int OpenLogFile(wxFile& file, wxString *pFilename, wxWindow *parent)
// open file // open file
// --------- // ---------
bool bOk; bool bOk wxDUMMY_INITIALIZE(false);
if ( wxFile::Exists(filename) ) { if ( wxFile::Exists(filename) ) {
bool bAppend = false; bool bAppend = false;
wxString strMsg; wxString strMsg;