Merge Jef's upstream fix for the OSTC4 CCR gas parsing issue reported by
Michael Keller.

This also effectively obviates (and undoes) the revert I did in commit
8d3271e586cd.

* https://github.com/libdivecomputer/libdivecomputer:
  Fix the OSTC4 diluent changes
This commit is contained in:
Linus Torvalds 2023-03-16 09:49:21 -07:00
commit 543bd58ddd

View File

@ -1049,8 +1049,12 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
return DC_STATUS_DATAFORMAT;
}
unsigned int idx = data[offset];
if (idx < 1 || idx > parser->ngasmixes) {
ERROR(abstract->context, "Invalid gas mix.");
if (parser->model == OSTC4 && ccr && idx > parser->nfixed) {
// Fix the OSTC4 diluent index.
idx -= parser->nfixed;
}
if (idx < 1 || idx > parser->nfixed) {
ERROR(abstract->context, "Invalid gas mix (%u).", idx);
return DC_STATUS_DATAFORMAT;
}
idx--; /* Convert to a zero based index. */