mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Use the right type for sanitize_sensor_id()
It returned a 'uint8_t', which clashes pretty badly with NO_SENSOR being
-1, and turned it into 255. That then ended up historically working,
because before commit 0c84f369c3
("core: use int16_t for sensor-id")
we actually did that everywhere:
#define NO_SENSOR ((uint8_t)-1)
...
uint8_t sensor[MAX_SENSORS];
but that was changed to
#define NO_SENSOR -1
...
int16_t sensor[MAX_SENSORS];
and this helper type became wrong.
Just make it return 'int', avoiding any type narrowing issues.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
3446dd5125
commit
aa50be9cd5
2 changed files with 2 additions and 2 deletions
|
@ -644,7 +644,7 @@ static char *parse_sample_unit(struct sample *sample, double val, char *unit)
|
|||
/*
|
||||
* If the given cylinder doesn't exist, return NO_SENSOR.
|
||||
*/
|
||||
static uint8_t sanitize_sensor_id(const struct dive *d, int nr)
|
||||
static int sanitize_sensor_id(const struct dive *d, int nr)
|
||||
{
|
||||
return d && nr >= 0 && nr < d->cylinders.nr ? nr : NO_SENSOR;
|
||||
}
|
||||
|
|
|
@ -393,7 +393,7 @@ void ws_end(struct parser_state *state)
|
|||
/*
|
||||
* If the given cylinder doesn't exist, return NO_SENSOR.
|
||||
*/
|
||||
static uint8_t sanitize_sensor_id(const struct dive *d, int nr)
|
||||
static int sanitize_sensor_id(const struct dive *d, int nr)
|
||||
{
|
||||
return d && nr >= 0 && nr < d->cylinders.nr ? nr : NO_SENSOR;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue