Skip to content

Commit 4ba42f2

Browse files
committed
address a few static analysis warnings
1 parent 5714916 commit 4ba42f2

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

implot.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1193,7 +1193,7 @@ void Locator_Time(ImPlotTicker& ticker, const ImPlotRange& range, float pixels,
11931193
(void)vertical;
11941194
// get units for level 0 and level 1 labels
11951195
const ImPlotTimeUnit unit0 = GetUnitForRange(range.Size() / (pixels / 100)); // level = 0 (top)
1196-
const ImPlotTimeUnit unit1 = unit0 + 1; // level = 1 (bottom)
1196+
const ImPlotTimeUnit unit1 = ImClamp(unit0 + 1, 0, ImPlotTimeUnit_COUNT-1); // level = 1 (bottom)
11971197
// get time format specs
11981198
const ImPlotDateTimeSpec fmt0 = GetDateTimeFmt(TimeFormatLevel0, unit0);
11991199
const ImPlotDateTimeSpec fmt1 = GetDateTimeFmt(TimeFormatLevel1, unit1);

implot_internal.h

+22-10
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ enum ImPlotTimeFmt_ { // default [ 24 Hour Clock ]
261261
ImPlotTimeFmt_SUs, // :29.428 552 [ :29.428 552 ]
262262
ImPlotTimeFmt_SMs, // :29.428 [ :29.428 ]
263263
ImPlotTimeFmt_S, // :29 [ :29 ]
264-
ImPlotTimeFmt_MinSMs, // 21:29.428 [ 21:29.428 ]
264+
ImPlotTimeFmt_MinSMs, // 21:29.428 [ 21:29.428 ]
265265
ImPlotTimeFmt_HrMinSMs, // 7:21:29.428pm [ 19:21:29.428 ]
266266
ImPlotTimeFmt_HrMinS, // 7:21:29pm [ 19:21:29 ]
267267
ImPlotTimeFmt_HrMin, // 7:21pm [ 19:21 ]
@@ -437,6 +437,11 @@ struct ImPlotAnnotation {
437437
ImU32 ColorFg;
438438
int TextOffset;
439439
bool Clamp;
440+
ImPlotAnnotation() {
441+
ColorBg = ColorFg = 0;
442+
TextOffset = 0;
443+
Clamp = false;
444+
}
440445
};
441446

442447
// Collection of plot labels
@@ -540,6 +545,7 @@ struct ImPlotTick
540545
int Idx;
541546

542547
ImPlotTick(double value, bool major, int level, bool show_label) {
548+
PixelPos = 0;
543549
PlotPos = value;
544550
Major = major;
545551
ShowLabel = show_label;
@@ -666,6 +672,7 @@ struct ImPlotAxis
666672
bool Held;
667673

668674
ImPlotAxis() {
675+
ID = 0;
669676
Flags = PreviousFlags = ImPlotAxisFlags_None;
670677
Range.Min = 0;
671678
Range.Max = 1;
@@ -764,7 +771,7 @@ struct ImPlotAxis
764771

765772
inline void SetAspect(double unit_per_pix) {
766773
double new_size = unit_per_pix * PixelSize();
767-
double delta = (new_size - Range.Size()) * 0.5f;
774+
double delta = (new_size - Range.Size()) * 0.5;
768775
if (IsLocked())
769776
return;
770777
else if (IsLockedMin() && !IsLockedMax())
@@ -793,7 +800,7 @@ struct ImPlotAxis
793800
Range.Max += delta;
794801
}
795802
if (z > ConstraintZoom.Max) {
796-
double delta = (z - ConstraintZoom.Max) * 0.5f;
803+
double delta = (z - ConstraintZoom.Max) * 0.5;
797804
Range.Min += delta;
798805
Range.Max -= delta;
799806
}
@@ -945,6 +952,7 @@ struct ImPlotItem
945952

946953
ImPlotItem() {
947954
ID = 0;
955+
Color = IM_COL32_WHITE;
948956
NameOffset = -1;
949957
Show = true;
950958
SeenThisFrame = false;
@@ -986,7 +994,7 @@ struct ImPlotItemGroup
986994
ImPool<ImPlotItem> ItemPool;
987995
int ColormapIdx;
988996

989-
ImPlotItemGroup() { ColormapIdx = 0; }
997+
ImPlotItemGroup() { ID = 0; ColormapIdx = 0; }
990998

991999
int GetItemCount() const { return ItemPool.GetBufSize(); }
9921000
ImGuiID GetItemID(const char* label_id) { return ImGui::GetID(label_id); /* GetIDWithSeed */ }
@@ -1129,12 +1137,16 @@ struct ImPlotSubplot {
11291137
bool HasTitle;
11301138

11311139
ImPlotSubplot() {
1132-
Rows = Cols = CurrentIdx = 0;
1133-
FrameHovered = false;
1134-
Items.Legend.Location = ImPlotLocation_North;
1135-
Items.Legend.Flags = ImPlotLegendFlags_Horizontal|ImPlotLegendFlags_Outside;
1136-
Items.Legend.CanGoInside = false;
1137-
HasTitle = false;
1140+
ID = 0;
1141+
Flags = PreviousFlags = ImPlotSubplotFlags_None;
1142+
Rows = Cols = CurrentIdx = 0;
1143+
FrameHovered = false;
1144+
Items.Legend.Location = ImPlotLocation_North;
1145+
Items.Legend.Flags = ImPlotLegendFlags_Horizontal|ImPlotLegendFlags_Outside;
1146+
Items.Legend.CanGoInside = false;
1147+
TempSizes[0] = TempSizes[1] = 0;
1148+
FrameHovered = false;
1149+
HasTitle = false;
11381150
}
11391151
};
11401152

0 commit comments

Comments
 (0)