Private
Public Access
2
0

iio: iio get channel and get event error checking

Signed-off-by: Lay, Kuan Loon <kuan.loon.lay@intel.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Lay, Kuan Loon
2015-10-20 18:59:30 +08:00
committed by Brendan Le Foll
parent 078b6371d7
commit 2df28fa883

View File

@@ -90,6 +90,9 @@ mraa_iio_get_channel_data(mraa_iio_context dev)
}
}
dev->chan_num = chan_num;
//no need proceed if no channel found
if (chan_num == 0)
return MRAA_SUCCESS;
mraa_iio_channel* chan;
dev->channels = calloc(chan_num, sizeof(mraa_iio_channel));
seekdir(dir, 0);
@@ -304,6 +307,9 @@ mraa_iio_get_event_data(mraa_iio_context dev)
}
}
dev->event_num = event_num;
//no need proceed if no event found
if (event_num == 0)
return MRAA_SUCCESS;
mraa_iio_event* event;
dev->events = calloc(event_num, sizeof(mraa_iio_event));
if ( dev->events == NULL)