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:
committed by
Mihai Tudor Panu
parent
b425c99030
commit
2bb200aa04
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user