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
@@ -176,6 +176,13 @@ mraa_iio_get_channel_data(mraa_iio_context dev)
|
|||||||
// have grabbed all the correct info
|
// have grabbed all the correct info
|
||||||
for (i = 0; i < dev->chan_num; i++) {
|
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) {
|
if (curr_bytes % chan->bytes == 0) {
|
||||||
chan->location = curr_bytes;
|
chan->location = curr_bytes;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user