Skip the size validation for unused divisors.

The recently introduced CNS support caused a regression for older
firmware versions. If a firmware doesn't support a certain sample
yet, the corresponding sample divisor and size are both equal to
zero (the default value for unused bytes). However, because the
size was always checked, regardless of whether the sample is
actually present or not, this zero size caused the parsing to fail.

To fix the regression, the size is now only checked when the
divisor indicates the sample is actually present.
This commit is contained in:
Jef Driesen 2012-12-11 22:14:11 +01:00
parent 17efdaf1d8
commit 531e5cb748

View File

@ -296,18 +296,20 @@ hw_ostc_parser_samples_foreach (dc_parser_t *abstract, dc_sample_callback_t call
for (unsigned int i = 0; i < NINFO; ++i) {
info[i].divisor = (data[37 + i] & 0x0F);
info[i].size = (data[37 + i] & 0xF0) >> 4;
switch (i) {
case 0: // Temperature
case 1: // Deco / NDL
if (info[i].size != 2)
return DC_STATUS_DATAFORMAT;
break;
case 5: // CNS
if (info[i].size != 1)
return DC_STATUS_DATAFORMAT;
break;
default: // Not yet used.
break;
if (info[i].divisor) {
switch (i) {
case 0: // Temperature
case 1: // Deco / NDL
if (info[i].size != 2)
return DC_STATUS_DATAFORMAT;
break;
case 5: // CNS
if (info[i].size != 1)
return DC_STATUS_DATAFORMAT;
break;
default: // Not yet used.
break;
}
}
}