From 798e426926504674dfaafb2a88f33b130ef8d420 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 13 Jan 2024 10:46:36 +0100 Subject: [PATCH] cleanup: fix enum in profile.c There are two enums related to the type of dive. There is the global enum divemode_t {OC, CCR, PSCR, FREEDIVE, NUM_DIVEMODE, UNDEF_COMP_TYPE}; and the anonymous enum {AIR, NITROX, TRIMIX, FREEDIVING} dive_type; in struct plot_info. In profile.c FREEDIVE (of divemode_t) is assigned to dive_type. This only works because by chance(?) FREEDIVE and FREEDIVING are the fourth element of each enum. Fix this. C truly is a bad language when it comes to types (very weak) and namespaces (non existing). Contains whitespace fix. Signed-off-by: Berthold Stoeger --- core/profile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/profile.c b/core/profile.c index f6bf70f46..5129673bf 100644 --- a/core/profile.c +++ b/core/profile.c @@ -1302,9 +1302,9 @@ void create_plot_info_new(const struct dive *dive, const struct divecomputer *dc free_plot_info_data(pi); calculate_max_limits_new(dive, dc, pi, in_planner); get_dive_gas(dive, &o2, &he, &o2max); - if (dc->divemode == FREEDIVE){ - pi->dive_type = FREEDIVE; - } else if (he > 0) { + if (dc->divemode == FREEDIVE) { + pi->dive_type = FREEDIVING; + } else if (he > 0) { pi->dive_type = TRIMIX; } else { if (o2)