[PATCH 1/3] Gas usage statistics: don't require gas switch events

Linus Torvalds torvalds at linux-foundation.org
Sat Jul 22 08:50:56 PDT 2017


From: Linus Torvalds <torvalds at linux-foundation.org>
Date: Sat, 22 Jul 2017 08:28:39 -0700
Subject: [PATCH 1/3] Gas usage statistics: don't require gas switch events

Our "get_has_used()" helper only filled in gas usage for cylinders that
had a gas change event associated with them.  That works really badly
for things like CCR, but also simply for cases where the dive computer
wasn't necessarily explicitly notified about usage, like sidemount
diving etc.

Just remove the logic.  If some use ends up particularly wanting to
ignore some cylinder, they can always do it in the caller instead.

Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
---
 core/statistics.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/core/statistics.c b/core/statistics.c
index d86fe632..ff812212 100644
--- a/core/statistics.c
+++ b/core/statistics.c
@@ -345,23 +345,11 @@ void get_gas_used(struct dive *dive, volume_t gases[MAX_CYLINDERS])
 {
 	int idx;
 	struct divecomputer *dc;
-	bool used;
 
 	for (idx = 0; idx < MAX_CYLINDERS; idx++) {
-		used = false;
 		cylinder_t *cyl = &dive->cylinder[idx];
 		pressure_t start, end;
 
-		for_each_dc(dive, dc) {
-			if (same_string(dc->model, "planned dive"))
-				continue;
-			if (has_gaschange_event(dive, dc, idx))
-				used = true;
-		}
-
-		if (!used)
-			continue;
-
 		start = cyl->start.mbar ? cyl->start : cyl->sample_start;
 		end = cyl->end.mbar ? cyl->end : cyl->sample_end;
 		if (end.mbar && start.mbar > end.mbar)
-- 
2.13.1.518.g0d864c4df



More information about the subsurface mailing list