linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hartmut Knaack <knaack.h@gmx.de>
To: Cristina Opriceana <cristina.opriceana@gmail.com>, 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
Date: Mon, 13 Jul 2015 20:49:32 +0200	[thread overview]
Message-ID: <55A4083C.6030107@gmx.de> (raw)
In-Reply-To: <d636b387c2cee14901733a3d768d10f9cb6782b9.1436789446.git.cristina.opriceana@gmail.com>

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 <cristina.opriceana@gmail.com>
Acked-by: Hartmut Knaack <knaack.h@gmx.de>
> ---
>  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;
>  
>  /**
> 


  reply	other threads:[~2015-07-13 18:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-13 13:13 [PATCH 0/3] tools: iio: Fix style issues Cristina Opriceana
2015-07-13 13:15 ` [PATCH 1/3] tools: iio: Remove explicit NULL comparison Cristina Opriceana
2015-07-13 18:46   ` Hartmut Knaack
2015-07-19 14:01     ` Jonathan Cameron
2015-07-13 13:17 ` [PATCH 2/3] tools: iio: Remove unnecessary braces Cristina Opriceana
2015-07-13 18:48   ` Hartmut Knaack
2015-07-19 14:02     ` Jonathan Cameron
2015-07-13 13:20 ` [PATCH 3/3] tools: iio: Add ARRAY_SIZE macro Cristina Opriceana
2015-07-13 18:49   ` Hartmut Knaack [this message]
2015-07-19 14:03     ` Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55A4083C.6030107@gmx.de \
    --to=knaack.h@gmx.de \
    --cc=cristina.opriceana@gmail.com \
    --cc=daniel.baluta@intel.com \
    --cc=jic23@kernel.org \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=octavian.purdila@intel.com \
    --cc=pmeerw@pmeerw.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).