Skip to content

Commit 78a6b99

Browse files
committed
Fixed: static analysis generated warnings
1 parent dabf3c6 commit 78a6b99

7 files changed

Lines changed: 197 additions & 157 deletions

File tree

FreeTypeWrapper/CMakeLists.txt

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,44 @@ target_include_directories(${TargetName} PRIVATE ./External/LLUtils/Include)
3838

3939
if (FREETYPE_WRAPPER_DISABLE_WARNINGS_EXTERNAL_LIBS)
4040
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
41-
# target_compile_options(freetype PRIVATE -Wno-deprecated-declarations)
41+
42+
target_compile_options(freetype PRIVATE -Wno-documentation
43+
-Wno-documentation-unknown-command
44+
-Wno-unsafe-buffer-usage
45+
-Wno-cast-qual
46+
-Wno-sign-conversion
47+
-Wno-unused-macros
48+
-Wno-switch-enum
49+
-Wno-tautological-type-limit-compare
50+
-Wno-implicit-fallthrough
51+
-Wno-shorten-64-to-32
52+
-Wno-cast-align
53+
-Wno-cast-align
54+
-Wno-implicit-int-conversion
55+
-Wno-nonportable-system-include-path
56+
-Wno-missing-noreturn
57+
-Wno-extra-semi-stmt
58+
)
59+
if (FREETYPE_WRAPPER_BUILD_FRIBIDI)
60+
target_compile_options(libfribidi PRIVATE
61+
-Wno-undef
62+
-Wno-unused-macros
63+
-Wno-sign-conversion
64+
-Wno-missing-variable-declarations
65+
-Wno-cast-qual
66+
-Wno-extra-semi-stmt
67+
-Wno-assign-enum
68+
-Wno-unused-function
69+
-Wno-implicit-int-conversion
70+
-Wno-shorten-64-to-32
71+
-Wno-enum-conversion
72+
-Wno-shadow
73+
-Wno-unsafe-buffer-usage
74+
-Wno-reserved-identifier
75+
76+
)
77+
endif()
78+
4279
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
4380
target_compile_options(freetype PRIVATE /wd4267 /wd4244 /wd4267 /wd4244)
4481
if (FREETYPE_WRAPPER_BUILD_FRIBIDI)
@@ -47,7 +84,6 @@ if (FREETYPE_WRAPPER_DISABLE_WARNINGS_EXTERNAL_LIBS)
4784
endif()
4885
endif()
4986

50-
#add_subdirectory(${FreeTypePath} ${FreeTypeOutput})
5187
target_link_libraries(${TargetName} PRIVATE freetype)
5288
if (FREETYPE_WRAPPER_BUILD_FRIBIDI)
5389
target_link_libraries(${TargetName} PRIVATE libfribidi)

FreeTypeWrapper/Include/FreeTypeWrapper/FreeTypeConnector.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,17 @@ namespace FreeType
4646
{
4747
std::wstring fontPath;
4848
std::wstring text;
49-
uint16_t fontSize;
49+
uint16_t fontSize{};
5050
LLUtils::Color textColor;
5151
LLUtils::Color backgroundColor;
5252
LLUtils::Color outlineColor;
53-
uint32_t outlineWidth;
54-
uint32_t maxWidthPx;
55-
RenderMode renderMode;
56-
uint16_t DPIx;
57-
uint16_t DPIy;
58-
uint16_t padding;
59-
TextCreateFlags flags;
53+
uint32_t outlineWidth{};
54+
uint32_t maxWidthPx{};
55+
RenderMode renderMode{};
56+
uint16_t DPIx{};
57+
uint16_t DPIy{};
58+
uint16_t padding{};
59+
TextCreateFlags flags{};
6060
};
6161

6262

@@ -74,7 +74,7 @@ namespace FreeType
7474
{
7575
std::vector<LineMetrics> lineMetrics;
7676
LLUtils::RectI32 rect;
77-
uint32_t rowHeight;
77+
uint32_t rowHeight{};
7878
int32_t minX = std::numeric_limits<int32_t>::max();
7979
int32_t maxX = std::numeric_limits<int32_t>::min();
8080
};
@@ -89,11 +89,11 @@ namespace FreeType
8989

9090
struct Bitmap
9191
{
92-
uint32_t width;
93-
uint32_t height;
94-
LLUtils::Buffer buffer;
95-
uint32_t PixelSize;
96-
uint32_t rowPitch;
92+
uint32_t width{};
93+
uint32_t height{};
94+
LLUtils::Buffer buffer{};
95+
uint32_t PixelSize{};
96+
uint32_t rowPitch{};
9797
};
9898

9999

FreeTypeWrapper/Source/BlitBox.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#pragma once
22
#include <cstdint>
3+
#include <LLUtils/Warnings.h>
34
namespace FreeType
45
{
56
struct BlitBox
@@ -20,13 +21,16 @@ namespace FreeType
2021
template <typename color_type>
2122
static void BlitPremultiplied (BlitBox& dst, const BlitBox& src)
2223
{
24+
LLUTILS_DISABLE_WARNING_PUSH
25+
LLUTILS_DISABLE_WARNING_UNSAFE_BUFFER_USAGE
26+
2327
const std::byte* srcPos = src.buffer + src.GetStartOffset();
2428
std::byte* dstPos = dst.buffer + dst.GetStartOffset();
2529

2630
//Perform range check on target.
2731
if (dst.left + src.width > dst.width || dst.top + src.height > dst.height)
2832
LL_EXCEPTION(LLUtils::Exception::ErrorCode::LogicError, "Buffer out of bounds");
29-
33+
LLUTILS_DISABLE_WARNING_POP
3034
const uint32_t bytesPerLine = src.pixelSizeInbytes * src.width;
3135

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

4852
static void Blit(BlitBox& dst, const BlitBox& src)
4953
{
54+
LLUTILS_DISABLE_WARNING_PUSH
55+
LLUTILS_DISABLE_WARNING_UNSAFE_BUFFER_USAGE
5056
const std::byte* srcPos = src.buffer + src.GetStartOffset();
5157
std::byte* dstPos = dst.buffer + dst.GetStartOffset();
5258

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

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

0 commit comments

Comments
 (0)