From 0c84f369c35bf416071b9ef6d5a401b457fd4a38 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 20 Jul 2021 12:28:34 +0200 Subject: core: use int16_t for sensor-id The sensor-id in the sample struct was a uint8_t, with all the known problems of unsigned integers. In the rest of the code cylinder ids are signed integers. To avoid confusion, make it a signed int. int8_t should be enough (max. 127 cylinders). To allow for degenerate cases, use an int16_t. 16k cylinders should be enough for everyone. Signed-off-by: Berthold Stoeger --- core/parse-xml.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'core/parse-xml.c') diff --git a/core/parse-xml.c b/core/parse-xml.c index da3a54ec3..c5864d6f5 100644 --- a/core/parse-xml.c +++ b/core/parse-xml.c @@ -700,7 +700,7 @@ static void try_to_match_autogroup(const char *name, char *buf) nonmatch("autogroup", name, buf); } -static void get_cylinderindex(char *buffer, uint8_t *i, struct parser_state *state) +static void get_cylinderindex(char *buffer, int16_t *i, struct parser_state *state) { *i = atoi(buffer); if (state->lastcylinderindex != *i) { @@ -709,7 +709,7 @@ static void get_cylinderindex(char *buffer, uint8_t *i, struct parser_state *sta } } -static void get_sensor(char *buffer, uint8_t *i) +static void get_sensor(char *buffer, int16_t *i) { *i = atoi(buffer); } @@ -839,7 +839,7 @@ static void try_to_fill_dc(struct divecomputer *dc, const char *name, char *buf, return; if (MATCH("dctype", get_dc_type, &dc->divemode)) return; - if (MATCH("no_o2sensors", get_sensor, &dc->no_o2sensors)) + if (MATCH("no_o2sensors", get_uint8, &dc->no_o2sensors)) return; if (match_dc_data_fields(dc, name, buf, state)) return; -- cgit v1.2.3-70-g09d2