Skip to content

Commit

Permalink
Fixed: static analysis generated warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNicker committed Sep 12, 2023
1 parent dabf3c6 commit 78a6b99
Show file tree
Hide file tree
Showing 7 changed files with 197 additions and 157 deletions.
40 changes: 38 additions & 2 deletions FreeTypeWrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,44 @@ target_include_directories(${TargetName} PRIVATE ./External/LLUtils/Include)

if (FREETYPE_WRAPPER_DISABLE_WARNINGS_EXTERNAL_LIBS)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# target_compile_options(freetype PRIVATE -Wno-deprecated-declarations)

target_compile_options(freetype PRIVATE -Wno-documentation
-Wno-documentation-unknown-command
-Wno-unsafe-buffer-usage
-Wno-cast-qual
-Wno-sign-conversion
-Wno-unused-macros
-Wno-switch-enum
-Wno-tautological-type-limit-compare
-Wno-implicit-fallthrough
-Wno-shorten-64-to-32
-Wno-cast-align
-Wno-cast-align
-Wno-implicit-int-conversion
-Wno-nonportable-system-include-path
-Wno-missing-noreturn
-Wno-extra-semi-stmt
)
if (FREETYPE_WRAPPER_BUILD_FRIBIDI)
target_compile_options(libfribidi PRIVATE
-Wno-undef
-Wno-unused-macros
-Wno-sign-conversion
-Wno-missing-variable-declarations
-Wno-cast-qual
-Wno-extra-semi-stmt
-Wno-assign-enum
-Wno-unused-function
-Wno-implicit-int-conversion
-Wno-shorten-64-to-32
-Wno-enum-conversion
-Wno-shadow
-Wno-unsafe-buffer-usage
-Wno-reserved-identifier

)
endif()

elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
target_compile_options(freetype PRIVATE /wd4267 /wd4244 /wd4267 /wd4244)
if (FREETYPE_WRAPPER_BUILD_FRIBIDI)
Expand All @@ -47,7 +84,6 @@ if (FREETYPE_WRAPPER_DISABLE_WARNINGS_EXTERNAL_LIBS)
endif()
endif()

#add_subdirectory(${FreeTypePath} ${FreeTypeOutput})
target_link_libraries(${TargetName} PRIVATE freetype)
if (FREETYPE_WRAPPER_BUILD_FRIBIDI)
target_link_libraries(${TargetName} PRIVATE libfribidi)
Expand Down
28 changes: 14 additions & 14 deletions FreeTypeWrapper/Include/FreeTypeWrapper/FreeTypeConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ namespace FreeType
{
std::wstring fontPath;
std::wstring text;
uint16_t fontSize;
uint16_t fontSize{};
LLUtils::Color textColor;
LLUtils::Color backgroundColor;
LLUtils::Color outlineColor;
uint32_t outlineWidth;
uint32_t maxWidthPx;
RenderMode renderMode;
uint16_t DPIx;
uint16_t DPIy;
uint16_t padding;
TextCreateFlags flags;
uint32_t outlineWidth{};
uint32_t maxWidthPx{};
RenderMode renderMode{};
uint16_t DPIx{};
uint16_t DPIy{};
uint16_t padding{};
TextCreateFlags flags{};
};


Expand All @@ -74,7 +74,7 @@ namespace FreeType
{
std::vector<LineMetrics> lineMetrics;
LLUtils::RectI32 rect;
uint32_t rowHeight;
uint32_t rowHeight{};
int32_t minX = std::numeric_limits<int32_t>::max();
int32_t maxX = std::numeric_limits<int32_t>::min();
};
Expand All @@ -89,11 +89,11 @@ namespace FreeType

struct Bitmap
{
uint32_t width;
uint32_t height;
LLUtils::Buffer buffer;
uint32_t PixelSize;
uint32_t rowPitch;
uint32_t width{};
uint32_t height{};
LLUtils::Buffer buffer{};
uint32_t PixelSize{};
uint32_t rowPitch{};
};


Expand Down
10 changes: 8 additions & 2 deletions FreeTypeWrapper/Source/BlitBox.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once
#include <cstdint>
#include <LLUtils/Warnings.h>
namespace FreeType
{
struct BlitBox
Expand All @@ -20,13 +21,16 @@ namespace FreeType
template <typename color_type>
static void BlitPremultiplied (BlitBox& dst, const BlitBox& src)
{
LLUTILS_DISABLE_WARNING_PUSH
LLUTILS_DISABLE_WARNING_UNSAFE_BUFFER_USAGE

const std::byte* srcPos = src.buffer + src.GetStartOffset();
std::byte* dstPos = dst.buffer + dst.GetStartOffset();

//Perform range check on target.
if (dst.left + src.width > dst.width || dst.top + src.height > dst.height)
LL_EXCEPTION(LLUtils::Exception::ErrorCode::LogicError, "Buffer out of bounds");

LLUTILS_DISABLE_WARNING_POP
const uint32_t bytesPerLine = src.pixelSizeInbytes * src.width;

for (uint32_t y = src.top; y < src.height; y++)
Expand All @@ -47,13 +51,15 @@ namespace FreeType

static void Blit(BlitBox& dst, const BlitBox& src)
{
LLUTILS_DISABLE_WARNING_PUSH
LLUTILS_DISABLE_WARNING_UNSAFE_BUFFER_USAGE
const std::byte* srcPos = src.buffer + src.GetStartOffset();
std::byte* dstPos = dst.buffer + dst.GetStartOffset();

//Perform range check on target.
if (dst.left + src.width > dst.width || dst.top + src.height > dst.height)
LL_EXCEPTION(LLUtils::Exception::ErrorCode::LogicError, "Buffer out of bounds");

LLUTILS_DISABLE_WARNING_POP

const uint32_t bytesPerLine = src.pixelSizeInbytes * src.width;

Expand Down
Loading

0 comments on commit 78a6b99

Please sign in to comment.