From 7cbe23830f156c61f6238aba99a2854124d9612b Mon Sep 17 00:00:00 2001 From: Paul Cornett Date: Fri, 5 Apr 2019 09:55:49 -0700 Subject: [PATCH] Avoid truncation of expression assigned to larger type --- samples/validate/validate.cpp | 4 ++-- src/common/image.cpp | 4 ++-- src/common/imagtga.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/samples/validate/validate.cpp b/samples/validate/validate.cpp index 55bf6a0169..40397aa270 100644 --- a/samples/validate/validate.cpp +++ b/samples/validate/validate.cpp @@ -650,7 +650,7 @@ bool TextValidatorDialog::StyleValidator::TransferToWindow() if ( !cb ) return false; - const long style = 1 << (cb->GetId()-wxID_HIGHEST-1); + const long style = 1L << (cb->GetId()-wxID_HIGHEST-1); cb->SetValue((*m_style & style) != 0); } @@ -668,7 +668,7 @@ bool TextValidatorDialog::StyleValidator::TransferFromWindow() if ( !cb ) return false; - const long style = 1 << (cb->GetId()-wxID_HIGHEST-1); + const long style = 1L << (cb->GetId()-wxID_HIGHEST-1); if ( cb->IsChecked() ) *m_style |= style; diff --git a/src/common/image.cpp b/src/common/image.cpp index c3e79a571d..daae5d3427 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -3453,7 +3453,7 @@ unsigned long wxImage::CountColours( unsigned long stopafter ) const unsigned long size, nentries, key; p = GetData(); - size = GetWidth() * GetHeight(); + size = static_cast(GetWidth()) * GetHeight(); nentries = 0; for (unsigned long j = 0; (j < size) && (nentries <= stopafter) ; j++) @@ -3481,7 +3481,7 @@ unsigned long wxImage::ComputeHistogram( wxImageHistogram &h ) const h.clear(); - const unsigned long size = GetWidth() * GetHeight(); + const unsigned long size = static_cast(GetWidth()) * GetHeight(); unsigned char r, g, b; for ( unsigned long n = 0; n < size; n++ ) diff --git a/src/common/imagtga.cpp b/src/common/imagtga.cpp index 5b5ec55259..632d1f820c 100644 --- a/src/common/imagtga.cpp +++ b/src/common/imagtga.cpp @@ -233,7 +233,7 @@ int ReadTGA(wxImage* image, wxInputStream& stream) const short pixelSize = bpp / 8; - const unsigned long imageSize = width * height * pixelSize; + const unsigned long imageSize = static_cast(width) * height * pixelSize; wxScopedArray imageData(imageSize);