From 5a61ffcc2f3e2f520be526f7ff1c368bcfa2a8a1 Mon Sep 17 00:00:00 2001 From: Jef Driesen Date: Sun, 3 May 2015 20:09:43 +0200 Subject: [PATCH] Use a variable for gauge mode. This makes the code a little bit more readable, without needing any comments. --- src/suunto_vyper_parser.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/suunto_vyper_parser.c b/src/suunto_vyper_parser.c index 910670f..69f0b90 100644 --- a/src/suunto_vyper_parser.c +++ b/src/suunto_vyper_parser.c @@ -243,6 +243,8 @@ suunto_vyper_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi if (rc != DC_STATUS_SUCCESS) return rc; + unsigned int gauge = data[4] & 0x40; + if (value) { switch (type) { case DC_FIELD_DIVETIME: @@ -252,8 +254,8 @@ suunto_vyper_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi *((double *) value) = parser->maxdepth * FEET; break; case DC_FIELD_GASMIX_COUNT: - if (data[4] & 0x40) - *((unsigned int *) value) = 0; // Gauge mode + if (gauge) + *((unsigned int *) value) = 0; else *((unsigned int *) value) = parser->ngasmixes; break; @@ -269,7 +271,7 @@ suunto_vyper_parser_get_field (dc_parser_t *abstract, dc_field_type_t type, unsi *((double *) value) = (signed char) data[parser->marker + 1]; break; case DC_FIELD_DIVEMODE: - if (data[4] & 0x40) { + if (gauge) { *((dc_divemode_t *) value) = DC_DIVEMODE_GAUGE; } else { *((dc_divemode_t *) value) = DC_DIVEMODE_OC;