Private
Public Access
2
0

iio/iio.c: Add fix for division by 0 bug

Signed-off-by: Cosmin Popescu <gabrielcosmin.popescu@gmail.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>
This commit is contained in:
Cosmin Popescu
2019-01-16 13:41:28 +02:00
committed by Mihai Tudor Panu
parent b425c99030
commit 2bb200aa04

View File

@@ -175,7 +175,14 @@ mraa_iio_get_channel_data(mraa_iio_context dev)
// channel location has to be done in channel index order so do it afetr we
// have grabbed all the correct info
for (i = 0; i < dev->chan_num; i++) {
chan = &dev->channels[i];
chan = &dev->channels[i];
if(chan->bytes <= 0)
{
syslog(LOG_ERR, "iio: Channel %d with channel bytes value <= 0");
return MRAA_IO_SETUP_FAILURE;
}
if (curr_bytes % chan->bytes == 0) {
chan->location = curr_bytes;
} else {