瀏覽代碼

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>
Cristina Opriceana 10 年之前
父節點
當前提交
34cbea1908
共有 2 個文件被更改,包括 3 次插入1 次删除
  1. 1 1
      tools/iio/iio_utils.c
  2. 2 0
      tools/iio/iio_utils.h

+ 1 - 1
tools/iio/iio_utils.c

@@ -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];

+ 2 - 0
tools/iio/iio_utils.h

@@ -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;
 
 /**