diff options
author | Cristina Opriceana <cristina.opriceana@gmail.com> | 2015-07-13 09:20:11 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2015-07-20 13:41:23 -0400 |
commit | 34cbea1908fb686b037e01e5b1ab8e0e67b09ed3 (patch) | |
tree | 7c6186632a1e254502f133a8c4b94a25a45faa57 | |
parent | 37d38e2bcce055c3988977429dc4336c866df73d (diff) |
tools: iio: Add ARRAY_SIZE macro
Calculation of the length of an array can be done with the ARRAY_SIZE
macro to make code more abstract and remove the associated
checkpatch.pl warning.
Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com>
Acked-by: Hartmut Knaack <knaack.h@gmx.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | tools/iio/iio_utils.c | 2 | ||||
-rw-r--r-- | tools/iio/iio_utils.h | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c index 4a7e4801cebf..e177f4022d40 100644 --- a/tools/iio/iio_utils.c +++ b/tools/iio/iio_utils.c | |||
@@ -39,7 +39,7 @@ int iioutils_break_up_name(const char *full_name, char **generic_name) | |||
39 | char *working, *prefix = ""; | 39 | char *working, *prefix = ""; |
40 | int i, ret; | 40 | int i, ret; |
41 | 41 | ||
42 | for (i = 0; i < sizeof(iio_direction) / sizeof(iio_direction[0]); i++) | 42 | for (i = 0; i < ARRAY_SIZE(iio_direction); i++) |
43 | if (!strncmp(full_name, iio_direction[i], | 43 | if (!strncmp(full_name, iio_direction[i], |
44 | strlen(iio_direction[i]))) { | 44 | strlen(iio_direction[i]))) { |
45 | prefix = iio_direction[i]; | 45 | prefix = iio_direction[i]; |
diff --git a/tools/iio/iio_utils.h b/tools/iio/iio_utils.h index 086610139ade..f30a1091b53e 100644 --- a/tools/iio/iio_utils.h +++ b/tools/iio/iio_utils.h | |||
@@ -18,6 +18,8 @@ | |||
18 | #define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements" | 18 | #define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements" |
19 | #define FORMAT_TYPE_FILE "%s_type" | 19 | #define FORMAT_TYPE_FILE "%s_type" |
20 | 20 | ||
21 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) | ||
22 | |||
21 | extern const char *iio_dir; | 23 | extern const char *iio_dir; |
22 | 24 | ||
23 | /** | 25 | /** |