Skip to content

Commit

Permalink
tools: iio: Add ARRAY_SIZE macro
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Hartmut Knaack <[email protected]>
Signed-off-by: Jonathan Cameron <[email protected]>
  • Loading branch information
cristina2689 authored and jic23 committed Jul 20, 2015
1 parent 37d38e2 commit 34cbea1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tools/iio/iio_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ int iioutils_break_up_name(const char *full_name, char **generic_name)
char *working, *prefix = "";
int i, ret;

for (i = 0; i < sizeof(iio_direction) / sizeof(iio_direction[0]); i++)
for (i = 0; i < ARRAY_SIZE(iio_direction); i++)
if (!strncmp(full_name, iio_direction[i],
strlen(iio_direction[i]))) {
prefix = iio_direction[i];
Expand Down
2 changes: 2 additions & 0 deletions tools/iio/iio_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#define FORMAT_SCAN_ELEMENTS_DIR "%s/scan_elements"
#define FORMAT_TYPE_FILE "%s_type"

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0]))

extern const char *iio_dir;

/**
Expand Down

0 comments on commit 34cbea1

Please sign in to comment.