Not sure what I had in mind with that multiplication. Anyway, the
buffer is zero-initialized, so keep it at a reasonable size, which
is to say... 32. That's plenty enough for now, as the maximum we
encountered is 20 (accel x,y,z 16 bits + gyro x,y,z + 64 bits ts).
We don't need the expected data size calculation, because the
values are set to zero by default, and because that sum would not
be correct anyway in the case where fields such as the timestamp
are shared between sensors. Plus, we were not even verifying that
the computed sum did really fit our buffer.
Issue: STPK-1429
Change-Id: Ie001ceeb634866a1460444bb839918045b72de31
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
{
int len;
int s,c;
- unsigned char buf[MAX_SENSOR_REPORT_SIZE * MAX_SENSORS] = { 0 };
+ unsigned char buf[MAX_SENSOR_REPORT_SIZE] = { 0 };
int sr_offset;
unsigned char *target;
unsigned char *source;
int size;
- int expected_size = 0;
int ts;
/* There's an incoming report on the specified fd */
return -1;
}
- for (s=0; s<MAX_SENSORS; s++)
- if (sensor_info[s].dev_num == dev_num)
- for (c=0; c<sensor_info[s].num_channels; c++)
- expected_size += sensor_info[s].channel[c].size;
-
ts = get_timestamp();
- len = read(device_fd[dev_num], buf, expected_size);
+ len = read(device_fd[dev_num], buf, MAX_SENSOR_REPORT_SIZE);
if (len == -1) {
ALOGE("Could not read report from iio device %d (%s)\n",