From b42f9d836b4c0f7fbd4bdae1734021e2a09fdbe8 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sat, 1 Jun 2024 15:49:26 +0200 Subject: Re-enable a lot of compiler warnings for MSVC and address the C4267 "possible loss of precision" warnings --- indra/llimage/llimagedxt.cpp | 2 +- indra/llimage/llimagetga.cpp | 4 ++-- indra/llimage/llpngwrapper.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagedxt.cpp b/indra/llimage/llimagedxt.cpp index 89299258a6..6b960f9077 100644 --- a/indra/llimage/llimagedxt.cpp +++ b/indra/llimage/llimagedxt.cpp @@ -476,7 +476,7 @@ bool LLImageDXT::convertToDXR() // virtual S32 LLImageDXT::calcHeaderSize() { - return llmax(sizeof(dxtfile_header_old_t), sizeof(dxtfile_header_t)); + return static_cast(llmax(sizeof(dxtfile_header_old_t), sizeof(dxtfile_header_t))); } // virtual diff --git a/indra/llimage/llimagetga.cpp b/indra/llimage/llimagetga.cpp index b168f343e7..063ec3e763 100644 --- a/indra/llimage/llimagetga.cpp +++ b/indra/llimage/llimagetga.cpp @@ -1179,7 +1179,7 @@ bool LLImageTGA::decodeAndProcess( LLImageRaw* raw_image, F32 domain, F32 weight // Reads a .tga file and creates an LLImageTGA with its data. bool LLImageTGA::loadFile( const std::string& path ) { - S32 len = path.size(); + auto len = path.size(); if( len < 5 ) { return false; @@ -1206,7 +1206,7 @@ bool LLImageTGA::loadFile( const std::string& path ) } U8* buffer = allocateData(file_size); - S32 bytes_read = fread(buffer, 1, file_size, file); + S32 bytes_read = static_cast(fread(buffer, 1, file_size, file)); if( bytes_read != file_size ) { deleteData(); diff --git a/indra/llimage/llpngwrapper.cpp b/indra/llimage/llpngwrapper.cpp index a5fb7a3167..79c201b1f4 100644 --- a/indra/llimage/llpngwrapper.cpp +++ b/indra/llimage/llpngwrapper.cpp @@ -328,10 +328,10 @@ bool LLPngWrapper::writePng(const LLImageRaw* rawImage, U8* dest, size_t destSiz mWriteInfoPtr = png_create_info_struct(mWritePngPtr); // Setup write function - PngDataInfo dataPtr; + PngDataInfo dataPtr{}; dataPtr.mData = dest; dataPtr.mOffset = 0; - dataPtr.mDataSize = destSize; + dataPtr.mDataSize = static_cast(destSize); png_set_write_fn(mWritePngPtr, &dataPtr, &writeDataCallback, &writeFlush); // Setup image params -- cgit v1.2.3 From c0fad3028fd55c2067ce6a0ae4382cffe1014284 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Mon, 10 Jun 2024 16:42:43 +0200 Subject: Re-enable compiler warnings C4018, C4100, C4231 and C4506 --- indra/llimage/llimagefilter.cpp | 28 ++++++++++++++-------------- indra/llimage/llimagetga.cpp | 2 +- 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'indra/llimage') diff --git a/indra/llimage/llimagefilter.cpp b/indra/llimage/llimagefilter.cpp index db21f50b95..0d15906afd 100644 --- a/indra/llimage/llimagefilter.cpp +++ b/indra/llimage/llimagefilter.cpp @@ -781,9 +781,9 @@ void LLImageFilter::filterLinearize(F32 tail, const LLColor3& alpha) // Compute min and max counts minus tail tail = llclampf(tail); - S32 total = cumulated_histo[255]; - S32 min_c = (S32)((F32)(total) * tail); - S32 max_c = (S32)((F32)(total) * (1.0 - tail)); + U32 total = cumulated_histo[255]; + U32 min_c = (U32)((F32)(total) * tail); + U32 max_c = (U32)((F32)(total) * (1.0 - tail)); // Find min and max values S32 min_v = 0; @@ -798,9 +798,9 @@ void LLImageFilter::filterLinearize(F32 tail, const LLColor3& alpha) } // Compute linear lookup table - U8 linear_red_lut[256]; - U8 linear_green_lut[256]; - U8 linear_blue_lut[256]; + U8 linear_red_lut[256]{}; + U8 linear_green_lut[256]{}; + U8 linear_blue_lut[256]{}; if (max_v == min_v) { // Degenerated binary split case @@ -850,16 +850,16 @@ void LLImageFilter::filterEqualize(S32 nb_classes, const LLColor3& alpha) } // Compute deltas - S32 total = cumulated_histo[255]; - S32 delta_count = total / nb_classes; - S32 current_count = delta_count; - S32 delta_value = 256 / (nb_classes - 1); - S32 current_value = 0; + U32 total = cumulated_histo[255]; + U32 delta_count = total / nb_classes; + U32 current_count = delta_count; + U32 delta_value = 256 / (nb_classes - 1); + U32 current_value = 0; // Compute equalized lookup table - U8 equalize_red_lut[256]; - U8 equalize_green_lut[256]; - U8 equalize_blue_lut[256]; + U8 equalize_red_lut[256]{}; + U8 equalize_green_lut[256]{}; + U8 equalize_blue_lut[256]{}; for (S32 i = 0; i < 256; i++) { // Blend in current_value with alpha values diff --git a/indra/llimage/llimagetga.cpp b/indra/llimage/llimagetga.cpp index 063ec3e763..25232b77aa 100644 --- a/indra/llimage/llimagetga.cpp +++ b/indra/llimage/llimagetga.cpp @@ -467,7 +467,7 @@ bool LLImageTGA::decodeTruecolorNonRle( LLImageRaw* raw_image, bool &alpha_opaqu S32 pixels = getWidth() * getHeight(); - if (pixels * (mIs15Bit ? 2 : getComponents()) > getDataSize() - mDataOffset) + if (pixels * (mIs15Bit ? 2 : getComponents()) > getDataSize() - (S32)mDataOffset) { //here we have situation when data size in src less than actually needed return false; } -- cgit v1.2.3