Persistently fixing some PVS-Studio static analyzer false positive warnings.
diff --git a/imgui_demo.cpp b/imgui_demo.cpp
index d325749..0ff6fb4 100644
--- a/imgui_demo.cpp
+++ b/imgui_demo.cpp
@@ -882,7 +882,7 @@
// 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 046600a..b73299b 100644
--- a/imgui_draw.cpp
+++ b/imgui_draw.cpp
@@ -689,7 +689,7 @@
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 @@
}
// 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 fac87c1..60aebb2 100644
--- a/imgui_widgets.cpp
+++ b/imgui_widgets.cpp
@@ -4007,7 +4007,7 @@
{
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 @@
End();
return false;
}
- return true;
+ return true; //-V1020
}
void ImGui::EndMainMenuBar()
diff --git a/imstb_truetype.h b/imstb_truetype.h
index e6162fa..0b65350 100644
--- a/imstb_truetype.h
+++ b/imstb_truetype.h
@@ -1828,7 +1828,7 @@
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 @@
} 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