From bb00a9728f2d473b0e6426fd0db4fcde6c81c475 Mon Sep 17 00:00:00 2001 From: Michael Keller Date: Fri, 26 Apr 2024 11:04:05 +1200 Subject: [PATCH] Cleanup: More Fixes for Problems Reported by Coverity. Fix the problem another way as Coverity was still not happy with it. Signed-off-by: Michael Keller --- core/profile.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/profile.cpp b/core/profile.cpp index 1d3bb80a7..c16793d4b 100644 --- a/core/profile.cpp +++ b/core/profile.cpp @@ -762,7 +762,8 @@ static void setup_gas_sensor_pressure(const struct dive *dive, const struct dive std::vector last(num_cyl, INT_MAX); const struct divecomputer *secondary; - unsigned prev = (unsigned)explicit_first_cylinder(dive, dc); + int prev = explicit_first_cylinder(dive, dc); + prev = prev >= 0 ? prev : 0; seen[prev] = 1; for (ev = get_next_event(dc->events, "gaschange"); ev != NULL; ev = get_next_event(ev->next, "gaschange")) {