From 4e8e177cac657428fe511cb3a8b942b1654bd7f4 Mon Sep 17 00:00:00 2001 From: omar Date: Sun, 27 Jan 2019 16:35:48 +0100 Subject: [PATCH] Persistently fixing some PVS-Studio static analyzer false positive warnings. --- imgui_demo.cpp | 2 +- imgui_draw.cpp | 4 ++-- imgui_widgets.cpp | 4 ++-- imstb_truetype.h | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/imgui_demo.cpp b/imgui_demo.cpp index d3257493f..0ff6fb4a7 100644 --- a/imgui_demo.cpp +++ b/imgui_demo.cpp @@ -882,7 +882,7 @@ static void ShowDemoWindowWidgets() // Note: We _unnecessarily_ test for both x/y and i here only to silence some static analyzer. The second part of each test is unnecessary. int x = i % 4; int y = i / 4; - if (x > 0 && i > 0) { selected[i - 1] ^= 1; } + if (x > 0) { selected[i - 1] ^= 1; } if (x < 3 && i < 15) { selected[i + 1] ^= 1; } if (y > 0 && i > 3) { selected[i - 4] ^= 1; } if (y < 3 && i < 12) { selected[i + 4] ^= 1; } diff --git a/imgui_draw.cpp b/imgui_draw.cpp index 046600a0c..b73299b1c 100644 --- a/imgui_draw.cpp +++ b/imgui_draw.cpp @@ -689,7 +689,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32 PrimReserve(idx_count, vtx_count); // Temporary buffer - ImVec2* temp_normals = (ImVec2*)alloca(points_count * (thick_line ? 5 : 3) * sizeof(ImVec2)); + ImVec2* temp_normals = (ImVec2*)alloca(points_count * (thick_line ? 5 : 3) * sizeof(ImVec2)); //-V630 ImVec2* temp_points = temp_normals + points_count; for (int i1 = 0; i1 < count; i1++) @@ -880,7 +880,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun } // Compute normals - ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); + ImVec2* temp_normals = (ImVec2*)alloca(points_count * sizeof(ImVec2)); //-V630 for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++) { const ImVec2& p0 = points[i0]; diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index fac87c1db..60aebb2a5 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -4007,7 +4007,7 @@ bool ImGui::ColorEdit4(const char* label, float col[4], ImGuiColorEditFlags flag { if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_3F)) { - memcpy((float*)col, payload->Data, sizeof(float) * 3); // Preserve alpha if any + memcpy((float*)col, payload->Data, sizeof(float) * 3); // Preserve alpha if any //-V512 value_changed = true; } if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F)) @@ -5485,7 +5485,7 @@ bool ImGui::BeginMainMenuBar() End(); return false; } - return true; + return true; //-V1020 } void ImGui::EndMainMenuBar() diff --git a/imstb_truetype.h b/imstb_truetype.h index e6162fab3..0b65350a0 100644 --- a/imstb_truetype.h +++ b/imstb_truetype.h @@ -1828,7 +1828,7 @@ static int stbtt__GetGlyphShapeTT(const stbtt_fontinfo *info, int glyph_index, s if (comp_verts) STBTT_free(comp_verts, info->userdata); return 0; } - if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex)); + if (num_vertices > 0) STBTT_memcpy(tmp, vertices, num_vertices*sizeof(stbtt_vertex)); //-V595 STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex)); if (vertices) STBTT_free(vertices, info->userdata); vertices = tmp; @@ -2199,7 +2199,7 @@ static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, st } break; default: - if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254)) + if (b0 != 255 && b0 != 28 && (b0 < 32 || b0 > 254)) //-V560 return STBTT__CSERR("reserved operator"); // push immediate