cleanup: replace MIN and MAX macrors by standard versions

In C++ files, replace MIN and MAX by std::min and std::max,
respectively. There are still a few C files using these
macros. Convert them in due course.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-03-23 09:16:59 +01:00 committed by bstoeger
parent b89029353f
commit ec0bc2d06c
6 changed files with 16 additions and 16 deletions

View file

@ -436,10 +436,10 @@ extern "C" void calc_crushing_pressure(struct deco_state *ds, double pressure)
n2_crushing_pressure = pressure - n2_inner_pressure;
he_crushing_pressure = pressure - he_inner_pressure;
}
ds->max_n2_crushing_pressure[ci] = MAX(ds->max_n2_crushing_pressure[ci], n2_crushing_pressure);
ds->max_he_crushing_pressure[ci] = MAX(ds->max_he_crushing_pressure[ci], he_crushing_pressure);
ds->max_n2_crushing_pressure[ci] = std::max(ds->max_n2_crushing_pressure[ci], n2_crushing_pressure);
ds->max_he_crushing_pressure[ci] = std::max(ds->max_he_crushing_pressure[ci], he_crushing_pressure);
}
ds->max_ambient_pressure = MAX(pressure, ds->max_ambient_pressure);
ds->max_ambient_pressure = std::max(pressure, ds->max_ambient_pressure);
}
/* add period_in_seconds at the given pressure and gas to the deco calculation */
@ -589,7 +589,7 @@ extern "C" double get_gf(struct deco_state *ds, double ambpressure_bar, const st
double gf_high = buehlmann_config.gf_high;
double gf;
if (ds->gf_low_pressure_this_dive > surface_pressure_bar)
gf = MAX((double)gf_low, (ambpressure_bar - surface_pressure_bar) /
gf = std::max((double)gf_low, (ambpressure_bar - surface_pressure_bar) /
(ds->gf_low_pressure_this_dive - surface_pressure_bar) * (gf_low - gf_high) + gf_high);
else
gf = gf_low;

View file

@ -608,7 +608,7 @@ extern "C" int explicit_first_cylinder(const struct dive *dive, const struct div
if (ev && ((dc->sample && ev->time.seconds == dc->sample[0].time.seconds) || ev->time.seconds <= 1))
res = get_cylinder_index(dive, ev);
else if (dc->divemode == CCR)
res = MAX(get_cylinder_idx_by_use(dive, DILUENT), res);
res = std::max(get_cylinder_idx_by_use(dive, DILUENT), res);
}
return res < dive->cylinders.nr ? res : 0;
}
@ -852,7 +852,7 @@ static void fixup_duration(struct dive *dive)
duration_t duration = { };
for_each_relevant_dc (dive, dc) {
duration.seconds = MAX(duration.seconds, dc->duration.seconds);
duration.seconds = std::max(duration.seconds, dc->duration.seconds);
}
dive->duration.seconds = duration.seconds;
}
@ -1311,8 +1311,8 @@ extern "C" struct dive *fixup_dive(struct dive *dive)
}
/* Don't pick a zero for MERGE_MIN() */
#define MERGE_MAX(res, a, b, n) res->n = MAX(a->n, b->n)
#define MERGE_MIN(res, a, b, n) res->n = (a->n) ? (b->n) ? MIN(a->n, b->n) : (a->n) : (b->n)
#define MERGE_MAX(res, a, b, n) res->n = std::max(a->n, b->n)
#define MERGE_MIN(res, a, b, n) res->n = (a->n) ? (b->n) ? std::min(a->n, b->n) : (a->n) : (b->n)
#define MERGE_TXT(res, a, b, n, sep) res->n = merge_text(a->n, b->n, sep)
#define MERGE_NONZERO(res, a, b, n) res->n = a->n ? a->n : b->n
@ -2333,7 +2333,7 @@ static int likely_same_dive(const struct dive *a, const struct dive *b)
* Allow a time difference due to dive computer time
* setting etc. Check if they overlap.
*/
fuzz = MAX(a->duration.seconds, b->duration.seconds) / 2;
fuzz = std::max(a->duration.seconds, b->duration.seconds) / 2;
if (fuzz < 60)
fuzz = 60;

View file

@ -163,7 +163,7 @@ static dc_status_t parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_
}
clear_cylinder_table(&dive->cylinders);
for (i = 0; i < MAX(ngases, ntanks); i++) {
for (i = 0; i < std::max(ngases, ntanks); i++) {
cylinder_t cyl = empty_cylinder;
cyl.cylinder_use = NOT_USED;

View file

@ -852,7 +852,7 @@ bool plan(struct deco_state *ds, struct diveplan *diveplan, struct dive *dive, i
if ((divemode == CCR || divemode == PSCR) && prefs.dobailout) {
divemode = OC;
po2 = 0;
int bailoutsegment = MAX(prefs.min_switch_duration, 60 * prefs.problemsolvingtime);
int bailoutsegment = std::max(prefs.min_switch_duration, 60 * prefs.problemsolvingtime);
add_segment(ds, depth_to_bar(depth, dive),
get_cylinder(dive, current_cylinder)->gasmix,
bailoutsegment, po2, divemode, prefs.bottomsac, true);

View file

@ -79,7 +79,7 @@ extern "C" int get_maxtime(const struct plot_info *pi)
{
int seconds = pi->maxtime;
int min = prefs.zoomed_plot ? 30 : 30 * 60;
return MAX(min, seconds);
return std::max(min, seconds);
}
/* get the maximum depth to which we want to plot */
@ -87,7 +87,7 @@ extern "C" int get_maxdepth(const struct plot_info *pi)
{
/* 3m to spare */
int mm = pi->maxdepth + 3000;
return prefs.zoomed_plot ? mm : MAX(30000, mm);
return prefs.zoomed_plot ? mm : std::max(30000, mm);
}
/* UNUSED! */
@ -1265,7 +1265,7 @@ static void fill_o2_values(const struct dive *dive, const struct divecomputer *d
} // having initialised the empty o2 sensor values for this point on the profile,
amb_pressure.mbar = depth_to_mbar(entry->depth, dive);
o2pressure.mbar = calculate_ccr_po2(entry, dc); // ...calculate the po2 based on the sensor data
entry->o2pressure.mbar = MIN(o2pressure.mbar, amb_pressure.mbar);
entry->o2pressure.mbar = std::min(o2pressure.mbar, amb_pressure.mbar);
} else {
entry->o2pressure.mbar = 0; // initialise po2 to zero for dctype = OC
}

View file

@ -487,8 +487,8 @@ static bool is_same_cylinder(cylinder_t *cyl_a, cylinder_t *cyl_b)
* Macros are copied from dive.c
*/
#define MERGE_MAX(res, a, b, n) res->n = MAX(a->n, b->n)
#define MERGE_MIN(res, a, b, n) res->n = (a->n) ? (b->n) ? MIN(a->n, b->n) : (a->n) : (b->n)
#define MERGE_MAX(res, a, b, n) res->n = std::max(a->n, b->n)
#define MERGE_MIN(res, a, b, n) res->n = (a->n) ? (b->n) ? std::min(a->n, b->n) : (a->n) : (b->n)
static void merge_cylinder_type(cylinder_type_t *src, cylinder_type_t *dst)
{