From 469cc68b029ac3308b4338a43acfa21679493e8b Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Fri, 5 Jul 2019 23:14:07 +0200 Subject: Cleanup: replace pressure reading macros by inline functions Replace the INTERPOLATED_PRESSURE and SENSOR_PRESSURE macros by inline functions. Generate a common inline function that reads a pressure value for a dynamic sensor. Not all SENSOR_PRESSURE macros can be replaced, because the macro is also used to set the value and C sadly doesn't know the concept of "return reference from a function". Signed-off-by: Berthold Stoeger --- core/gaspressures.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/gaspressures.c') diff --git a/core/gaspressures.c b/core/gaspressures.c index 3b84aad24..2109c2702 100644 --- a/core/gaspressures.c +++ b/core/gaspressures.c @@ -352,7 +352,7 @@ static void debug_print_pressures(struct plot_info *pi) int i; for (i = 0; i < pi->nr; i++) { struct plot_data *entry = pi->entry + i; - printf("%5d |%9d | %9d |\n", i, SENSOR_PRESSURE(entry), INTERPOLATED_PRESSURE(entry)); + printf("%5d |%9d | %9d |\n", i, get_plot_sensor_pressure(entry), get_plot_interpolated_pressure(entry)); } } #endif @@ -388,7 +388,7 @@ void populate_pressure_information(struct dive *dive, struct divecomputer *dc, s first = last = -1; for (int i = 0; i < pi->nr; i++) { struct plot_data *entry = pi->entry + i; - unsigned pressure = SENSOR_PRESSURE(entry, sensor); + int pressure = get_plot_sensor_pressure(entry, sensor); if (!pressure) continue; @@ -417,7 +417,7 @@ void populate_pressure_information(struct dive *dive, struct divecomputer *dc, s for (int i = first; i <= last; i++) { struct plot_data *entry = pi->entry + i; - unsigned pressure = SENSOR_PRESSURE(entry, sensor); + int pressure = get_plot_sensor_pressure(entry, sensor); int time = entry->sec; while (ev && ev->time.seconds <= time) { // Find 1st gaschange event after -- cgit v1.2.3-70-g09d2