From: Brendan Le Foll Date: Mon, 28 Sep 2015 15:53:31 +0000 (+0100) Subject: mraa.c: Fix path of iio device in sysfs X-Git-Tag: v0.9.0~61 X-Git-Url: http://review.tizen.org/git/?p=contrib%2Fmraa.git;a=commitdiff_plain;h=ba9ab4b38461e94fa5aff4d27db1eccbe034b03e mraa.c: Fix path of iio device in sysfs Signed-off-by: Brendan Le Foll --- diff --git a/src/mraa.c b/src/mraa.c index 6e2b6be..36f7dc6 100644 --- a/src/mraa.c +++ b/src/mraa.c @@ -171,12 +171,14 @@ mraa_init() for (i=0; i < num_iio_devices; i++) { device = &plat->iio_devices[i]; device->num = i; - snprintf(filepath, 64, "/sys/bus/iio/devices/iio:device%d", i); + snprintf(filepath, 64, "/sys/bus/iio/devices/iio:device%d/name", i); fd = open(filepath, O_RDONLY); if (fd != -1) { len = read(fd, &name, 64); - device->name = malloc((sizeof(char) * len) + sizeof(char)); - strncpy(device->name, name, len); + if (len > 1) { + device->name = malloc((sizeof(char) * len) + sizeof(char)); + strncpy(device->name, name, len); + } } }