Browse Source

Persistently fixing some PVS-Studio static analyzer false positive warnings.

omar 6 năm trước cách đây
mục cha
commit
4e8e177cac
4 tập tin đã thay đổi với 7 bổ sung7 xóa
  1. 1 1
      imgui_demo.cpp
  2. 2 2
      imgui_draw.cpp
  3. 2 2
      imgui_widgets.cpp
  4. 2 2
      imstb_truetype.h

+ 1 - 1
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.
                     // 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 x = i % 4;
                     int y = 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 (x < 3 && i < 15) { selected[i + 1] ^= 1; }
                     if (y > 0 && i > 3)  { selected[i - 4] ^= 1; }
                     if (y > 0 && i > 3)  { selected[i - 4] ^= 1; }
                     if (y < 3 && i < 12) { selected[i + 4] ^= 1; }
                     if (y < 3 && i < 12) { selected[i + 4] ^= 1; }

+ 2 - 2
imgui_draw.cpp

@@ -689,7 +689,7 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
         PrimReserve(idx_count, vtx_count);
         PrimReserve(idx_count, vtx_count);
 
 
         // Temporary buffer
         // 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;
         ImVec2* temp_points = temp_normals + points_count;
 
 
         for (int i1 = 0; i1 < count; i1++)
         for (int i1 = 0; i1 < count; i1++)
@@ -880,7 +880,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
         }
         }
 
 
         // Compute normals
         // 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++)
         for (int i0 = points_count-1, i1 = 0; i1 < points_count; i0 = i1++)
         {
         {
             const ImVec2& p0 = points[i0];
             const ImVec2& p0 = points[i0];

+ 2 - 2
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))
         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;
             value_changed = true;
         }
         }
         if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F))
         if (const ImGuiPayload* payload = AcceptDragDropPayload(IMGUI_PAYLOAD_TYPE_COLOR_4F))
@@ -5485,7 +5485,7 @@ bool ImGui::BeginMainMenuBar()
         End();
         End();
         return false;
         return false;
     }
     }
-    return true;
+    return true; //-V1020
 }
 }
 
 
 void ImGui::EndMainMenuBar()
 void ImGui::EndMainMenuBar()

+ 2 - 2
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);
                if (comp_verts) STBTT_free(comp_verts, info->userdata);
                return 0;
                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));
             STBTT_memcpy(tmp+num_vertices, comp_verts, comp_num_verts*sizeof(stbtt_vertex));
             if (vertices) STBTT_free(vertices, info->userdata);
             if (vertices) STBTT_free(vertices, info->userdata);
             vertices = tmp;
             vertices = tmp;
@@ -2199,7 +2199,7 @@ static int stbtt__run_charstring(const stbtt_fontinfo *info, int glyph_index, st
       } break;
       } break;
 
 
       default:
       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");
             return STBTT__CSERR("reserved operator");
 
 
          // push immediate
          // push immediate