Skip to content

Commit

Permalink
sorting: ensure sorting happens after global attributes are added
Browse files Browse the repository at this point in the history
If global attributes are added after sorting, they are not included
in the sort, which defeats the purpose of things. This puts things
in the proper order (add all the attributes, then sort them).

Signed-off-by: Robin Getz <[email protected]>
  • Loading branch information
rgetz authored and commodo committed Nov 7, 2018
1 parent f05434e commit ed6709e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions local.c
Original file line number Diff line number Diff line change
Expand Up @@ -1767,15 +1767,18 @@ static int create_device(void *d, const char *path)
free_protected_attrs(chn);
if (ret < 0)
goto err_free_scan_elements;

qsort(chn->attrs, chn->nb_attrs, sizeof(struct iio_channel_attr),
iio_channel_attr_compare);
}

ret = detect_and_move_global_attrs(dev);
if (ret < 0)
goto err_free_device;

/* sorting is done after global attrs are added */
for (i = 0; i < dev->nb_channels; i++) {
struct iio_channel *chn = dev->channels[i];
qsort(chn->attrs, chn->nb_attrs, sizeof(struct iio_channel_attr),
iio_channel_attr_compare);
}
qsort(dev->attrs, dev->nb_attrs, sizeof(char *),
iio_device_attr_compare);

Expand Down

0 comments on commit ed6709e

Please sign in to comment.