Private
Public Access
2
0

mraa.c: we now remove trailing CR/LF from IIO dev names

E.g. on Edison they have LFs and that may cause problems
with downstream consumers of this data.

Signed-off-by: Alex Tereschenko <alext.mkrs@gmail.com>
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
Alex Tereschenko
2015-10-10 18:35:22 +02:00
committed by Brendan Le Foll
parent 325ac461d6
commit e5f28ab04c

View File

@@ -173,9 +173,12 @@ mraa_init()
if (fd > 0) {
len = read(fd, &name, 64);
if (len > 1) {
// remove any trailing CR/LF symbols
name[strcspn(name, "\r\n")] = '\0';
len = strlen(name);
// use strndup
device->name = malloc((sizeof(char) * len) + sizeof(char));
strncpy(device->name, name, len);
strncpy(device->name, name, len+1);
}
close(fd);
}