diff options
author | 2021-07-20 12:28:34 +0200 | |
---|---|---|
committer | 2021-07-23 11:16:00 -0700 | |
commit | 0c84f369c35bf416071b9ef6d5a401b457fd4a38 (patch) | |
tree | d5e3fd55c7c5113537d14a17ee2406ecbf4b1e19 /core/parse-xml.c | |
parent | 8ac0519a9954b58f43bc42dd70c5643169543999 (diff) | |
download | subsurface-0c84f369c35bf416071b9ef6d5a401b457fd4a38.tar.gz |
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 <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/parse-xml.c')
-rw-r--r-- | core/parse-xml.c | 6 |
1 files changed, 3 insertions, 3 deletions
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; |