From 9d801c663f41589b37b386920cff0a823653e898 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 6 Aug 2014 06:19:31 -0700 Subject: [PATCH] Only show libdivecomputer "unlikely gas" warning once Fixes #696 Signed-off-by: Dirk Hohndel --- libdivecomputer.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libdivecomputer.c b/libdivecomputer.c index b599b3d14..0011a201d 100644 --- a/libdivecomputer.c +++ b/libdivecomputer.c @@ -98,6 +98,7 @@ static bool get_tanksize(device_data_t *devdata, const unsigned char *data, cyli static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t *parser, int ngases, const unsigned char *data) { + static bool shown_warning = false; int i; for (i = 0; i < ngases; i++) { @@ -117,11 +118,17 @@ static int parse_gasmixes(device_data_t *devdata, struct dive *dive, dc_parser_t /* Ignore bogus data - libdivecomputer does some crazy stuff */ if (o2 + he <= O2_IN_AIR || o2 > 1000) { - report_error("unlikely dive gas data from libdivecomputer: o2 = %d he = %d", o2, he); + if (!shown_warning) { + shown_warning = true; + report_error("unlikely dive gas data from libdivecomputer: o2 = %d he = %d", o2, he); + } o2 = 0; } if (he < 0 || o2 + he > 1000) { - report_error("unlikely dive gas data from libdivecomputer: o2 = %d he = %d", o2, he); + if (!shown_warning) { + shown_warning = true; + report_error("unlikely dive gas data from libdivecomputer: o2 = %d he = %d", o2, he); + } he = 0; } dive->cylinder[i].gasmix.o2.permille = o2;