From: Włodzimierz Skiba Date: Wed, 6 Oct 2004 20:21:57 +0000 (+0000) Subject: Warning fixes found under hardest mode of OpenWatcom. Seems clean in Borland, MinGW... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/907173e51df6d2a91d65463ddf6ce810d3fd921a?ds=inline Warning fixes found under hardest mode of OpenWatcom. Seems clean in Borland, MinGW and DMC. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29682 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/common/datetime.cpp b/src/common/datetime.cpp index c8f8b2aea5..e2194fb574 100644 --- a/src/common/datetime.cpp +++ b/src/common/datetime.cpp @@ -536,10 +536,10 @@ wxDateTime::Tm::Tm(const struct tm& tm, const TimeZone& tz) : m_tz(tz) { msec = 0; - sec = tm.tm_sec; - min = tm.tm_min; - hour = tm.tm_hour; - mday = tm.tm_mday; + sec = (wxDateTime::wxDateTime_t)tm.tm_sec; + min = (wxDateTime::wxDateTime_t)tm.tm_min; + hour = (wxDateTime::wxDateTime_t)tm.tm_hour; + mday = (wxDateTime::wxDateTime_t)tm.tm_mday; mon = (wxDateTime::Month)tm.tm_mon; year = 1900 + tm.tm_year; wday = tm.tm_wday; @@ -597,7 +597,7 @@ void wxDateTime::Tm::AddDays(int dayDiff) dayDiff += GetNumOfDaysInMonth(year, mon); } - mday += dayDiff; + mday = (wxDateTime::wxDateTime_t)( mday + dayDiff ); while ( mday > GetNumOfDaysInMonth(year, mon) ) { mday -= GetNumOfDaysInMonth(year, mon); @@ -1873,7 +1873,7 @@ bool wxDateTime::SetToWeekDay(WeekDay weekday, static inline wxDateTime::wxDateTime_t GetDayOfYearFromTm(const wxDateTime::Tm& tm) { - return gs_cumulatedDays[wxDateTime::IsLeapYear(tm.year)][tm.mon] + tm.mday; + return (wxDateTime::wxDateTime_t)(gs_cumulatedDays[wxDateTime::IsLeapYear(tm.year)][tm.mon] + tm.mday); } wxDateTime::wxDateTime_t wxDateTime::GetDayOfYear(const TimeZone& tz) const @@ -1941,7 +1941,7 @@ wxDateTime::GetWeekOfYear(wxDateTime::WeekFlags flags, const TimeZone& tz) const } } - return week; + return (wxDateTime::wxDateTime_t)week; } wxDateTime::wxDateTime_t wxDateTime::GetWeekOfMonth(wxDateTime::WeekFlags flags, @@ -2467,11 +2467,11 @@ const wxChar *wxDateTime::ParseRfc822Date(const wxChar* date) return (wxChar *)NULL; } - wxDateTime_t day = *p++ - _T('0'); + wxDateTime_t day = (wxDateTime_t)(*p++ - _T('0')); if ( wxIsdigit(*p) ) { day *= 10; - day += *p++ - _T('0'); + day = (wxDateTime_t)(day + (*p++ - _T('0'))); } if ( *p++ != _T(' ') ) @@ -3392,19 +3392,23 @@ const wxChar *wxDateTime::ParseDate(const wxChar *date) { wxString date = wxGetTranslation(literalDates[n].str); size_t len = date.length(); - if ( wxStrlen(p) >= len && (wxString(p, len).CmpNoCase(date) == 0) ) + if ( wxStrlen(p) >= len ) { - // nothing can follow this, so stop here - p += len; - - int dayDiffFromToday = literalDates[n].dayDiffFromToday; - *this = Today(); - if ( dayDiffFromToday ) + wxString str(p, len); + if ( str.CmpNoCase(date) == 0 ) { - *this += wxDateSpan::Days(dayDiffFromToday); - } + // nothing can follow this, so stop here + p += len; + + int dayDiffFromToday = literalDates[n].dayDiffFromToday; + *this = Today(); + if ( dayDiffFromToday ) + { + *this += wxDateSpan::Days(dayDiffFromToday); + } - return p; + return p; + } } } diff --git a/src/common/strconv.cpp b/src/common/strconv.cpp index 395c2535ee..667874bdef 100644 --- a/src/common/strconv.cpp +++ b/src/common/strconv.cpp @@ -1190,8 +1190,8 @@ public: // it doesn't work with CJK encodings (which we test for rather roughly // here...) nor with UTF-7/8 nor, of course, with Windows versions not // supporting it - BOOL usedDef wxDUMMY_INITIALIZE(false), - *pUsedDef; + BOOL usedDef wxDUMMY_INITIALIZE(false); + BOOL *pUsedDef; int flags; if ( CanUseNoBestFit() && m_CodePage < 50000 ) { @@ -1769,7 +1769,7 @@ size_t wxCSConv::WC2MB(char *buf, const wchar_t *psz, size_t n) const { if (psz[c] > 0xFF) return (size_t)-1; - buf[c] = psz[c]; + buf[c] = (char)psz[c]; } } else diff --git a/src/msw/accel.cpp b/src/msw/accel.cpp index a918d7fff3..cad9c19c30 100644 --- a/src/msw/accel.cpp +++ b/src/msw/accel.cpp @@ -114,7 +114,7 @@ wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[] bool isVirtual; - WORD key = wxCharCodeWXToMSW(entries[i].GetKeyCode(), &isVirtual); + WORD key = (WORD)wxCharCodeWXToMSW(entries[i].GetKeyCode(), &isVirtual); if (isVirtual) fVirt |= FVIRTKEY; diff --git a/src/msw/bitmap.cpp b/src/msw/bitmap.cpp index b80b7989d9..16e23a409d 100644 --- a/src/msw/bitmap.cpp +++ b/src/msw/bitmap.cpp @@ -426,7 +426,7 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth) for ( int bits = 0; bits < 8; bits++) { reversed <<= 1; - reversed |= (val & 0x01); + reversed |= (unsigned char)(val & 0x01); val >>= 1; } *dst++ = reversed; @@ -1031,7 +1031,7 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const #ifndef __WXMICROWIN__ // handle alpha channel, if any if (HasAlpha()) - ret.UseAlpha(); + ret.UseAlpha(); // copy bitmap data MemoryHDC dcSrc, diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 51b2ebb921..c6f000a796 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -2461,6 +2461,7 @@ static bool AlphaBlt(HDC hdcDst, #else // !wxHAVE_RAW_BITMAP // no wxAlphaBlend() neither, fall back to using simple BitBlt() (we lose // alpha but at least something will be shown like this) + wxUnusedVar(bmp); return false; #endif // wxHAVE_RAW_BITMAP } diff --git a/src/msw/dialup.cpp b/src/msw/dialup.cpp index ac394e26ab..97eaaef176 100644 --- a/src/msw/dialup.cpp +++ b/src/msw/dialup.cpp @@ -460,7 +460,7 @@ wxString wxDialUpManagerMSW::GetErrorString(DWORD error) case 0: // we want the error message to start from a lower case letter - buffer[0] = wxTolower(buffer[0]); + buffer[0] = (wxChar)wxTolower(buffer[0]); return wxString(buffer); } diff --git a/src/msw/dib.cpp b/src/msw/dib.cpp index 285fd9142e..0589ec323e 100644 --- a/src/msw/dib.cpp +++ b/src/msw/dib.cpp @@ -69,7 +69,7 @@ static inline WORD GetNumberOfColours(WORD bitsPerPixel) { // only 1, 4 and 8bpp bitmaps use palettes (well, they could be used with // 24bpp ones too but we don't support this as I think it's quite uncommon) - return bitsPerPixel <= 8 ? 1 << bitsPerPixel : 0; + return (WORD)(bitsPerPixel <= 8 ? 1 << bitsPerPixel : 0); } // wrapper around ::GetObject() for DIB sections @@ -674,9 +674,9 @@ bool wxDIB::Create(const wxImage& image) // RGB order is reversed, and we need to premultiply // all channels by alpha value for use with ::AlphaBlend. const unsigned char a = *alpha++; - *dst++ = (src[2] * a + 127) / 255; - *dst++ = (src[1] * a + 127) / 255; - *dst++ = (src[0] * a + 127) / 255; + *dst++ = (unsigned char)((src[2] * a + 127) / 255); + *dst++ = (unsigned char)((src[1] * a + 127) / 255); + *dst++ = (unsigned char)((src[0] * a + 127) / 255); *dst++ = a; src += 3; } diff --git a/src/msw/font.cpp b/src/msw/font.cpp index d87bdd0821..d79b4b74a6 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -165,10 +165,10 @@ public: return m_nativeFontInfoOk ? m_nativeFontInfo.GetPixelSize() : m_pixelSize; } - + bool IsUsingSizeInPixels() const { - return m_nativeFontInfoOk ? TRUE : m_sizeUsingPixels; + return m_nativeFontInfoOk ? true : m_sizeUsingPixels; } int GetFamily() const @@ -1041,8 +1041,8 @@ bool wxFont::IsFixedWidth() const { // the two low-order bits specify the pitch of the font, the rest is // family - BYTE pitch = M_FONTDATA->GetNativeFontInfo(). - lf.lfPitchAndFamily & PITCH_MASK; + BYTE pitch = + (BYTE)(M_FONTDATA->GetNativeFontInfo().lf.lfPitchAndFamily & PITCH_MASK); return pitch == FIXED_PITCH; } diff --git a/src/msw/gsocket.cpp b/src/msw/gsocket.cpp index 620ad39cbf..fbe81c4a01 100644 --- a/src/msw/gsocket.cpp +++ b/src/msw/gsocket.cpp @@ -1528,24 +1528,15 @@ GSocketError _GAddress_Init_UNIX(GAddress *address) return GSOCK_INVADDR; } -GSocketError GAddress_UNIX_SetPath(GAddress *address, const char *path) +GSocketError GAddress_UNIX_SetPath(GAddress *address, const char *WXUNUSED(path)) { -#if defined(__BORLANDC__) - /* prevents unused variable message in Borland */ - (void)path; -#endif assert (address != NULL); address->m_error = GSOCK_INVADDR; return GSOCK_INVADDR; } -GSocketError GAddress_UNIX_GetPath(GAddress *address, char *path, size_t sbuf) +GSocketError GAddress_UNIX_GetPath(GAddress *address, char *WXUNUSED(path), size_t WXUNUSED(sbuf)) { -#if defined(__BORLANDC__) - /* prevents unused variable message in Borland */ - (void)path; - (void)sbuf; -#endif assert (address != NULL); address->m_error = GSOCK_INVADDR; return GSOCK_INVADDR; diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 1daf19b5e9..7daffb9b2a 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -4134,7 +4134,8 @@ bool wxWindowMSW::HandleMaximize() bool wxWindowMSW::HandleMove(int x, int y) { - wxMoveEvent event(wxPoint(x, y), m_windowId); + wxPoint point(x,y); + wxMoveEvent event(point, m_windowId); event.SetEventObject(this); return GetEventHandler()->ProcessEvent(event); @@ -4708,7 +4709,7 @@ int wxWindowMSW::HandleMenuChar(int chAccel, WXLPARAM lParam) // FIXME-UNICODE: this comparison doesn't risk to work // for non ASCII accelerator characters I'm afraid, but // what can we do? - if ( wxToupper(*p) == (wchar_t)chAccel ) + if ( (wchar_t)wxToupper(*p) == (wchar_t)chAccel ) { return i; }