From 7e6d9935f13db00ebb980c9d286c7bab0fea8a15 Mon Sep 17 00:00:00 2001 From: Josh Torres Date: Sun, 5 Sep 2021 17:07:08 -0700 Subject: core: fix off-by-one causing incorrect profile display In commit 4724c88 get_plot_details_new was updated to pass an index instead of the entry into plot_string. This means we are passing "i" to plot_string after the final increment of the for loop, instead of getting the entry[i] within the loop before the final increment. This means if we are mousing over the far right of the graph, where the time based break is not hit, we will end up passing an index equal to nr-2 instead of nr-3, which is intended to shave off the final two rows containing data not useful to the display. There are a handful of ways to fix this. This commit intends to be consistent with stylistic choices made elsewhere in the project. Signed-off-by: Josh Torres Signed-off-by: Dirk Hohndel --- core/profile.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/profile.c b/core/profile.c index 2db4c54c3..bde706bd0 100644 --- a/core/profile.c +++ b/core/profile.c @@ -1571,7 +1571,7 @@ int get_plot_details_new(const struct dive *d, const struct plot_info *pi, int t /* The two first and the two last plot entries do not have useful data */ if (pi->nr <= 4) return 0; - for (i = 2; i < pi->nr - 2; i++) { + for (i = 2; i < pi->nr - 3; i++) { if (pi->entry[i].sec >= time) break; } -- cgit v1.2.3-70-g09d2