Skip to content

Commit

Permalink
Improved matching on global attributes for differential channels
Browse files Browse the repository at this point in the history
Signed-off-by: fpagliughi <[email protected]>
  • Loading branch information
fpagliughi committed Jan 31, 2020
1 parent d94e149 commit 17148ef
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions local.c
Original file line number Diff line number Diff line change
Expand Up @@ -1480,16 +1480,18 @@ static unsigned int is_global_attr(struct iio_channel *chn, const char *attr)

len = ptr - attr;

// Check if matching global differential attr,
// like "voltage-voltage"
// Check for matching global differential attr, like "voltage-voltage"
dashptr = strchr(attr, '-');
if (dashptr && dashptr > attr && dashptr < ptr) {
unsigned int len1 = dashptr - attr,
len2 = ptr - dashptr - 1;
if (chn->id[len1] >= '0' && chn->id[len1] <= '9' &&
const char* iddashptr = strchr(chn->id, '-');
if (iddashptr && strlen(iddashptr+1) > len2 &&
iddashptr - chn->id > len1 &&
chn->id[len1] >= '0' && chn->id[len1] <= '9' &&
!strncmp(chn->id, attr, len1) &&
chn->id[len+1] >= '0' && chn->id[len+1] <= '9' &&
!strncmp(chn->id+len1+2, attr+len1+1, len2))
iddashptr[len2+1] >= '0' && iddashptr[len2+1] <= '9' &&
!strncmp(iddashptr+1, dashptr+1, len2))
return 1;
}

Expand Down

0 comments on commit 17148ef

Please sign in to comment.