1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-30 18:34:34 +01:00

FIx static analysers warnings and disable false positives.

This commit is contained in:
ocornut 2021-06-24 15:13:21 +02:00
parent 1965f38e9e
commit 20d415e939
5 changed files with 16 additions and 11 deletions

View File

@ -43,7 +43,7 @@ jobs:
cd examples/example_null cd examples/example_null
pvs-studio-analyzer trace -- make WITH_EXTRA_WARNINGS=1 pvs-studio-analyzer trace -- make WITH_EXTRA_WARNINGS=1
pvs-studio-analyzer analyze -e ../../imstb_rectpack.h -e ../../imstb_textedit.h -e ../../imstb_truetype.h -l ../../pvs-studio.lic -o pvs-studio.log pvs-studio-analyzer analyze -e ../../imstb_rectpack.h -e ../../imstb_textedit.h -e ../../imstb_truetype.h -l ../../pvs-studio.lic -o pvs-studio.log
plog-converter -a 'GA:1,2;OP:1' -t errorfile -w pvs-studio.log plog-converter -a 'GA:1,2;OP:1' -d V1071 -t errorfile -w pvs-studio.log
Discord-CI: Discord-CI:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04

View File

@ -278,8 +278,8 @@ static bool ImGui_ImplDX9_CreateFontsTexture()
#ifndef IMGUI_USE_BGRA_PACKED_COLOR #ifndef IMGUI_USE_BGRA_PACKED_COLOR
if (io.Fonts->TexPixelsUseColors) if (io.Fonts->TexPixelsUseColors)
{ {
ImU32* dst_start = (ImU32*)ImGui::MemAlloc(width * height * bytes_per_pixel); ImU32* dst_start = (ImU32*)ImGui::MemAlloc((size_t)width * height * bytes_per_pixel);
for (ImU32* src = (ImU32*)pixels, *dst = dst_start, *dst_end = dst_start + width * height; dst < dst_end; src++, dst++) for (ImU32* src = (ImU32*)pixels, *dst = dst_start, *dst_end = dst_start + (size_t)width * height; dst < dst_end; src++, dst++)
*dst = IMGUI_COL_TO_DX9_ARGB(*src); *dst = IMGUI_COL_TO_DX9_ARGB(*src);
pixels = (unsigned char*)dst_start; pixels = (unsigned char*)dst_start;
} }
@ -293,7 +293,7 @@ static bool ImGui_ImplDX9_CreateFontsTexture()
if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK) if (g_FontTexture->LockRect(0, &tex_locked_rect, NULL, 0) != D3D_OK)
return false; return false;
for (int y = 0; y < height; y++) for (int y = 0; y < height; y++)
memcpy((unsigned char*)tex_locked_rect.pBits + tex_locked_rect.Pitch * y, pixels + (width * bytes_per_pixel) * y, (width * bytes_per_pixel)); memcpy((unsigned char*)tex_locked_rect.pBits + (size_t)tex_locked_rect.Pitch * y, pixels + (size_t)width * bytes_per_pixel * y, (size_t)width * bytes_per_pixel);
g_FontTexture->UnlockRect(0); g_FontTexture->UnlockRect(0);
// Store our identifier // Store our identifier

View File

@ -420,6 +420,8 @@ static BOOL _IsWindowsVersionOrGreater(WORD major, WORD minor, WORD)
if (RtlVerifyVersionInfoFn == NULL) if (RtlVerifyVersionInfoFn == NULL)
if (HMODULE ntdllModule = ::GetModuleHandleA("ntdll.dll")) if (HMODULE ntdllModule = ::GetModuleHandleA("ntdll.dll"))
RtlVerifyVersionInfoFn = (PFN_RtlVerifyVersionInfo)GetProcAddress(ntdllModule, "RtlVerifyVersionInfo"); RtlVerifyVersionInfoFn = (PFN_RtlVerifyVersionInfo)GetProcAddress(ntdllModule, "RtlVerifyVersionInfo");
if (RtlVerifyVersionInfoFn == NULL)
return FALSE;
RTL_OSVERSIONINFOEXW versionInfo = { }; RTL_OSVERSIONINFOEXW versionInfo = { };
ULONGLONG conditionMask = 0; ULONGLONG conditionMask = 0;

View File

@ -8119,7 +8119,7 @@ void ImGui::TabItemLabelAndCloseButton(ImDrawList* draw_list, const ImRect& bb,
else if (unsaved_marker_visible) else if (unsaved_marker_visible)
{ {
const ImRect bullet_bb(button_pos, button_pos + ImVec2(button_sz, button_sz) + g.Style.FramePadding * 2.0f); const ImRect bullet_bb(button_pos, button_pos + ImVec2(button_sz, button_sz) + g.Style.FramePadding * 2.0f);
RenderBullet(bullet_bb.GetCenter()); RenderBullet(draw_list, bullet_bb.GetCenter(), GetColorU32(ImGuiCol_Text));
} }
// This is all rather complicated // This is all rather complicated

View File

@ -41,7 +41,8 @@
#include FT_SYNTHESIS_H // <freetype/ftsynth.h> #include FT_SYNTHESIS_H // <freetype/ftsynth.h>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff) #pragma warning (disable: 4505) // unreferenced local function has been removed (stb stuff)
#pragma warning (disable: 26812) // [Static Analyzer] The enum type 'xxx' is unscoped. Prefer 'enum class' over 'enum' (Enum.3).
#endif #endif
#if defined(__GNUC__) #if defined(__GNUC__)
@ -600,13 +601,15 @@ bool ImFontAtlasBuildWithFreeTypeEx(FT_Library ft_library, ImFontAtlas* atlas, u
atlas->TexUvScale = ImVec2(1.0f / atlas->TexWidth, 1.0f / atlas->TexHeight); atlas->TexUvScale = ImVec2(1.0f / atlas->TexWidth, 1.0f / atlas->TexHeight);
if (src_load_color) if (src_load_color)
{ {
atlas->TexPixelsRGBA32 = (unsigned int*)IM_ALLOC(atlas->TexWidth * atlas->TexHeight * 4); size_t tex_size = (size_t)atlas->TexWidth * atlas->TexHeight * 4;
memset(atlas->TexPixelsRGBA32, 0, atlas->TexWidth * atlas->TexHeight * 4); atlas->TexPixelsRGBA32 = (unsigned int*)IM_ALLOC(tex_size);
memset(atlas->TexPixelsRGBA32, 0, tex_size);
} }
else else
{ {
atlas->TexPixelsAlpha8 = (unsigned char*)IM_ALLOC(atlas->TexWidth * atlas->TexHeight); size_t tex_size = (size_t)atlas->TexWidth * atlas->TexHeight * 1;
memset(atlas->TexPixelsAlpha8, 0, atlas->TexWidth * atlas->TexHeight); atlas->TexPixelsAlpha8 = (unsigned char*)IM_ALLOC(tex_size);
memset(atlas->TexPixelsAlpha8, 0, tex_size);
} }
// 8. Copy rasterized font characters back into the main texture // 8. Copy rasterized font characters back into the main texture