X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=tools%2Fiio%2Fiio_utils.c;h=5eb6793f3972e64ed2c46533cd2e6aa5d65168fa;hb=fac33bfdb0a54e149f8d1c2f002de5b57770b84c;hp=a95270f3335376ca46f494ba8190a9343e8bffea;hpb=ae067cb68d2ef42d4a84eeaf07411fe2936f48c4;p=firefly-linux-kernel-4.4.55.git diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index a95270f33353..5eb6793f3972 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c @@ -6,9 +6,6 @@ * under the terms of the GNU General Public License version 2 as published by * the Free Software Foundation. */ -#ifndef _IIO_UTILS_H -#define _IIO_UTILS_H - #include #include #include @@ -289,17 +286,17 @@ error_free_builtname: * @cnt: the amount of array elements **/ -void bsort_channel_array_by_index(struct iio_channel_info **ci_array, int cnt) +void bsort_channel_array_by_index(struct iio_channel_info *ci_array, int cnt) { struct iio_channel_info temp; int x, y; for (x = 0; x < cnt; x++) for (y = 0; y < (cnt - 1); y++) - if ((*ci_array)[y].index > (*ci_array)[y + 1].index) { - temp = (*ci_array)[y + 1]; - (*ci_array)[y + 1] = (*ci_array)[y]; - (*ci_array)[y] = temp; + if (ci_array[y].index > ci_array[y + 1].index) { + temp = ci_array[y + 1]; + ci_array[y + 1] = ci_array[y]; + ci_array[y] = temp; } } @@ -519,7 +516,7 @@ int build_channel_array(const char *device_dir, free(scan_el_dir); /* reorder so that the array is in index order */ - bsort_channel_array_by_index(ci_array, *counter); + bsort_channel_array_by_index(*ci_array, *counter); return 0; @@ -529,6 +526,8 @@ error_cleanup_array: free((*ci_array)[i].generic_name); } free(*ci_array); + *ci_array = NULL; + *counter = 0; error_close_dir: if (dp) if (closedir(dp) == -1) @@ -540,7 +539,7 @@ error_free_name: return ret; } -int calc_digits(int num) +static int calc_digits(int num) { int count = 0; @@ -990,5 +989,3 @@ error_free: return ret; } - -#endif /* _IIO_UTILS_H */