From c150ece20fd339eef0d149461dd04e37bdc2c9f9 Mon Sep 17 00:00:00 2001 From: catalinr Date: Mon, 14 Oct 2019 07:49:28 +0300 Subject: [PATCH 1/5] Cast int to double to avoid arithmetic overflow warning --- include/wx/geometry.h | 4 ++-- include/wx/math.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/wx/geometry.h b/include/wx/geometry.h index a3b3f1b8c7..513ff1385e 100644 --- a/include/wx/geometry.h +++ b/include/wx/geometry.h @@ -133,7 +133,7 @@ inline void wxPoint2DInt::GetRounded( wxInt32 *x , wxInt32 *y ) const inline wxDouble wxPoint2DInt::GetVectorLength() const { // cast needed MIPSpro compiler under SGI - return sqrt( (double)(m_x)*(m_x) + (m_y)*(m_y) ); + return sqrt( (wxDouble)(m_x)*(m_x) + (wxDouble)(m_y)*(m_y) ); } inline void wxPoint2DInt::SetVectorLength( wxDouble length ) @@ -155,7 +155,7 @@ inline wxDouble wxPoint2DInt::GetDistance( const wxPoint2DInt &pt ) const inline wxDouble wxPoint2DInt::GetDistanceSquare( const wxPoint2DInt &pt ) const { - return ( (pt.m_x-m_x)*(pt.m_x-m_x) + (pt.m_y-m_y)*(pt.m_y-m_y) ); + return ( (wxDouble)(pt.m_x-m_x)*(pt.m_x-m_x) + (wxDouble)(pt.m_y-m_y)*(pt.m_y-m_y) ); } inline wxInt32 wxPoint2DInt::GetDotProduct( const wxPoint2DInt &vec ) const diff --git a/include/wx/math.h b/include/wx/math.h index 261969d364..89d0bc719f 100644 --- a/include/wx/math.h +++ b/include/wx/math.h @@ -136,7 +136,7 @@ inline bool wxIsNullDouble(double x) { return wxIsSameDouble(x, 0.); } inline int wxRound(double x) { - wxASSERT_MSG( x > INT_MIN - 0.5 && x < INT_MAX + 0.5, + wxASSERT_MSG( x > (double)INT_MIN - 0.5 && x < (double)INT_MAX + 0.5, wxT("argument out of supported range") ); #if defined(HAVE_ROUND) From 2fc569f0c21dc7fda873628cf5ce06584d8a2a2f Mon Sep 17 00:00:00 2001 From: catalinr Date: Mon, 14 Oct 2019 07:53:21 +0300 Subject: [PATCH 2/5] Initialize member variables to avoid warnings --- include/wx/any.h | 1 + include/wx/event.h | 2 +- include/wx/gauge.h | 3 +++ include/wx/generic/choicdgg.h | 2 +- include/wx/generic/textdlgg.h | 1 + include/wx/list.h | 2 +- include/wx/msw/checkbox.h | 2 +- include/wx/strconv.h | 4 ++-- include/wx/string.h | 2 +- 9 files changed, 12 insertions(+), 7 deletions(-) diff --git a/include/wx/any.h b/include/wx/any.h index 4bf9b0eef4..3d057c8a60 100644 --- a/include/wx/any.h +++ b/include/wx/any.h @@ -730,6 +730,7 @@ public: wxAny() { m_type = wxAnyNullValueType; + m_buffer = { 0 }; } /** diff --git a/include/wx/event.h b/include/wx/event.h index 3b5a975c01..fd25c7a1ca 100644 --- a/include/wx/event.h +++ b/include/wx/event.h @@ -244,7 +244,7 @@ private: wxEventFunction m_method; // Provide a dummy default ctor for type info purposes - wxObjectEventFunctor() { } + wxObjectEventFunctor() : m_handler(NULL), m_method(NULL) { } WX_DECLARE_TYPEINFO_INLINE(wxObjectEventFunctor) }; diff --git a/include/wx/gauge.h b/include/wx/gauge.h index d89f089131..b1ddac7769 100644 --- a/include/wx/gauge.h +++ b/include/wx/gauge.h @@ -52,6 +52,9 @@ class WXDLLIMPEXP_CORE wxGaugeBase : public wxControl { public: wxGaugeBase() : m_rangeMax(0), m_gaugePos(0), +#if wxGAUGE_EMULATE_INDETERMINATE_MODE + m_nDirection(wxRIGHT), +#endif m_appProgressIndicator(NULL) { } virtual ~wxGaugeBase(); diff --git a/include/wx/generic/choicdgg.h b/include/wx/generic/choicdgg.h index 114d666230..152b581c81 100644 --- a/include/wx/generic/choicdgg.h +++ b/include/wx/generic/choicdgg.h @@ -33,7 +33,7 @@ class WXDLLIMPEXP_FWD_CORE wxListBoxBase; class WXDLLIMPEXP_CORE wxAnyChoiceDialog : public wxDialog { public: - wxAnyChoiceDialog() { } + wxAnyChoiceDialog() : m_listbox(NULL) { } wxAnyChoiceDialog(wxWindow *parent, const wxString& message, diff --git a/include/wx/generic/textdlgg.h b/include/wx/generic/textdlgg.h index a3749844fd..9aee847083 100644 --- a/include/wx/generic/textdlgg.h +++ b/include/wx/generic/textdlgg.h @@ -39,6 +39,7 @@ public: wxTextEntryDialog() { m_textctrl = NULL; + m_dialogStyle = 0; } wxTextEntryDialog(wxWindow *parent, diff --git a/include/wx/list.h b/include/wx/list.h index cc58fe04f8..3c3ddd896e 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -333,7 +333,7 @@ class WXDLLIMPEXP_BASE wxListKey public: // implicit ctors wxListKey() : m_keyType(wxKEY_NONE) - { } + { m_key.integer = 0; } wxListKey(long i) : m_keyType(wxKEY_INTEGER) { m_key.integer = i; } wxListKey(const wxString& s) : m_keyType(wxKEY_STRING) diff --git a/include/wx/msw/checkbox.h b/include/wx/msw/checkbox.h index afecb4baf9..f8b12c1f3b 100644 --- a/include/wx/msw/checkbox.h +++ b/include/wx/msw/checkbox.h @@ -17,7 +17,7 @@ class WXDLLIMPEXP_CORE wxCheckBox : public wxMSWOwnerDrawnButton { public: - wxCheckBox() { } + wxCheckBox() : m_state(wxCHK_UNCHECKED) { } wxCheckBox(wxWindow *parent, wxWindowID id, const wxString& label, diff --git a/include/wx/strconv.h b/include/wx/strconv.h index d344a5a911..f6088e10c0 100644 --- a/include/wx/strconv.h +++ b/include/wx/strconv.h @@ -288,7 +288,7 @@ private: public: // the initial state is direct - DecoderState() { mode = Direct; } + DecoderState() { mode = Direct; accum = bit = msb = 0; } // switch to/from shifted mode void ToDirect() { mode = Direct; } @@ -317,7 +317,7 @@ private: Mode mode; public: - EncoderState() { mode = Direct; } + EncoderState() { mode = Direct; accum = bit = 0; } void ToDirect() { mode = Direct; } void ToShifted() { mode = Shifted; accum = bit = 0; } diff --git a/include/wx/string.h b/include/wx/string.h index 6e579ed616..88bbe43fe0 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -3379,7 +3379,7 @@ private: { // notice that there is no need to initialize m_len here as it's unused // as long as m_str is NULL - ConvertedBuffer() : m_str(NULL) {} + ConvertedBuffer() : m_str(NULL), m_len(0) {} ~ConvertedBuffer() { free(m_str); } From 0508764973841c961478ee6dcda97b1290f526e2 Mon Sep 17 00:00:00 2001 From: catalinr Date: Mon, 14 Oct 2019 08:10:41 +0300 Subject: [PATCH 3/5] Initialize isLSB to avoid warning --- include/wx/strconv.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/wx/strconv.h b/include/wx/strconv.h index f6088e10c0..8474876500 100644 --- a/include/wx/strconv.h +++ b/include/wx/strconv.h @@ -288,7 +288,7 @@ private: public: // the initial state is direct - DecoderState() { mode = Direct; accum = bit = msb = 0; } + DecoderState() { mode = Direct; accum = bit = msb = 0; isLSB = false; } // switch to/from shifted mode void ToDirect() { mode = Direct; } From 62981e156146ebe203a00c9a34b3101b2323ce4b Mon Sep 17 00:00:00 2001 From: catalinr Date: Mon, 14 Oct 2019 21:34:00 +0300 Subject: [PATCH 4/5] Move member initialization in default ctor --- include/wx/any.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/wx/any.h b/include/wx/any.h index 3d057c8a60..4883214b46 100644 --- a/include/wx/any.h +++ b/include/wx/any.h @@ -41,6 +41,11 @@ union wxAnyValueBuffer void* m_ptr; wxByte m_buffer[WX_ANY_VALUE_BUFFER_SIZE]; + + wxAnyValueBuffer() + { + m_ptr = NULL; + } }; // @@ -730,7 +735,6 @@ public: wxAny() { m_type = wxAnyNullValueType; - m_buffer = { 0 }; } /** From 67dd28619fc568fdfbe25ec68c103605c767b5c2 Mon Sep 17 00:00:00 2001 From: catalinr Date: Mon, 14 Oct 2019 22:20:37 +0300 Subject: [PATCH 5/5] Cast more int vars to double to avoid overflow warning --- include/wx/geometry.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/wx/geometry.h b/include/wx/geometry.h index 513ff1385e..287a211da6 100644 --- a/include/wx/geometry.h +++ b/include/wx/geometry.h @@ -155,7 +155,8 @@ inline wxDouble wxPoint2DInt::GetDistance( const wxPoint2DInt &pt ) const inline wxDouble wxPoint2DInt::GetDistanceSquare( const wxPoint2DInt &pt ) const { - return ( (wxDouble)(pt.m_x-m_x)*(pt.m_x-m_x) + (wxDouble)(pt.m_y-m_y)*(pt.m_y-m_y) ); + return ( ((wxDouble)pt.m_x-m_x)*((wxDouble)pt.m_x-m_x) + + ((wxDouble)pt.m_y-m_y)*((wxDouble)pt.m_y-m_y) ); } inline wxInt32 wxPoint2DInt::GetDotProduct( const wxPoint2DInt &vec ) const