Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752735AbbGMSto (ORCPT ); Mon, 13 Jul 2015 14:49:44 -0400 Received: from mout.gmx.net ([212.227.17.21]:51446 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752598AbbGMStm (ORCPT ); Mon, 13 Jul 2015 14:49:42 -0400 Message-ID: <55A4083C.6030107@gmx.de> Date: Mon, 13 Jul 2015 20:49:32 +0200 From: Hartmut Knaack User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:36.0) Gecko/20100101 Firefox/36.0 SeaMonkey/2.33.1 MIME-Version: 1.0 To: Cristina Opriceana , jic23@kernel.org CC: lars@metafoo.de, pmeerw@pmeerw.net, linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, daniel.baluta@intel.com, octavian.purdila@intel.com Subject: Re: [PATCH 3/3] tools: iio: Add ARRAY_SIZE macro References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:RuVrhWvEra1zcKLZYLiiGTDzDcnzkLBTobrdm6fHjGoEMF49iy8 lsqwCAZiDrxi71UIvMqYKQXzUzRQef3Itfm6QPmYdmowa31/6K1eumQRUnyYzjPUovf2nN7 HbGufAyvhvF49F3smvRPCzL6RZ5seq4r19zP/ngbB3DCt8XfPh5GRYCVEagGPw99JEgrApw JX3h6mgnqk+BXaSuF/cZw== X-UI-Out-Filterresults: notjunk:1;V01:K0:Q0GIYaZLm7Y=:qSPHPGnZl9fg5Su+Im9JUD KnPY8kiU9SbiLuqB8FjzP62tmvojvV3DZMeEcGss4ngaRqfig66qoNiku80CpbSBiLZDKyevc oyDyIS0oQu1lgrZEf/NsjLRN7Hr5Q3wt8S4I6ea1A0iy4jX8W3oFR3ZRK418Rn7g2YmvlteuS 6pd38Ktw3vQkMDKyZ11qNbsVD7wwPWhDpfUhw5o0kvBS/Y9A1EQ8a84v6AIr6D82NKYZWsPio Y2Mm8fonAd9ZjkcNKxJKBpfGnxlv8vMJT1bc87S8NlRsWzDj56nvll6o84tk0zLlPpYDB4xW7 SYIp+Fa7WDEaTMBpuO+yzwBtDatzCGv50lK1NTNW7kUuQR0dmeirDv7E5NVjU3MuXgtLhlatw uzu3fPNn5P7QUwR79OfFaWduv/0QubhiVsEnlRxf9g0iRHz+lONcGVjU3ymlHJeB2ovkWVUzr kgi9dP0IVKV1IdfNS84ovsDWtApdmqdISaYjx/y83YIMu9WxAS5nMAg7a1cJzGI/wzu6ufIJc a+EsvqWPSTv/PpPbQaUKgrQuQsEESfBEkXhQgfw+lhfyX8YpJtJvycyQsdk/EjjvDw25ii36Z hCzcYWDPZazqj2ZSOeWo+YUzT9cb49Y6mUSmJRn/1NMastXwKxCJ57VSRWwAUc4eWmn2Ay9eu yd3DoNxKMouSZUulyTBfTJCEa122JNSxrmnZ8mxjEGorfC06gm4+QijHK4QYum4eMLxU= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1613 Lines: 45 Cristina Opriceana schrieb am 13.07.2015 um 15:20: > 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 Acked-by: Hartmut Knaack > --- > tools/iio/iio_utils.c | 2 +- > tools/iio/iio_utils.h | 2 ++ > 2 files changed, 3 insertions(+), 1 deletion(-) > > diff --git a/tools/iio/iio_utils.c b/tools/iio/iio_utils.c > index 4a7e480..e177f40 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) > 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]; > diff --git a/tools/iio/iio_utils.h b/tools/iio/iio_utils.h > index 0866101..f30a109 100644 > --- a/tools/iio/iio_utils.h > +++ b/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; > > /** > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/