From: Eunki, Hong Date: Tue, 7 Feb 2023 01:55:00 +0000 (+0900) Subject: Fix svace issue (uint32_t to long or std::streamsize) X-Git-Tag: dali_2.2.13~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a96ad9c8ac26fbc2799a96bc298f3e6d1136c4b8;p=platform%2Fcore%2Fuifw%2Fdali-adaptor.git Fix svace issue (uint32_t to long or std::streamsize) To convert unsigned value into signed value safely, we should convert as unsigned type with same size as signed type, and after done, convert into signed type. Change-Id: I3d8ebb3866c2bd753dd186026f7e1773e0f178a9 Signed-off-by: Eunki, Hong --- diff --git a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-buffer.cpp b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-buffer.cpp index 27f0dce..42b53b1 100644 --- a/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-buffer.cpp +++ b/automated-tests/src/dali-adaptor/dali-test-suite-utils/test-graphics-buffer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,11 +61,11 @@ void TestGraphicsBuffer::Upload(uint32_t offset, uint32_t size) if(size <= memory.size() && mCreated) { // Use subData to avoid re-allocation - mGl.BufferSubData(GetTarget(), offset, size, &memory[offset]); + mGl.BufferSubData(GetTarget(), static_cast(static_cast(offset)), static_cast(static_cast(size)), &memory[offset]); } else { - mGl.BufferData(GetTarget(), GLsizeiptr(size), &memory[0], GL_STATIC_DRAW); //@todo Query - do we need other usages? + mGl.BufferData(GetTarget(), static_cast(static_cast(size)), &memory[0], GL_STATIC_DRAW); //@todo Query - do we need other usages? mCreated = true; } } diff --git a/dali/internal/adaptor-framework/generic/file-stream-impl-generic.cpp b/dali/internal/adaptor-framework/generic/file-stream-impl-generic.cpp index 8af04d2..585d79f 100644 --- a/dali/internal/adaptor-framework/generic/file-stream-impl-generic.cpp +++ b/dali/internal/adaptor-framework/generic/file-stream-impl-generic.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -137,7 +137,7 @@ std::iostream& FileStream::Impl::GetStream() } else if(mBuffer) { - mBufferStream.rdbuf()->pubsetbuf(reinterpret_cast(mBuffer), mDataSize); + mBufferStream.rdbuf()->pubsetbuf(reinterpret_cast(mBuffer), static_cast(static_cast(mDataSize))); if(!mBufferStream.rdbuf()->in_avail()) { DALI_LOG_WARNING("File open failed for memory buffer at location: \"%p\", of size: \"%u\", in mode: \"%d\".\n", diff --git a/dali/internal/imaging/common/loader-bmp.cpp b/dali/internal/imaging/common/loader-bmp.cpp index 05d0518..6d3a5de 100644 --- a/dali/internal/imaging/common/loader-bmp.cpp +++ b/dali/internal/imaging/common/loader-bmp.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -141,7 +141,7 @@ bool DecodeRGB24V5(FILE* fp, DALI_LOG_ERROR("Error decoding BMP_RGB24V5 format\n"); return false; } - if(DALI_UNLIKELY(fseek(fp, offset, SEEK_SET))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(offset)), SEEK_SET))) { DALI_LOG_ERROR("Error seeking BMP_RGB24V5 data\n"); return false; @@ -173,7 +173,7 @@ bool DecodeRGB24V5(FILE* fp, if(padding) { // move past the padding. - if(DALI_UNLIKELY(fseek(fp, padding, SEEK_CUR))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(padding)), SEEK_CUR))) { DALI_LOG_ERROR("Error moving past BMP_RGB24V5 padding\n"); } @@ -208,7 +208,7 @@ bool DecodeBF32V4(FILE* fp, DALI_LOG_ERROR("Error decoding BMP_BITFIELDS32V4 format\n"); return false; } - if(DALI_UNLIKELY(fseek(fp, offset, SEEK_SET))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(offset)), SEEK_SET))) { DALI_LOG_ERROR("Error seeking BMP_BITFIELDS32V4 data\n"); return false; @@ -239,7 +239,7 @@ bool DecodeBF32V4(FILE* fp, if(padding) { // move past the padding. - if(DALI_UNLIKELY(fseek(fp, padding, SEEK_CUR))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(padding)), SEEK_CUR))) { DALI_LOG_ERROR("Error moving past BMP_BITFIELDS32V4 padding\n"); } @@ -274,7 +274,7 @@ bool DecodeBF32(FILE* fp, DALI_LOG_ERROR("Error decoding BMP_BITFIELDS32 format\n"); return false; } - if(DALI_UNLIKELY(fseek(fp, offset, SEEK_SET))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(offset)), SEEK_SET))) { DALI_LOG_ERROR("Error seeking BMP_BITFIELDS32 data\n"); return false; @@ -309,7 +309,7 @@ bool DecodeBF32(FILE* fp, if(padding) { // move past the padding. - if(DALI_UNLIKELY(fseek(fp, padding, SEEK_CUR))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(padding)), SEEK_CUR))) { DALI_LOG_ERROR("Error moving past BMP_BITFIELDS32 padding\n"); } @@ -340,7 +340,7 @@ bool DecodeBF565(FILE* fp, DALI_LOG_ERROR("Error decoding RGB565 format\n"); return false; } - if(DALI_UNLIKELY(fseek(fp, offset, SEEK_SET))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(offset)), SEEK_SET))) { DALI_LOG_ERROR("Error seeking RGB565 data\n"); return false; @@ -394,7 +394,7 @@ bool DecodeBF555(FILE* fp, return false; } - if(DALI_UNLIKELY(fseek(fp, offset, SEEK_SET))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(offset)), SEEK_SET))) { DALI_LOG_ERROR("Error seeking BMP_BITFIELDS555 data\n"); return false; @@ -463,7 +463,7 @@ bool DecodeRGB555(FILE* fp, DALI_LOG_ERROR("Error decoding BMP_RGB555 format\n"); return false; } - if(DALI_UNLIKELY(fseek(fp, offset, SEEK_SET))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(offset)), SEEK_SET))) { DALI_LOG_ERROR("Error seeking BMP_RGB555 data\n"); return false; @@ -529,7 +529,7 @@ bool DecodeRGB1(FILE* fp, DALI_LOG_ERROR("Error decoding BMP_RGB1 format\n"); return false; } - if(DALI_UNLIKELY(fseek(fp, offset, SEEK_SET))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(offset)), SEEK_SET))) { DALI_LOG_ERROR("Error seeking BMP_RGB1 data\n"); return false; @@ -621,7 +621,7 @@ bool DecodeRGB4(FILE* fp, DALI_LOG_ERROR("Error decoding BMP_RGB4 format\n"); return false; } - if(DALI_UNLIKELY(fseek(fp, offset, SEEK_SET))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(offset)), SEEK_SET))) { DALI_LOG_ERROR("Error seeking BMP_RGB4 data\n"); return false; @@ -697,7 +697,7 @@ bool DecodeRGB8(FILE* fp, DALI_LOG_ERROR("Error decoding BMP_RGB8 format\n"); return false; } - if(DALI_UNLIKELY(fseek(fp, offset, SEEK_SET))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(offset)), SEEK_SET))) { DALI_LOG_ERROR("Error seeking BMP_RGB8 data\n"); return false; @@ -779,7 +779,7 @@ bool DecodeRLE4(FILE* fp, bool finish = false; - if(DALI_UNLIKELY(fseek(fp, offset, SEEK_SET))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(offset)), SEEK_SET))) { DALI_LOG_ERROR("Error seeking BMP_RLE4 data\n"); return false; @@ -941,7 +941,7 @@ bool DecodeRLE8(FILE* fp, std::uint8_t cmd[2]; std::vector colorIndex(width * height); - if(DALI_UNLIKELY(fseek(fp, offset, SEEK_SET))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(offset)), SEEK_SET))) { DALI_LOG_ERROR("Error seeking BMP_RLE8 data\n"); return false; @@ -1127,7 +1127,7 @@ bool LoadBitmapFromBmp(const Dali::ImageLoader::Input& input, Dali::Devel::Pixel { if(infoHeader.bitsPerPixel == 16) { - if(DALI_UNLIKELY(fseek(fp, 14 + infoHeader.infoHeaderSize + 1, SEEK_SET))) + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(14 + infoHeader.infoHeaderSize + 1)), SEEK_SET))) { return false; } @@ -1342,7 +1342,7 @@ bool LoadBitmapFromBmp(const Dali::ImageLoader::Input& input, Dali::Devel::Pixel if(padding) { - if(DALI_UNLIKELY(fseek(fp, padding, SEEK_CUR))) // move past the padding. + if(DALI_UNLIKELY(fseek(fp, static_cast(static_cast(padding)), SEEK_CUR))) // move past the padding. { DALI_LOG_ERROR("Error moving past BMP padding\n"); }