Skip to content

Commit

Permalink
Handle channel IDs without index or modifier correctly
Browse files Browse the repository at this point in the history
Channel whose ID is "timestamp" has type IIO_CHAN_TYPE_UNKNOWN
before this patch, but it should be IIO_TIMESTAMP.

Signed-off-by: Ryo Hashimoto <[email protected]>
  • Loading branch information
hshmt committed Feb 8, 2020
1 parent f7c5e7f commit d7838e4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ void iio_channel_init_finalize(struct iio_channel *chn)
len = strlen(iio_chan_type_name_spec[i]);
if (strncmp(iio_chan_type_name_spec[i], chn->id, len) != 0)
continue;
/* Type must be followed by either a '_' or a digit */
if (chn->id[len] != '_' && (chn->id[len] < '0' || chn->id[len] > '9'))
/* Type must be followed by one of a '\0', a '_', or a digit */
if (chn->id[len] != '\0' && chn->id[len] != '_' &&
(chn->id[len] < '0' || chn->id[len] > '9'))
continue;

chn->type = (enum iio_chan_type) i;
Expand Down

0 comments on commit d7838e4

Please sign in to comment.