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>
This commit is contained in:
Berthold Stoeger 2021-07-20 12:28:34 +02:00 committed by Dirk Hohndel
parent 8ac0519a99
commit 0c84f369c3
2 changed files with 9 additions and 9 deletions

View file

@ -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;